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

Side by Side Diff: gm/xfermodes2.cpp

Issue 1243103002: make xfermode* portable (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 5 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/xfermodes.cpp ('k') | gm/xfermodes3.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 /* 2 /*
3 * Copyright 2013 Google Inc. 3 * Copyright 2013 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "gm.h" 8 #include "gm.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkShader.h" 10 #include "SkShader.h"
(...skipping 16 matching lines...) Expand all
27 } 27 }
28 28
29 void onDraw(SkCanvas* canvas) override { 29 void onDraw(SkCanvas* canvas) override {
30 canvas->translate(SkIntToScalar(10), SkIntToScalar(20)); 30 canvas->translate(SkIntToScalar(10), SkIntToScalar(20));
31 31
32 const SkScalar w = SkIntToScalar(kSize); 32 const SkScalar w = SkIntToScalar(kSize);
33 const SkScalar h = SkIntToScalar(kSize); 33 const SkScalar h = SkIntToScalar(kSize);
34 34
35 SkPaint labelP; 35 SkPaint labelP;
36 labelP.setAntiAlias(true); 36 labelP.setAntiAlias(true);
37 sk_tool_utils::set_portable_typeface(&labelP); 37 sk_tool_utils::set_portable_typeface_always(&labelP);
38 labelP.setTextAlign(SkPaint::kCenter_Align); 38 labelP.setTextAlign(SkPaint::kCenter_Align);
39 39
40 const int W = 6; 40 const int W = 6;
41 41
42 SkScalar x = 0, y = 0; 42 SkScalar x = 0, y = 0;
43 for (size_t m = 0; m <= SkXfermode::kLastMode; m++) { 43 for (size_t m = 0; m <= SkXfermode::kLastMode; m++) {
44 SkXfermode::Mode mode = static_cast<SkXfermode::Mode>(m); 44 SkXfermode::Mode mode = static_cast<SkXfermode::Mode>(m);
45 SkXfermode* xm = SkXfermode::Create(mode); 45 SkXfermode* xm = SkXfermode::Create(mode);
46 SkAutoUnref aur(xm); 46 SkAutoUnref aur(xm);
47 47
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 if ((m % W) == W - 1) { 81 if ((m % W) == W - 1) {
82 x = 0; 82 x = 0;
83 y += h + SkIntToScalar(30); 83 y += h + SkIntToScalar(30);
84 } 84 }
85 } 85 }
86 } 86 }
87 87
88 private: 88 private:
89 void onOnceBeforeDraw() override { 89 void onOnceBeforeDraw() override {
90 static const uint32_t kCheckData[] = { 90 static const uint32_t kCheckData[] = {
91 SkPackARGB32(0xFF, 0x40, 0x40, 0x40), 91 SkPackARGB32(0xFF, 0x42, 0x41, 0x42),
92 SkPackARGB32(0xFF, 0xD0, 0xD0, 0xD0), 92 SkPackARGB32(0xFF, 0xD6, 0xD3, 0xD6),
93 SkPackARGB32(0xFF, 0xD0, 0xD0, 0xD0), 93 SkPackARGB32(0xFF, 0xD6, 0xD3, 0xD6),
94 SkPackARGB32(0xFF, 0x40, 0x40, 0x40) 94 SkPackARGB32(0xFF, 0x42, 0x41, 0x42)
95 }; 95 };
96 SkBitmap bg; 96 SkBitmap bg;
97 bg.allocN32Pixels(2, 2, true); 97 bg.allocN32Pixels(2, 2, true);
98 memcpy(bg.getPixels(), kCheckData, sizeof(kCheckData)); 98 memcpy(bg.getPixels(), kCheckData, sizeof(kCheckData));
99 99
100 SkMatrix lm; 100 SkMatrix lm;
101 lm.setScale(SkIntToScalar(16), SkIntToScalar(16)); 101 lm.setScale(SkIntToScalar(16), SkIntToScalar(16));
102 fBG.reset(SkShader::CreateBitmapShader(bg, 102 fBG.reset(SkShader::CreateBitmapShader(bg,
103 SkShader::kRepeat_TileMode, 103 SkShader::kRepeat_TileMode,
104 SkShader::kRepeat_TileMode, 104 SkShader::kRepeat_TileMode,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 145
146 typedef GM INHERITED; 146 typedef GM INHERITED;
147 }; 147 };
148 148
149 ////////////////////////////////////////////////////////////////////////////// 149 //////////////////////////////////////////////////////////////////////////////
150 150
151 static GM* MyFactory(void*) { return new Xfermodes2GM; } 151 static GM* MyFactory(void*) { return new Xfermodes2GM; }
152 static GMRegistry reg(MyFactory); 152 static GMRegistry reg(MyFactory);
153 153
154 } 154 }
OLDNEW
« no previous file with comments | « gm/xfermodes.cpp ('k') | gm/xfermodes3.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698