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

Side by Side Diff: gm/bitmapfilters.cpp

Issue 340533002: hide SkBitmap::Config entirely (behind a flag) (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | gyp/SampleApp.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1
2 /* 1 /*
3 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
4 * 3 *
5 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 5 * found in the LICENSE file.
7 */ 6 */
7
8 #include "gm.h" 8 #include "gm.h"
9 #include "sk_tool_utils.h"
9 10
10 namespace skiagm { 11 namespace skiagm {
11 12
12 static void make_bm(SkBitmap* bm) { 13 static void make_bm(SkBitmap* bm) {
13 const SkColor colors[4] = { 14 const SkColor colors[4] = {
14 SK_ColorRED, SK_ColorGREEN, 15 SK_ColorRED, SK_ColorGREEN,
15 SK_ColorBLUE, SK_ColorWHITE 16 SK_ColorBLUE, SK_ColorWHITE
16 }; 17 };
17 SkPMColor colorsPM[4]; 18 SkPMColor colorsPM[4];
18 for (size_t i = 0; i < SK_ARRAY_COUNT(colors); ++i) { 19 for (size_t i = 0; i < SK_ARRAY_COUNT(colors); ++i) {
(...skipping 20 matching lines...) Expand all
39 40
40 static SkScalar draw_set(SkCanvas* c, const SkBitmap& bm, SkScalar x, 41 static SkScalar draw_set(SkCanvas* c, const SkBitmap& bm, SkScalar x,
41 SkPaint* p) { 42 SkPaint* p) {
42 x += draw_bm(c, bm, x, 0, p); 43 x += draw_bm(c, bm, x, 0, p);
43 p->setFilterLevel(SkPaint::kLow_FilterLevel); 44 p->setFilterLevel(SkPaint::kLow_FilterLevel);
44 x += draw_bm(c, bm, x, 0, p); 45 x += draw_bm(c, bm, x, 0, p);
45 p->setDither(true); 46 p->setDither(true);
46 return x + draw_bm(c, bm, x, 0, p); 47 return x + draw_bm(c, bm, x, 0, p);
47 } 48 }
48 49
49 static const char* gConfigNames[] = {
50 "unknown config",
51 "A8",
52 "Index8",
53 "565",
54 "4444",
55 "8888"
56 };
57
58 static SkScalar draw_row(SkCanvas* canvas, const SkBitmap& bm) { 50 static SkScalar draw_row(SkCanvas* canvas, const SkBitmap& bm) {
59 SkAutoCanvasRestore acr(canvas, true); 51 SkAutoCanvasRestore acr(canvas, true);
60 52
61 SkPaint paint; 53 SkPaint paint;
62 SkScalar x = 0; 54 SkScalar x = 0;
63 const int scale = 32; 55 const int scale = 32;
64 56
65 paint.setAntiAlias(true); 57 paint.setAntiAlias(true);
66 const char* name = gConfigNames[bm.config()]; 58 const char* name = sk_tool_utils::colortype_name(bm.colorType());
67 canvas->drawText(name, strlen(name), x, SkIntToScalar(bm.height())*scale*5/8 , 59 canvas->drawText(name, strlen(name), x, SkIntToScalar(bm.height())*scale*5/8 ,
68 paint); 60 paint);
69 canvas->translate(SkIntToScalar(48), 0); 61 canvas->translate(SkIntToScalar(48), 0);
70 62
71 canvas->scale(SkIntToScalar(scale), SkIntToScalar(scale)); 63 canvas->scale(SkIntToScalar(scale), SkIntToScalar(scale));
72 64
73 x += draw_set(canvas, bm, 0, &paint); 65 x += draw_set(canvas, bm, 0, &paint);
74 paint.reset(); 66 paint.reset();
75 paint.setAlpha(0x80); 67 paint.setAlpha(0x80);
76 draw_set(canvas, bm, x, &paint); 68 draw_set(canvas, bm, x, &paint);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 private: 116 private:
125 typedef GM INHERITED; 117 typedef GM INHERITED;
126 }; 118 };
127 119
128 ////////////////////////////////////////////////////////////////////////////// 120 //////////////////////////////////////////////////////////////////////////////
129 121
130 static GM* MyFactory(void*) { return new FilterGM; } 122 static GM* MyFactory(void*) { return new FilterGM; }
131 static GMRegistry reg(MyFactory); 123 static GMRegistry reg(MyFactory);
132 124
133 } 125 }
OLDNEW
« no previous file with comments | « no previous file | gyp/SampleApp.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698