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 88a31f9729
commit a0a7f1acec
3 changed files with 18 additions and 20 deletions

View File

@ -699,9 +699,15 @@ DrawTargetSkia::InitWithGrContext(GrContext* aGrContext,
void
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;
bitmap.setConfig(GfxFormatToSkiaConfig(aFormat), aSize.width, aSize.height, aStride,
SkAlphaTypeForGfxFormat(aFormat));
bitmap.setConfig(GfxFormatToSkiaConfig(aFormat), aSize.width, aSize.height, aStride, alphaType);
bitmap.setPixels(aData);
SkAutoTUnref<SkCanvas> canvas(new SkCanvas(new SkBitmapDevice(bitmap)));

View File

@ -19,22 +19,6 @@
namespace mozilla {
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
GfxFormatToSkiaConfig(SurfaceFormat format)
{

View File

@ -65,14 +65,22 @@ SourceSurfaceSkia::InitFromData(unsigned char* aData,
SurfaceFormat aFormat)
{
SkBitmap temp;
temp.setConfig(GfxFormatToSkiaConfig(aFormat), aSize.width, aSize.height, aStride,
SkAlphaTypeForGfxFormat(aFormat));
temp.setConfig(GfxFormatToSkiaConfig(aFormat), aSize.width, aSize.height, aStride);
temp.setPixels(aData);
if (!temp.copyTo(&mBitmap, GfxFormatToSkiaColorType(aFormat))) {
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;
mFormat = aFormat;
mStride = mBitmap.rowBytes();