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

Side by Side Diff: gm/xfermodes2.cpp

Issue 1790353002: Revert of more shader-->sp conversions (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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/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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 SkPackARGB32(0xFF, 0xD6, 0xD3, 0xD6), 92 SkPackARGB32(0xFF, 0xD6, 0xD3, 0xD6),
93 SkPackARGB32(0xFF, 0xD6, 0xD3, 0xD6), 93 SkPackARGB32(0xFF, 0xD6, 0xD3, 0xD6),
94 SkPackARGB32(0xFF, 0x42, 0x41, 0x42) 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 = SkShader::MakeBitmapShader(bg, SkShader::kRepeat_TileMode, SkShade r::kRepeat_TileMode, 102 fBG.reset(SkShader::CreateBitmapShader(bg,
103 &lm); 103 SkShader::kRepeat_TileMode,
104 SkShader::kRepeat_TileMode,
105 &lm));
104 106
105 SkBitmap srcBmp; 107 SkBitmap srcBmp;
106 srcBmp.allocN32Pixels(kSize, kSize); 108 srcBmp.allocN32Pixels(kSize, kSize);
107 SkPMColor* pixels = reinterpret_cast<SkPMColor*>(srcBmp.getPixels()); 109 SkPMColor* pixels = reinterpret_cast<SkPMColor*>(srcBmp.getPixels());
108 110
109 for (int y = 0; y < kSize; ++y) { 111 for (int y = 0; y < kSize; ++y) {
110 int c = y * (1 << kShift); 112 int c = y * (1 << kShift);
111 SkPMColor rowColor = SkPackARGB32(c, c, 0, c/2); 113 SkPMColor rowColor = SkPackARGB32(c, c, 0, c/2);
112 for (int x = 0; x < kSize; ++x) { 114 for (int x = 0; x < kSize; ++x) {
113 pixels[kSize * y + x] = rowColor; 115 pixels[kSize * y + x] = rowColor;
114 } 116 }
115 } 117 }
116 fSrc = SkShader::MakeBitmapShader(srcBmp, SkShader::kClamp_TileMode, 118 fSrc.reset(SkShader::CreateBitmapShader(srcBmp,
117 SkShader::kClamp_TileMode); 119 SkShader::kClamp_TileMode,
120 SkShader::kClamp_TileMode));
118 SkBitmap dstBmp; 121 SkBitmap dstBmp;
119 dstBmp.allocN32Pixels(kSize, kSize); 122 dstBmp.allocN32Pixels(kSize, kSize);
120 pixels = reinterpret_cast<SkPMColor*>(dstBmp.getPixels()); 123 pixels = reinterpret_cast<SkPMColor*>(dstBmp.getPixels());
121 124
122 for (int x = 0; x < kSize; ++x) { 125 for (int x = 0; x < kSize; ++x) {
123 int c = x * (1 << kShift); 126 int c = x * (1 << kShift);
124 SkPMColor colColor = SkPackARGB32(c, 0, c, c/2); 127 SkPMColor colColor = SkPackARGB32(c, 0, c, c/2);
125 for (int y = 0; y < kSize; ++y) { 128 for (int y = 0; y < kSize; ++y) {
126 pixels[kSize * y + x] = colColor; 129 pixels[kSize * y + x] = colColor;
127 } 130 }
128 } 131 }
129 fDst = SkShader::MakeBitmapShader(dstBmp, SkShader::kClamp_TileMode, 132 fDst.reset(SkShader::CreateBitmapShader(dstBmp,
130 SkShader::kClamp_TileMode); 133 SkShader::kClamp_TileMode,
134 SkShader::kClamp_TileMode));
131 } 135 }
132 136
133 enum { 137 enum {
134 kShift = 2, 138 kShift = 2,
135 kSize = 256 >> kShift, 139 kSize = 256 >> kShift,
136 }; 140 };
137 141
138 sk_sp<SkShader> fBG; 142 SkAutoTUnref<SkShader> fBG;
139 sk_sp<SkShader> fSrc; 143 SkAutoTUnref<SkShader> fSrc;
140 sk_sp<SkShader> fDst; 144 SkAutoTUnref<SkShader> fDst;
141 145
142 typedef GM INHERITED; 146 typedef GM INHERITED;
143 }; 147 };
144 148
145 ////////////////////////////////////////////////////////////////////////////// 149 //////////////////////////////////////////////////////////////////////////////
146 150
147 static GM* MyFactory(void*) { return new Xfermodes2GM; } 151 static GM* MyFactory(void*) { return new Xfermodes2GM; }
148 static GMRegistry reg(MyFactory); 152 static GMRegistry reg(MyFactory);
149 153
150 } 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