From: commit-bot@chromium.org Date: Mon, 17 Feb 2014 21:21:46 +0000 (+0000) Subject: replace SkBitmap::Config with SkColorType in gms X-Git-Tag: submit/tizen/20180928.044319~8978 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dac522589e9395b4654a1a708f1bd971f37f95a5;p=platform%2Fupstream%2FlibSkiaSharp.git replace SkBitmap::Config with SkColorType in gms add helper installMaskPixels() to SkBitmap BUG=skia: R=halcanary@google.com Author: reed@google.com Review URL: https://codereview.chromium.org/169913003 git-svn-id: http://skia.googlecode.com/svn/trunk@13482 2bbb7eff-a529-9590-31e7-b0007b416f81 --- diff --git a/gm/bitmapfilters.cpp b/gm/bitmapfilters.cpp index 5856f87f66..7addf25c01 100644 --- a/gm/bitmapfilters.cpp +++ b/gm/bitmapfilters.cpp @@ -20,8 +20,9 @@ static void make_bm(SkBitmap* bm) { } SkColorTable* ctable = new SkColorTable(colorsPM, 4); - bm->setConfig(SkBitmap::kIndex8_Config, 2, 2); - bm->allocPixels(ctable); + bm->allocPixels(SkImageInfo::Make(2, 2, kIndex_8_SkColorType, + kPremul_SkAlphaType), + NULL, ctable); ctable->unref(); *bm->getAddr8(0, 0) = 0; diff --git a/gm/bitmappremul.cpp b/gm/bitmappremul.cpp index 57d22d700a..fd563eb775 100644 --- a/gm/bitmappremul.cpp +++ b/gm/bitmappremul.cpp @@ -22,14 +22,15 @@ static const int SLIDE_SIZE = 256; static const int PIXEL_SIZE_8888 = SLIDE_SIZE / 256; static const int PIXEL_SIZE_4444 = SLIDE_SIZE / 16; -static void init_bitmap(SkBitmap::Config config, SkBitmap* bitmap) { - bitmap->allocConfigPixels(config, SLIDE_SIZE, SLIDE_SIZE); +static void init_bitmap(SkColorType ct, SkBitmap* bitmap) { + bitmap->allocPixels(SkImageInfo::Make(SLIDE_SIZE, SLIDE_SIZE, ct, + kPremul_SkAlphaType)); bitmap->eraseColor(SK_ColorWHITE); } static SkBitmap make_argb8888_gradient() { SkBitmap bitmap; - init_bitmap(SkBitmap::kARGB_8888_Config, &bitmap); + init_bitmap(kPMColor_SkColorType, &bitmap); uint8_t rowColor = 0; for (int y = 0; y < SLIDE_SIZE; y++) { uint32_t* dst = bitmap.getAddr32(0, y); @@ -46,7 +47,7 @@ static SkBitmap make_argb8888_gradient() { static SkBitmap make_argb4444_gradient() { SkBitmap bitmap; - init_bitmap(SkBitmap::kARGB_4444_Config, &bitmap); + init_bitmap(kARGB_4444_SkColorType, &bitmap); uint8_t rowColor = 0; for (int y = 0; y < SLIDE_SIZE; y++) { uint16_t* dst = bitmap.getAddr16(0, y); @@ -63,7 +64,7 @@ static SkBitmap make_argb4444_gradient() { static SkBitmap make_argb8888_stripes() { SkBitmap bitmap; - init_bitmap(SkBitmap::kARGB_8888_Config, &bitmap); + init_bitmap(kPMColor_SkColorType, &bitmap); uint8_t rowColor = 0; for (int y = 0; y < SLIDE_SIZE; y++) { uint32_t* dst = bitmap.getAddr32(0, y); @@ -82,7 +83,7 @@ static SkBitmap make_argb8888_stripes() { static SkBitmap make_argb4444_stripes() { SkBitmap bitmap; - init_bitmap(SkBitmap::kARGB_4444_Config, &bitmap); + init_bitmap(kARGB_4444_SkColorType, &bitmap); uint8_t rowColor = 0;; for (int y = 0; y < SLIDE_SIZE; y++) { uint16_t* dst = bitmap.getAddr16(0, y); diff --git a/gm/bitmapshader.cpp b/gm/bitmapshader.cpp index d1915c9c90..4649b7e95f 100644 --- a/gm/bitmapshader.cpp +++ b/gm/bitmapshader.cpp @@ -28,7 +28,7 @@ static void draw_mask(SkBitmap* bm) { SkPaint circlePaint; circlePaint.setColor(SK_ColorBLACK); - bm->allocConfigPixels(SkBitmap::kA8_Config, 20, 20); + bm->allocPixels(SkImageInfo::MakeA8(20, 20)); bm->eraseColor(SK_ColorTRANSPARENT); SkCanvas canvas(*bm); diff --git a/gm/blurrect.cpp b/gm/blurrect.cpp index 3197eb6fc6..52edd6a105 100644 --- a/gm/blurrect.cpp +++ b/gm/blurrect.cpp @@ -197,8 +197,7 @@ protected: SkAutoMaskFreeImage amfi(mask.fImage); SkBitmap bm; - bm.setConfig(SkBitmap::kA8_Config, mask.fBounds.width(), mask.fBounds.height()); - bm.setPixels(mask.fImage); + bm.installMaskPixels(mask); center_x = (canvas_size.fWidth - mask.fBounds.width())/2; center_y = (canvas_size.fHeight - mask.fBounds.height())/2; diff --git a/gm/drawbitmaprect.cpp b/gm/drawbitmaprect.cpp index 31cba51e79..664958a06b 100644 --- a/gm/drawbitmaprect.cpp +++ b/gm/drawbitmaprect.cpp @@ -28,8 +28,8 @@ static SkBitmap make_chessbm(int w, int h) { return bm; } -static void makebm(SkBitmap* bm, SkBitmap::Config config, int w, int h) { - bm->allocConfigPixels(config, w, h); +static void makebm(SkBitmap* bm, int w, int h) { + bm->allocN32Pixels(w, h); bm->eraseColor(SK_ColorTRANSPARENT); SkCanvas canvas(*bm); @@ -89,9 +89,7 @@ protected: virtual void onDraw(SkCanvas* canvas) { static const int kBmpSize = 2048; if (fLargeBitmap.isNull()) { - makebm(&fLargeBitmap, - SkBitmap::kARGB_8888_Config, - kBmpSize, kBmpSize); + makebm(&fLargeBitmap, kBmpSize, kBmpSize); } SkRect dstRect = { 0, 0, SkIntToScalar(64), SkIntToScalar(64)}; static const int kMaxSrcRectSize = 1 << (SkNextLog2(kBmpSize) + 2); diff --git a/gm/gmmain.cpp b/gm/gmmain.cpp index 687ee45a66..d6457abb58 100644 --- a/gm/gmmain.cpp +++ b/gm/gmmain.cpp @@ -265,16 +265,16 @@ public: otherwise on compare we may not get a perfect match. */ static void force_all_opaque(const SkBitmap& bitmap) { - SkBitmap::Config config = bitmap.config(); - switch (config) { - case SkBitmap::kARGB_8888_Config: + SkColorType colorType = bitmap.colorType(); + switch (colorType) { + case kPMColor_SkColorType: force_all_opaque_8888(bitmap); break; - case SkBitmap::kRGB_565_Config: + case kRGB_565_SkColorType: // nothing to do here; 565 bitmaps are inherently opaque break; default: - gm_fprintf(stderr, "unsupported bitmap config %d\n", config); + gm_fprintf(stderr, "unsupported bitmap colorType %d\n", colorType); DEBUGFAIL_SEE_STDERR; } } @@ -590,8 +590,7 @@ public: // the device is as large as the current rendertarget, so // we explicitly only readback the amount we expect (in // size) overwrite our previous allocation - bitmap->setConfig(SkBitmap::kARGB_8888_Config, size.fWidth, - size.fHeight); + bitmap->setConfig(SkImageInfo::MakeN32Premul(size.fWidth, size.fHeight)); canvas->readPixels(bitmap, 0, 0); } #endif @@ -741,8 +740,8 @@ public: return; } - if ((SkBitmap::kARGB_8888_Config != expectedBitmap.config()) || - (SkBitmap::kARGB_8888_Config != actualBitmap.config())) { + if ((kPMColor_SkColorType != expectedBitmap.colorType()) || + (kPMColor_SkColorType != actualBitmap.colorType())) { gm_fprintf(stderr, "---- %s: not computing max per-channel" " pixel mismatch because non-8888\n", testName); return; diff --git a/gm/shadertext.cpp b/gm/shadertext.cpp index eccd8cbe12..4af5b0d49d 100644 --- a/gm/shadertext.cpp +++ b/gm/shadertext.cpp @@ -12,8 +12,8 @@ namespace skiagm { -static void makebm(SkBitmap* bm, SkBitmap::Config config, int w, int h) { - bm->allocConfigPixels(config, w, h); +static void makebm(SkBitmap* bm, int w, int h) { + bm->allocN32Pixels(w, h); bm->eraseColor(SK_ColorTRANSPARENT); SkCanvas canvas(*bm); @@ -39,7 +39,7 @@ static SkShader* MakeBitmapShader(SkShader::TileMode tx, SkShader::TileMode ty, int w, int h) { static SkBitmap bmp; if (bmp.isNull()) { - makebm(&bmp, SkBitmap::kARGB_8888_Config, w/2, h/4); + makebm(&bmp, w/2, h/4); } return SkShader::CreateBitmapShader(bmp, tx, ty); } diff --git a/gm/shadertext2.cpp b/gm/shadertext2.cpp index dcff3c69bd..1e6ae5ca2c 100644 --- a/gm/shadertext2.cpp +++ b/gm/shadertext2.cpp @@ -11,8 +11,8 @@ namespace skiagm { -static void makebm(SkBitmap* bm, SkBitmap::Config config, int w, int h) { - bm->allocConfigPixels(config, w, h); +static void makebm(SkBitmap* bm, int w, int h) { + bm->allocN32Pixels(w, h); bm->eraseColor(SK_ColorTRANSPARENT); SkCanvas canvas(*bm); @@ -92,7 +92,7 @@ protected: static SkBitmap bmp; if (bmp.isNull()) { - makebm(&bmp, SkBitmap::kARGB_8888_Config, kPointSize / 2, kPointSize / 2); + makebm(&bmp, kPointSize / 2, kPointSize / 2); } SkAutoTUnref shader(SkShader::CreateBitmapShader(bmp, diff --git a/gm/shadertext3.cpp b/gm/shadertext3.cpp index 15b4f99317..29ceac4579 100644 --- a/gm/shadertext3.cpp +++ b/gm/shadertext3.cpp @@ -11,8 +11,8 @@ namespace skiagm { -static void makebm(SkBitmap* bm, SkBitmap::Config config, int w, int h) { - bm->allocConfigPixels(config, w, h); +static void makebm(SkBitmap* bm, int w, int h) { + bm->allocN32Pixels(w, h); bm->eraseColor(SK_ColorTRANSPARENT); SkCanvas canvas(*bm); @@ -68,7 +68,7 @@ protected: static SkBitmap bmp; if (bmp.isNull()) { - makebm(&bmp, SkBitmap::kARGB_8888_Config, kPointSize / 4, kPointSize / 4); + makebm(&bmp, kPointSize / 4, kPointSize / 4); } SkPaint bmpPaint; diff --git a/gm/simpleaaclip.cpp b/gm/simpleaaclip.cpp index e8946b446c..a517b50dc1 100644 --- a/gm/simpleaaclip.cpp +++ b/gm/simpleaaclip.cpp @@ -21,9 +21,7 @@ static void paint_rgn(SkCanvas* canvas, const SkAAClip& clip, SkAutoMaskFreeImage amfi(mask.fImage); - bm.setConfig(SkBitmap::kA8_Config, mask.fBounds.width(), - mask.fBounds.height(), mask.fRowBytes); - bm.setPixels(mask.fImage); + bm.installMaskPixels(mask); // need to copy for deferred drawing test to work SkBitmap bm2; diff --git a/gm/tilemodes.cpp b/gm/tilemodes.cpp index 0b0a3ae6df..5b97f13fc8 100644 --- a/gm/tilemodes.cpp +++ b/gm/tilemodes.cpp @@ -19,8 +19,8 @@ #include "SkUnitMappers.h" #include "SkBlurDrawLooper.h" -static void makebm(SkBitmap* bm, SkBitmap::Config config, int w, int h) { - bm->allocConfigPixels(config, w, h); +static void makebm(SkBitmap* bm, SkColorType ct, int w, int h) { + bm->allocPixels(SkImageInfo::Make(w, h, ct, kPremul_SkAlphaType)); bm->eraseColor(SK_ColorTRANSPARENT); SkCanvas canvas(*bm); @@ -49,9 +49,9 @@ static void setup(SkPaint* paint, const SkBitmap& bm, bool filter, paint->setFilterLevel(filter ? SkPaint::kLow_FilterLevel : SkPaint::kNone_FilterLevel); } -static const SkBitmap::Config gConfigs[] = { - SkBitmap::kARGB_8888_Config, - SkBitmap::kRGB_565_Config, +static const SkColorType gColorTypes[] = { + kPMColor_SkColorType, + kRGB_565_SkColorType, }; class TilingGM : public skiagm::GM { @@ -60,7 +60,7 @@ public: : fPowerOfTwoSize(powerOfTwoSize) { } - SkBitmap fTexture[SK_ARRAY_COUNT(gConfigs)]; + SkBitmap fTexture[SK_ARRAY_COUNT(gColorTypes)]; protected: @@ -81,8 +81,8 @@ protected: virtual void onOnceBeforeDraw() SK_OVERRIDE { int size = fPowerOfTwoSize ? kPOTSize : kNPOTSize; - for (size_t i = 0; i < SK_ARRAY_COUNT(gConfigs); i++) { - makebm(&fTexture[i], gConfigs[i], size, size); + for (size_t i = 0; i < SK_ARRAY_COUNT(gColorTypes); i++) { + makebm(&fTexture[i], gColorTypes[i], size, size); } } @@ -120,7 +120,7 @@ protected: y += SkIntToScalar(16); - for (size_t i = 0; i < SK_ARRAY_COUNT(gConfigs); i++) { + for (size_t i = 0; i < SK_ARRAY_COUNT(gColorTypes); i++) { for (size_t j = 0; j < SK_ARRAY_COUNT(gFilters); j++) { x = SkIntToScalar(10); for (size_t kx = 0; kx < SK_ARRAY_COUNT(gModes); kx++) { @@ -129,7 +129,7 @@ protected: #if 1 // Temporary change to regen bitmap before each draw. This may help tracking down an issue // on SGX where resizing NPOT textures to POT textures exhibits a driver bug. if (!fPowerOfTwoSize) { - makebm(&fTexture[i], gConfigs[i], size, size); + makebm(&fTexture[i], gColorTypes[i], size, size); } #endif setup(&paint, fTexture[i], gFilters[j], gModes[kx], gModes[ky]); @@ -166,7 +166,7 @@ static const int gHeight = 32; static SkShader* make_bm(SkShader::TileMode tx, SkShader::TileMode ty) { SkBitmap bm; - makebm(&bm, SkBitmap::kARGB_8888_Config, gWidth, gHeight); + makebm(&bm, kPMColor_SkColorType, gWidth, gHeight); return SkShader::CreateBitmapShader(bm, tx, ty); } diff --git a/gm/tilemodes_scaled.cpp b/gm/tilemodes_scaled.cpp index 603a78fb1e..932d3f7220 100644 --- a/gm/tilemodes_scaled.cpp +++ b/gm/tilemodes_scaled.cpp @@ -19,8 +19,8 @@ #include "SkUnitMappers.h" #include "SkBlurDrawLooper.h" -static void makebm(SkBitmap* bm, SkBitmap::Config config, int w, int h) { - bm->allocConfigPixels(config, w, h); +static void makebm(SkBitmap* bm, SkColorType ct, int w, int h) { + bm->allocPixels(SkImageInfo::Make(w, h, ct, kPremul_SkAlphaType)); bm->eraseColor(SK_ColorTRANSPARENT); SkCanvas canvas(*bm); @@ -49,9 +49,9 @@ static void setup(SkPaint* paint, const SkBitmap& bm, SkPaint::FilterLevel filte paint->setFilterLevel(filter_level); } -static const SkBitmap::Config gConfigs[] = { - SkBitmap::kARGB_8888_Config, - SkBitmap::kRGB_565_Config, +static const SkColorType gColorTypes[] = { + kPMColor_SkColorType, + kRGB_565_SkColorType, }; class ScaledTilingGM : public skiagm::GM { @@ -62,7 +62,7 @@ public: , fPowerOfTwoSize(powerOfTwoSize) { } - SkBitmap fTexture[SK_ARRAY_COUNT(gConfigs)]; + SkBitmap fTexture[SK_ARRAY_COUNT(gColorTypes)]; protected: @@ -83,8 +83,8 @@ protected: virtual void onOnceBeforeDraw() SK_OVERRIDE { int size = fPowerOfTwoSize ? kPOTSize : kNPOTSize; - for (size_t i = 0; i < SK_ARRAY_COUNT(gConfigs); i++) { - makebm(&fTexture[i], gConfigs[i], size, size); + for (size_t i = 0; i < SK_ARRAY_COUNT(gColorTypes); i++) { + makebm(&fTexture[i], gColorTypes[i], size, size); } } @@ -96,7 +96,7 @@ protected: SkRect r = { 0, 0, SkIntToScalar(size*2), SkIntToScalar(size*2) }; - static const char* gConfigNames[] = { "8888" , "565", "4444" }; + static const char* gColorTypeNames[] = { "8888" , "565", "4444" }; static const SkPaint::FilterLevel gFilterLevels[] = { SkPaint::kNone_FilterLevel, @@ -129,7 +129,7 @@ protected: y = SkIntToScalar(40) / scale; - for (size_t i = 0; i < SK_ARRAY_COUNT(gConfigs); i++) { + for (size_t i = 0; i < SK_ARRAY_COUNT(gColorTypes); i++) { for (size_t j = 0; j < SK_ARRAY_COUNT(gFilterLevels); j++) { x = SkIntToScalar(10)/scale; for (size_t kx = 0; kx < SK_ARRAY_COUNT(gModes); kx++) { @@ -138,7 +138,7 @@ protected: #if 1 // Temporary change to regen bitmap before each draw. This may help tracking down an issue // on SGX where resizing NPOT textures to POT textures exhibits a driver bug. if (!fPowerOfTwoSize) { - makebm(&fTexture[i], gConfigs[i], size, size); + makebm(&fTexture[i], gColorTypes[i], size, size); } #endif setup(&paint, fTexture[i], gFilterLevels[j], gModes[kx], gModes[ky]); @@ -158,7 +158,7 @@ protected: SkString str; p.setAntiAlias(true); p.setLooper(&fLooper); - str.printf("%s, %s", gConfigNames[i], gFilterNames[j]); + str.printf("%s, %s", gColorTypeNames[i], gFilterNames[j]); canvas->drawText(str.c_str(), str.size(), scale*x, scale*(y + r.height() * 2 / 3), p); } @@ -177,7 +177,7 @@ static const int gHeight = 32; static SkShader* make_bm(SkShader::TileMode tx, SkShader::TileMode ty) { SkBitmap bm; - makebm(&bm, SkBitmap::kARGB_8888_Config, gWidth, gHeight); + makebm(&bm, kPMColor_SkColorType, gWidth, gHeight); return SkShader::CreateBitmapShader(bm, tx, ty); } diff --git a/gm/tinybitmap.cpp b/gm/tinybitmap.cpp index 6cb9eded73..92bf7c645f 100644 --- a/gm/tinybitmap.cpp +++ b/gm/tinybitmap.cpp @@ -18,8 +18,9 @@ static SkBitmap make_bitmap() { SkColorTable* ctable = new SkColorTable(c, SK_ARRAY_COUNT(c)); SkBitmap bm; - bm.setConfig(SkBitmap::kIndex8_Config, 1, 1); - bm.allocPixels(ctable); + bm.allocPixels(SkImageInfo::Make(1, 1, kIndex_8_SkColorType, + kPremul_SkAlphaType), + NULL, ctable); ctable->unref(); bm.lockPixels(); diff --git a/gm/xfermodes.cpp b/gm/xfermodes.cpp index 353bebf56f..b5ce8b8ced 100644 --- a/gm/xfermodes.cpp +++ b/gm/xfermodes.cpp @@ -31,8 +31,7 @@ static void make_bitmaps(int w, int h, SkBitmap* src, SkBitmap* dst, c.drawOval(r, p); } - dst->setConfig(SkBitmap::kARGB_8888_Config, w, h); - dst->allocPixels(); + dst->allocN32Pixels(w, h); dst->eraseColor(SK_ColorTRANSPARENT); { @@ -42,8 +41,7 @@ static void make_bitmaps(int w, int h, SkBitmap* src, SkBitmap* dst, c.drawRect(r, p); } - transparent->setConfig(SkBitmap::kARGB_8888_Config, w, h); - transparent->allocPixels(); + transparent->allocN32Pixels(w, h); transparent->eraseColor(SK_ColorTRANSPARENT); } @@ -150,8 +148,9 @@ class XfermodesGM : public GM { } virtual void onOnceBeforeDraw() SK_OVERRIDE { - fBG.setConfig(SkBitmap::kARGB_4444_Config, 2, 2, 4, kOpaque_SkAlphaType); - fBG.setPixels(gData); + fBG.installPixels(SkImageInfo::Make(2, 2, kARGB_4444_SkColorType, + kOpaque_SkAlphaType), + gData, 4); make_bitmaps(W, H, &fSrcB, &fDstB, &fTransparent); } diff --git a/include/core/SkBitmap.h b/include/core/SkBitmap.h index b6851def98..35928db2a2 100644 --- a/include/core/SkBitmap.h +++ b/include/core/SkBitmap.h @@ -14,6 +14,7 @@ #include "SkPoint.h" #include "SkRefCnt.h" +struct SkMask; struct SkIRect; struct SkRect; class SkPaint; @@ -307,6 +308,22 @@ public: bool installPixels(const SkImageInfo&, void* pixels, size_t rowBytes, void (*ReleaseProc)(void* addr, void* context), void* context); + + /** + * Call installPixels with no ReleaseProc specified. This means that the + * caller must ensure that the specified pixels are valid for the lifetime + * of the created bitmap (and its pixelRef). + */ + bool installPixels(const SkImageInfo& info, void* pixels, size_t rowBytes) { + return this->installPixels(info, pixels, rowBytes, NULL, NULL); + } + + /** + * Calls installPixels() with the value in the SkMask. The caller must + * ensure that the specified mask pixels are valid for the lifetime + * of the created bitmap (and its pixelRef). + */ + bool installMaskPixels(const SkMask&); /** * DEPRECATED: call info(). diff --git a/samplecode/SampleAAClip.cpp b/samplecode/SampleAAClip.cpp index 5419f68ed1..a1ee67b75f 100644 --- a/samplecode/SampleAAClip.cpp +++ b/samplecode/SampleAAClip.cpp @@ -46,9 +46,7 @@ static void drawClip(SkCanvas* canvas, const SkAAClip& clip) { clip.copyToMask(&mask); SkAutoMaskFreeImage amfi(mask.fImage); - bm.installPixels(SkImageInfo::MakeA8(mask.fBounds.width(), - mask.fBounds.height()), - mask.fImage, mask.fRowBytes, NULL, NULL); + bm.installMaskPixels(mask); SkPaint paint; canvas->drawBitmap(bm, diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp index 151ab50290..b6c2e2f65c 100644 --- a/src/core/SkBitmap.cpp +++ b/src/core/SkBitmap.cpp @@ -519,6 +519,16 @@ bool SkBitmap::installPixels(const SkImageInfo& info, void* pixels, size_t rb, return true; } +bool SkBitmap::installMaskPixels(const SkMask& mask) { + if (SkMask::kA8_Format != mask.fFormat) { + this->reset(); + return false; + } + return this->installPixels(SkImageInfo::MakeA8(mask.fBounds.width(), + mask.fBounds.height()), + mask.fImage, mask.fRowBytes); +} + bool SkBitmap::allocConfigPixels(Config config, int width, int height, bool isOpaque) { SkColorType ct; diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp index f4d399b80f..7a20295156 100644 --- a/src/effects/SkBlurMaskFilter.cpp +++ b/src/effects/SkBlurMaskFilter.cpp @@ -195,9 +195,7 @@ static bool draw_rrect_into_mask(const SkRRect rrect, SkMask* mask) { // FIXME: This code duplicates code in draw_rects_into_mask, below. Is there a // clean way to share more code? SkBitmap bitmap; - bitmap.installPixels(SkImageInfo::MakeA8(mask->fBounds.width(), - mask->fBounds.height()), - mask->fImage, mask->fRowBytes, NULL, NULL); + bitmap.installMaskPixels(*mask); SkCanvas canvas(bitmap); canvas.translate(-SkIntToScalar(mask->fBounds.left()), diff --git a/src/effects/SkLayerRasterizer.cpp b/src/effects/SkLayerRasterizer.cpp index 65ebd8ad1a..a10d758ede 100644 --- a/src/effects/SkLayerRasterizer.cpp +++ b/src/effects/SkLayerRasterizer.cpp @@ -122,9 +122,7 @@ bool SkLayerRasterizer::onRasterize(const SkPath& path, const SkMatrix& matrix, translatedMatrix.postTranslate(-SkIntToScalar(mask->fBounds.fLeft), -SkIntToScalar(mask->fBounds.fTop)); - device.installPixels(SkImageInfo::MakeA8(mask->fBounds.width(), - mask->fBounds.height()), - mask->fImage, mask->fRowBytes, NULL, NULL); + device.installMaskPixels(*mask); draw.fBitmap = &device; draw.fMatrix = &drawMatrix;