Backed out changeset 32ce387c5487 (bug 987010) for crashes.

CLOSED TREE
This commit is contained in:
Ryan VanderMeulen 2014-03-26 15:58:07 -04:00
parent 336a053131
commit a852688935
3 changed files with 18 additions and 20 deletions

View File

@ -699,9 +699,15 @@ DrawTargetSkia::InitWithGrContext(GrContext* aGrContext,
void void
DrawTargetSkia::Init(unsigned char* aData, const IntSize &aSize, int32_t aStride, SurfaceFormat aFormat) DrawTargetSkia::Init(unsigned char* aData, const IntSize &aSize, int32_t aStride, SurfaceFormat aFormat)
{ {
SkAlphaType alphaType = kPremul_SkAlphaType;
if (aFormat == SurfaceFormat::B8G8R8X8) {
// We have to manually set the A channel to be 255 as Skia doesn't understand BGRX
ConvertBGRXToBGRA(aData, aSize, aStride);
alphaType = kOpaque_SkAlphaType;
}
SkBitmap bitmap; SkBitmap bitmap;
bitmap.setConfig(GfxFormatToSkiaConfig(aFormat), aSize.width, aSize.height, aStride, bitmap.setConfig(GfxFormatToSkiaConfig(aFormat), aSize.width, aSize.height, aStride, alphaType);
SkAlphaTypeForGfxFormat(aFormat));
bitmap.setPixels(aData); bitmap.setPixels(aData);
SkAutoTUnref<SkCanvas> canvas(new SkCanvas(new SkBitmapDevice(bitmap))); SkAutoTUnref<SkCanvas> canvas(new SkCanvas(new SkBitmapDevice(bitmap)));

View File

@ -19,22 +19,6 @@
namespace mozilla { namespace mozilla {
namespace gfx { namespace gfx {
static inline SkAlphaType
SkAlphaTypeForGfxFormat(SurfaceFormat format)
{
switch (format)
{
case SurfaceFormat::B8G8R8X8:
case SurfaceFormat::R8G8B8X8:
return kIgnore_SkAlphaType;
case SurfaceFormat::R5G6B5:
return kOpaque_SkAlphaType;
default:
return kPremul_SkAlphaType;
}
}
static inline SkBitmap::Config static inline SkBitmap::Config
GfxFormatToSkiaConfig(SurfaceFormat format) GfxFormatToSkiaConfig(SurfaceFormat format)
{ {

View File

@ -65,14 +65,22 @@ SourceSurfaceSkia::InitFromData(unsigned char* aData,
SurfaceFormat aFormat) SurfaceFormat aFormat)
{ {
SkBitmap temp; SkBitmap temp;
temp.setConfig(GfxFormatToSkiaConfig(aFormat), aSize.width, aSize.height, aStride, temp.setConfig(GfxFormatToSkiaConfig(aFormat), aSize.width, aSize.height, aStride);
SkAlphaTypeForGfxFormat(aFormat));
temp.setPixels(aData); temp.setPixels(aData);
if (!temp.copyTo(&mBitmap, GfxFormatToSkiaColorType(aFormat))) { if (!temp.copyTo(&mBitmap, GfxFormatToSkiaColorType(aFormat))) {
return false; return false;
} }
if (aFormat == SurfaceFormat::B8G8R8X8) {
mBitmap.lockPixels();
// We have to manually set the A channel to be 255 as Skia doesn't understand BGRX
ConvertBGRXToBGRA(reinterpret_cast<unsigned char*>(mBitmap.getPixels()), aSize, mBitmap.rowBytes());
mBitmap.unlockPixels();
mBitmap.notifyPixelsChanged();
mBitmap.setAlphaType(kOpaque_SkAlphaType);
}
mSize = aSize; mSize = aSize;
mFormat = aFormat; mFormat = aFormat;
mStride = mBitmap.rowBytes(); mStride = mBitmap.rowBytes();