mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 15:52:07 +00:00
Backed out changeset 32ce387c5487 (bug 987010) for crashes.
CLOSED TREE
This commit is contained in:
parent
336a053131
commit
a852688935
@ -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)));
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user