diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-02-17 21:21:46 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-02-17 21:21:46 +0000 |
commit | dac522589e9395b4654a1a708f1bd971f37f95a5 (patch) | |
tree | 3190dc309541bf8b706bee789b0a9ffce1771728 /gm | |
parent | 5c056399259bb7ec06ff1eb8ce904001b363276c (diff) |
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
Diffstat (limited to 'gm')
-rw-r--r-- | gm/bitmapfilters.cpp | 5 | ||||
-rw-r--r-- | gm/bitmappremul.cpp | 13 | ||||
-rw-r--r-- | gm/bitmapshader.cpp | 2 | ||||
-rw-r--r-- | gm/blurrect.cpp | 3 | ||||
-rw-r--r-- | gm/drawbitmaprect.cpp | 8 | ||||
-rw-r--r-- | gm/gmmain.cpp | 17 | ||||
-rw-r--r-- | gm/shadertext.cpp | 6 | ||||
-rw-r--r-- | gm/shadertext2.cpp | 6 | ||||
-rw-r--r-- | gm/shadertext3.cpp | 6 | ||||
-rw-r--r-- | gm/simpleaaclip.cpp | 4 | ||||
-rw-r--r-- | gm/tilemodes.cpp | 22 | ||||
-rw-r--r-- | gm/tilemodes_scaled.cpp | 26 | ||||
-rw-r--r-- | gm/tinybitmap.cpp | 5 | ||||
-rw-r--r-- | gm/xfermodes.cpp | 11 |
14 files changed, 65 insertions, 69 deletions
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<SkShader> 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); } |