Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Unified Diff: samplecode/SampleFilter.cpp

Issue 169063002: use SkColorType instead of SkBitmap::Config in samplecode (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « samplecode/SampleFatBits.cpp ('k') | samplecode/SampleFilter2.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samplecode/SampleFilter.cpp
diff --git a/samplecode/SampleFilter.cpp b/samplecode/SampleFilter.cpp
index 7f902d5b2e9390b64b2721fac72729927ad26511..1b26bf246341bf66f6975f834ca60883bffdd152 100644
--- a/samplecode/SampleFilter.cpp
+++ b/samplecode/SampleFilter.cpp
@@ -22,13 +22,14 @@
#include "SkDither.h"
static void make_bm(SkBitmap* bm) {
- const SkColor colors[] = {
- SK_ColorRED, SK_ColorGREEN,
- SK_ColorBLUE, SK_ColorWHITE
+ const SkPMColor colors[] = {
+ SkPreMultiplyColor(SK_ColorRED), SkPreMultiplyColor(SK_ColorGREEN),
+ SkPreMultiplyColor(SK_ColorBLUE), SkPreMultiplyColor(SK_ColorWHITE)
};
SkColorTable* ctable = new SkColorTable(colors, 4);
- bm->setConfig(SkBitmap::kIndex8_Config, 2, 2);
- bm->allocPixels(ctable);
+ bm->allocPixels(SkImageInfo::Make(2, 2, kIndex_8_SkColorType,
+ kOpaque_SkAlphaType),
+ NULL, ctable);
ctable->unref();
*bm->getAddr8(0, 0) = 0;
@@ -39,22 +40,8 @@ static void make_bm(SkBitmap* bm) {
static SkScalar draw_bm(SkCanvas* canvas, const SkBitmap& bm,
SkScalar x, SkScalar y, SkPaint* paint) {
-#if 1
canvas->drawBitmap(bm, x, y, paint);
return SkIntToScalar(bm.width()) * 5/4;
-#else
- SkAutoCanvasRestore acr(canvas, true);
- canvas->translate(x, y);
-
- SkScalar w = SkIntToScalar(bm.width());
- SkScalar h = SkIntToScalar(bm.height());
- SkShader* s = SkShader::CreateBitmapShader(bm, SkShader::kRepeat_TileMode,
- SkShader::kRepeat_TileMode);
- paint->setShader(s)->unref();
- canvas->drawRect(SkRect::MakeWH(w, h), *paint);
- paint->setShader(NULL);
- return w * 5/4;
-#endif
}
static SkScalar draw_set(SkCanvas* c, const SkBitmap& bm, SkScalar x, SkPaint* p) {
« no previous file with comments | « samplecode/SampleFatBits.cpp ('k') | samplecode/SampleFilter2.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698