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

Side by Side Diff: gm/pixelsnap.cpp

Issue 1263553002: make pixelsnap textblob* etc gm portable (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add more 565 compatibility Created 5 years, 4 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/pictureshader.cpp ('k') | gm/poly2poly.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 2015 Google Inc. 2 * Copyright 2015 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 "SkShader.h" 10 #include "SkShader.h"
(...skipping 17 matching lines...) Expand all
28 static const int kLabelOffsetY = kLabelTextSize + kLabelPad; 28 static const int kLabelOffsetY = kLabelTextSize + kLabelPad;
29 29
30 SkISize onISize() override { 30 SkISize onISize() override {
31 return SkISize::Make((kSubPixelSteps + 1) * kTrans + kLabelOffsetX + kLa belPad, 31 return SkISize::Make((kSubPixelSteps + 1) * kTrans + kLabelOffsetX + kLa belPad,
32 (kSubPixelSteps + 1) * kTrans + kLabelOffsetY + kLa belPad); 32 (kSubPixelSteps + 1) * kTrans + kLabelOffsetY + kLa belPad);
33 } 33 }
34 34
35 void onDraw(SkCanvas* canvas) override { 35 void onDraw(SkCanvas* canvas) override {
36 SkPaint bgPaint; 36 SkPaint bgPaint;
37 bgPaint.setShader( 37 bgPaint.setShader(
38 sk_tool_utils::create_checkerboard_shader(0xFFAAAAAA, 0xFF777777, 1) )->unref(); 38 sk_tool_utils::create_checkerboard_shader(
39 sk_tool_utils::color_to_565(0xFFAAAAAA),
40 sk_tool_utils::color_to_565(0xFF777777), 1))->unref();
39 canvas->drawPaint(bgPaint); 41 canvas->drawPaint(bgPaint);
40 42
41 SkString offset; 43 SkString offset;
42 SkPaint labelPaint; 44 SkPaint labelPaint;
43 labelPaint.setAntiAlias(true); 45 labelPaint.setAntiAlias(true);
44 labelPaint.setColor(SK_ColorWHITE); 46 labelPaint.setColor(SK_ColorWHITE);
45 labelPaint.setTextSize(SkIntToScalar(kLabelTextSize)); 47 labelPaint.setTextSize(SkIntToScalar(kLabelTextSize));
48 sk_tool_utils::set_portable_typeface(&labelPaint);
46 SkPaint linePaint; 49 SkPaint linePaint;
47 linePaint.setColor(SK_ColorWHITE); 50 linePaint.setColor(SK_ColorWHITE);
48 51
49 // Drawing labels is useful for debugging, but bad for baselining (x-pla tform txt diffs). 52 // Draw row labels
50 if (false) { 53 canvas->save();
51 // Draw row labels 54 canvas->translate(0, SkIntToScalar(kLabelOffsetY));
52 canvas->save(); 55 for (int i = 0; i <= kSubPixelSteps; ++i) {
53 canvas->translate(0, SkIntToScalar(kLabelOffsetY)); 56 offset.printf("%d", i);
54 for (int i = 0; i <= kSubPixelSteps; ++i) { 57 canvas->drawText(offset.c_str(), offset.size(),
55 offset.printf("%d", i); 58 0, i * kTrans + labelPaint.getTextSize(),
56 canvas->drawText(offset.c_str(), offset.size(), 59 labelPaint);
57 0, i * kTrans + labelPaint.getTextSize(), 60 }
58 labelPaint); 61 canvas->restore();
59 }
60 canvas->restore();
61 62
62 // Draw col labels 63 // Draw col labels
63 canvas->save(); 64 canvas->save();
64 canvas->translate(SkIntToScalar(kLabelOffsetX), 0); 65 canvas->translate(SkIntToScalar(kLabelOffsetX), 0);
65 for (int i = 0; i <= kSubPixelSteps; ++i) { 66 for (int i = 0; i <= kSubPixelSteps; ++i) {
66 offset.printf("%d", i); 67 offset.printf("%d", i);
67 canvas->drawText(offset.c_str(), offset.size(), 68 canvas->drawText(offset.c_str(), offset.size(),
68 i * SkIntToScalar(kTrans), labelPaint.getTe xtSize(), 69 i * SkIntToScalar(kTrans), labelPaint.getTex tSize(),
69 labelPaint); 70 labelPaint);
70 } 71 }
71 canvas->restore(); 72 canvas->restore();
72 }
73 73
74 canvas->translate(SkIntToScalar(kLabelOffsetX), SkIntToScalar(kLabelOffs etY)); 74 canvas->translate(SkIntToScalar(kLabelOffsetX), SkIntToScalar(kLabelOffs etY));
75 75
76 // Draw test case grid lines (Draw them all at pixel centers to hopefull y avoid any 76 // Draw test case grid lines (Draw them all at pixel centers to hopefull y avoid any
77 // snapping issues). 77 // snapping issues).
78 for (int i = 0; i <= kSubPixelSteps + 1; ++i) { 78 for (int i = 0; i <= kSubPixelSteps + 1; ++i) {
79 canvas->drawLine(0.5f, 79 canvas->drawLine(0.5f,
80 i * SkIntToScalar(kTrans) + 0.5f, 80 i * SkIntToScalar(kTrans) + 0.5f,
81 SkIntToScalar(kTrans) * (kSubPixelSteps + 1) + 0.5f , 81 SkIntToScalar(kTrans) * (kSubPixelSteps + 1) + 0.5f ,
82 i * SkIntToScalar(kTrans) + 0.5f, 82 i * SkIntToScalar(kTrans) + 0.5f,
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 172
173 private: 173 private:
174 typedef PixelSnapGM INHERITED; 174 typedef PixelSnapGM INHERITED;
175 }; 175 };
176 176
177 ////////////////////////////////////////////////////////////////////////////// 177 //////////////////////////////////////////////////////////////////////////////
178 DEF_GM( return SkNEW(PointSnapGM); ) 178 DEF_GM( return SkNEW(PointSnapGM); )
179 DEF_GM( return SkNEW(LineSnapGM); ) 179 DEF_GM( return SkNEW(LineSnapGM); )
180 DEF_GM( return SkNEW(RectSnapGM); ) 180 DEF_GM( return SkNEW(RectSnapGM); )
181 DEF_GM( return SkNEW(ComboSnapGM); ) 181 DEF_GM( return SkNEW(ComboSnapGM); )
OLDNEW
« no previous file with comments | « gm/pictureshader.cpp ('k') | gm/poly2poly.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698