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

Side by Side Diff: gm/glyph_pos_align.cpp

Issue 1776973003: partial switch over to sp usage of shaders (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: move into lua container Created 4 years, 9 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/giantbitmap.cpp ('k') | src/utils/SkLua.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 2014 Google Inc. 2 * Copyright 2014 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 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkGradientShader.h" 10 #include "SkGradientShader.h"
11 11
12 /** 12 /**
13 * This test exercises drawPosTextH and drawPosText with every text align. 13 * This test exercises drawPosTextH and drawPosText with every text align.
14 */ 14 */
15 static const int kWidth = 480; 15 static const int kWidth = 480;
16 static const int kHeight = 600; 16 static const int kHeight = 600;
17 static const SkScalar kTextHeight = 64.0f; 17 static const SkScalar kTextHeight = 64.0f;
18 static const int kMaxStringLength = 12; 18 static const int kMaxStringLength = 12;
19 19
20 static void drawTestCase(SkCanvas*, const char*, SkScalar, const SkPaint&); 20 static void drawTestCase(SkCanvas*, const char*, SkScalar, const SkPaint&);
21 21
22 DEF_SIMPLE_GM_BG(glyph_pos_align, canvas, kWidth, kHeight, SK_ColorBLACK) { 22 DEF_SIMPLE_GM_BG(glyph_pos_align, canvas, kWidth, kHeight, SK_ColorBLACK) {
23 SkPaint paint; 23 SkPaint paint;
24 paint.setTextSize(kTextHeight); 24 paint.setTextSize(kTextHeight);
25 paint.setFakeBoldText(true); 25 paint.setFakeBoldText(true);
26 const SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE }; 26 const SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE };
27 const SkPoint pts[] = {{0, 0}, {kWidth, kHeight}}; 27 const SkPoint pts[] = {{0, 0}, {kWidth, kHeight}};
28 SkAutoTUnref<SkShader> grad(SkGradientShader::CreateLinear(pts, colors, nullptr, 28 paint.setShader(SkGradientShader::MakeLinear(pts, colors, nullptr, SK_AR RAY_COUNT(colors),
29 SK_ARRAY_COUN T(colors), 29 SkShader::kMirror_TileMode) );
30 SkShader::kMi rror_TileMode));
31 paint.setShader(grad);
32
33
34 paint.setTextAlign(SkPaint::kRight_Align); 30 paint.setTextAlign(SkPaint::kRight_Align);
35 drawTestCase(canvas, "Right Align", kTextHeight, paint); 31 drawTestCase(canvas, "Right Align", kTextHeight, paint);
36 32
37 paint.setTextAlign(SkPaint::kCenter_Align); 33 paint.setTextAlign(SkPaint::kCenter_Align);
38 drawTestCase(canvas, "Center Align", 4 * kTextHeight, paint); 34 drawTestCase(canvas, "Center Align", 4 * kTextHeight, paint);
39 35
40 paint.setTextAlign(SkPaint::kLeft_Align); 36 paint.setTextAlign(SkPaint::kLeft_Align);
41 drawTestCase(canvas, "Left Align", 7 * kTextHeight, paint); 37 drawTestCase(canvas, "Left Align", 7 * kTextHeight, paint);
42 } 38 }
43 39
(...skipping 17 matching lines...) Expand all
61 float x = kTextHeight; 57 float x = kTextHeight;
62 for (int i = 0; i < length; ++i) { 58 for (int i = 0; i < length; ++i) {
63 posX[i] = x + originX * widths[i]; 59 posX[i] = x + originX * widths[i];
64 pos[i].set(posX[i], i ? pos[i - 1].y() + 3 : y + kTextHeight); 60 pos[i].set(posX[i], i ? pos[i - 1].y() + 3 : y + kTextHeight);
65 x += widths[i]; 61 x += widths[i];
66 } 62 }
67 63
68 canvas->drawPosTextH(text, length, posX, y, paint); 64 canvas->drawPosTextH(text, length, posX, y, paint);
69 canvas->drawPosText(text, length, pos, paint); 65 canvas->drawPosText(text, length, pos, paint);
70 } 66 }
OLDNEW
« no previous file with comments | « gm/giantbitmap.cpp ('k') | src/utils/SkLua.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698