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

Side by Side Diff: gm/filterbitmap.cpp

Issue 1184123002: Revert of make gm background colors 565 compatible (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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 | « gm/filltypes.cpp ('k') | gm/filterfastbounds.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * 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
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "gm.h" 8 #include "gm.h"
9 9
10 #include "Resources.h" 10 #include "Resources.h"
11 #include "SkGradientShader.h" 11 #include "SkGradientShader.h"
12 #include "SkImageDecoder.h" 12 #include "SkImageDecoder.h"
13 #include "SkStream.h" 13 #include "SkStream.h"
14 #include "SkTypeface.h" 14 #include "SkTypeface.h"
15 15
16 static void setTypeface(SkPaint* paint, const char name[], SkTypeface::Style sty le) { 16 static void setTypeface(SkPaint* paint, const char name[], SkTypeface::Style sty le) {
17 sk_tool_utils::set_portable_typeface_always(paint, name, style); 17 sk_tool_utils::set_portable_typeface(paint, name, style);
18 } 18 }
19 19
20 static SkSize computeSize(const SkBitmap& bm, const SkMatrix& mat) { 20 static SkSize computeSize(const SkBitmap& bm, const SkMatrix& mat) {
21 SkRect bounds = SkRect::MakeWH(SkIntToScalar(bm.width()), 21 SkRect bounds = SkRect::MakeWH(SkIntToScalar(bm.width()),
22 SkIntToScalar(bm.height())); 22 SkIntToScalar(bm.height()));
23 mat.mapRect(&bounds); 23 mat.mapRect(&bounds);
24 return SkSize::Make(bounds.width(), bounds.height()); 24 return SkSize::Make(bounds.width(), bounds.height());
25 } 25 }
26 26
27 static void draw_cell(SkCanvas* canvas, const SkBitmap& bm, const SkMatrix& mat, SkScalar dx, 27 static void draw_cell(SkCanvas* canvas, const SkBitmap& bm, const SkMatrix& mat, SkScalar dx,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 fMatrix[2].setScale(0.7f, 1.05f); 59 fMatrix[2].setScale(0.7f, 1.05f);
60 } 60 }
61 61
62 public: 62 public:
63 SkBitmap fBM; 63 SkBitmap fBM;
64 SkMatrix fMatrix[3]; 64 SkMatrix fMatrix[3];
65 SkString fName; 65 SkString fName;
66 66
67 FilterBitmapGM() 67 FilterBitmapGM()
68 { 68 {
69 this->setBGColor(sk_tool_utils::color_to_565(0xFFDDDDDD)); 69 this->setBGColor(0xFFDDDDDD);
70 } 70 }
71 71
72 protected: 72 protected:
73 73
74 SkString onShortName() override { 74 SkString onShortName() override {
75 return fName; 75 return fName;
76 } 76 }
77 77
78 SkISize onISize() override { 78 SkISize onISize() override {
79 return SkISize::Make(1024, 768); 79 return SkISize::Make(1024, 768);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 void makeBitmap() override { 117 void makeBitmap() override {
118 fBM.allocN32Pixels(int(fTextSize * 8), int(fTextSize * 6)); 118 fBM.allocN32Pixels(int(fTextSize * 8), int(fTextSize * 6));
119 SkCanvas canvas(fBM); 119 SkCanvas canvas(fBM);
120 canvas.drawColor(SK_ColorWHITE); 120 canvas.drawColor(SK_ColorWHITE);
121 121
122 SkPaint paint; 122 SkPaint paint;
123 paint.setAntiAlias(true); 123 paint.setAntiAlias(true);
124 paint.setSubpixelText(true); 124 paint.setSubpixelText(true);
125 paint.setTextSize(fTextSize); 125 paint.setTextSize(fTextSize);
126 126
127 setTypeface(&paint, "serif", SkTypeface::kNormal); 127 setTypeface(&paint, "Times", SkTypeface::kNormal);
128 canvas.drawText("Hamburgefons", 12, fTextSize/2, 1.2f*fTextSize, paint ); 128 canvas.drawText("Hamburgefons", 12, fTextSize/2, 1.2f*fTextSize, paint );
129 setTypeface(&paint, "serif", SkTypeface::kBold); 129 setTypeface(&paint, "Times", SkTypeface::kBold);
130 canvas.drawText("Hamburgefons", 12, fTextSize/2, 2.4f*fTextSize, paint ); 130 canvas.drawText("Hamburgefons", 12, fTextSize/2, 2.4f*fTextSize, paint );
131 setTypeface(&paint, "serif", SkTypeface::kItalic); 131 setTypeface(&paint, "Times", SkTypeface::kItalic);
132 canvas.drawText("Hamburgefons", 12, fTextSize/2, 3.6f*fTextSize, paint ); 132 canvas.drawText("Hamburgefons", 12, fTextSize/2, 3.6f*fTextSize, paint );
133 setTypeface(&paint, "serif", SkTypeface::kBoldItalic); 133 setTypeface(&paint, "Times", SkTypeface::kBoldItalic);
134 canvas.drawText("Hamburgefons", 12, fTextSize/2, 4.8f*fTextSize, paint ); 134 canvas.drawText("Hamburgefons", 12, fTextSize/2, 4.8f*fTextSize, paint );
135 } 135 }
136 private: 136 private:
137 typedef FilterBitmapGM INHERITED; 137 typedef FilterBitmapGM INHERITED;
138 }; 138 };
139 139
140 class FilterBitmapCheckerboardGM: public FilterBitmapGM { 140 class FilterBitmapCheckerboardGM: public FilterBitmapGM {
141 public: 141 public:
142 FilterBitmapCheckerboardGM(int size, int num_checks, bool convertToG8 = fals e) 142 FilterBitmapCheckerboardGM(int size, int num_checks, bool convertToG8 = fals e)
143 : fSize(size), fNumChecks(num_checks), fConvertToG8(convertToG8) 143 : fSize(size), fNumChecks(num_checks), fConvertToG8(convertToG8)
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 DEF_GM( return new FilterBitmapCheckerboardGM(32,2); ) 234 DEF_GM( return new FilterBitmapCheckerboardGM(32,2); )
235 DEF_GM( return new FilterBitmapCheckerboardGM(192,192); ) 235 DEF_GM( return new FilterBitmapCheckerboardGM(192,192); )
236 DEF_GM( return new FilterBitmapImageGM("mandrill_16.png"); ) 236 DEF_GM( return new FilterBitmapImageGM("mandrill_16.png"); )
237 DEF_GM( return new FilterBitmapImageGM("mandrill_32.png"); ) 237 DEF_GM( return new FilterBitmapImageGM("mandrill_32.png"); )
238 DEF_GM( return new FilterBitmapImageGM("mandrill_64.png"); ) 238 DEF_GM( return new FilterBitmapImageGM("mandrill_64.png"); )
239 DEF_GM( return new FilterBitmapImageGM("mandrill_64.png", true); ) 239 DEF_GM( return new FilterBitmapImageGM("mandrill_64.png", true); )
240 DEF_GM( return new FilterBitmapImageGM("mandrill_128.png"); ) 240 DEF_GM( return new FilterBitmapImageGM("mandrill_128.png"); )
241 DEF_GM( return new FilterBitmapImageGM("mandrill_256.png"); ) 241 DEF_GM( return new FilterBitmapImageGM("mandrill_256.png"); )
242 DEF_GM( return new FilterBitmapImageGM("mandrill_512.png"); ) 242 DEF_GM( return new FilterBitmapImageGM("mandrill_512.png"); )
243 DEF_GM( return new FilterBitmapImageGM("color_wheel.png"); ) 243 DEF_GM( return new FilterBitmapImageGM("color_wheel.png"); )
OLDNEW
« no previous file with comments | « gm/filltypes.cpp ('k') | gm/filterfastbounds.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698