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

Side by Side Diff: src/core/SkShader.cpp

Issue 245963010: Move SkShader::fLocalMatrix into SkShader constructor. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: nit Created 6 years, 7 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 | « src/core/SkPictureShader.cpp ('k') | src/core/SkSmallAllocator.h » ('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 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
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 "SkBitmapProcShader.h" 8 #include "SkBitmapProcShader.h"
9 #include "SkReadBuffer.h" 9 #include "SkReadBuffer.h"
10 #include "SkMallocPixelRef.h" 10 #include "SkMallocPixelRef.h"
11 #include "SkPaint.h" 11 #include "SkPaint.h"
12 #include "SkPicture.h" 12 #include "SkPicture.h"
13 #include "SkPictureShader.h" 13 #include "SkPictureShader.h"
14 #include "SkScalar.h" 14 #include "SkScalar.h"
15 #include "SkShader.h" 15 #include "SkShader.h"
16 #include "SkWriteBuffer.h" 16 #include "SkWriteBuffer.h"
17 17
18 SkShader::SkShader() { 18 SkShader::SkShader(const SkMatrix* localMatrix) {
19 fLocalMatrix.reset(); 19 if (localMatrix) {
20 fLocalMatrix = *localMatrix;
21 } else {
22 fLocalMatrix.reset();
23 }
20 } 24 }
21 25
22 SkShader::SkShader(SkReadBuffer& buffer) 26 SkShader::SkShader(SkReadBuffer& buffer)
23 : INHERITED(buffer) { 27 : INHERITED(buffer) {
24 if (buffer.readBool()) { 28 if (buffer.readBool()) {
25 buffer.readMatrix(&fLocalMatrix); 29 buffer.readMatrix(&fLocalMatrix);
26 } else { 30 } else {
27 fLocalMatrix.reset(); 31 fLocalMatrix.reset();
28 } 32 }
29 } 33 }
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 } 177 }
174 178
175 SkShader::GradientType SkShader::asAGradient(GradientInfo* info) const { 179 SkShader::GradientType SkShader::asAGradient(GradientInfo* info) const {
176 return kNone_GradientType; 180 return kNone_GradientType;
177 } 181 }
178 182
179 GrEffectRef* SkShader::asNewEffect(GrContext*, const SkPaint&) const { 183 GrEffectRef* SkShader::asNewEffect(GrContext*, const SkPaint&) const {
180 return NULL; 184 return NULL;
181 } 185 }
182 186
183 SkShader* SkShader::CreateBitmapShader(const SkBitmap& src, 187 SkShader* SkShader::CreateBitmapShader(const SkBitmap& src, TileMode tmx, TileMo de tmy,
184 TileMode tmx, TileMode tmy) { 188 const SkMatrix* localMatrix) {
185 return ::CreateBitmapShader(src, tmx, tmy, NULL); 189 return ::CreateBitmapShader(src, tmx, tmy, localMatrix, NULL);
186 } 190 }
187 191
188 SkShader* SkShader::CreatePictureShader(SkPicture* src, TileMode tmx, TileMode t my) { 192 SkShader* SkShader::CreatePictureShader(SkPicture* src, TileMode tmx, TileMode t my) {
189 return SkPictureShader::Create(src, tmx, tmy); 193 return SkPictureShader::Create(src, tmx, tmy);
190 } 194 }
191 195
192 #ifndef SK_IGNORE_TO_STRING 196 #ifndef SK_IGNORE_TO_STRING
193 void SkShader::toString(SkString* str) const { 197 void SkShader::toString(SkString* str) const {
194 if (this->hasLocalMatrix()) { 198 if (this->hasLocalMatrix()) {
195 str->append(" "); 199 str->append(" ");
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 249
246 return SkNEW_PLACEMENT_ARGS(storage, ColorShaderContext, (*this, device, pai nt, matrix)); 250 return SkNEW_PLACEMENT_ARGS(storage, ColorShaderContext, (*this, device, pai nt, matrix));
247 } 251 }
248 252
249 SkColorShader::ColorShaderContext::ColorShaderContext(const SkColorShader& shade r, 253 SkColorShader::ColorShaderContext::ColorShaderContext(const SkColorShader& shade r,
250 const SkBitmap& device, 254 const SkBitmap& device,
251 const SkPaint& paint, 255 const SkPaint& paint,
252 const SkMatrix& matrix) 256 const SkMatrix& matrix)
253 : INHERITED(shader, device, paint, matrix) 257 : INHERITED(shader, device, paint, matrix)
254 { 258 {
255 SkColor color; 259 SkColor color = shader.fColor;
256 unsigned a; 260 unsigned a = SkAlphaMul(SkColorGetA(color), SkAlpha255To256(paint.getAlpha() ));
257
258 color = shader.fColor;
259 a = SkAlphaMul(SkColorGetA(color), SkAlpha255To256(paint.getAlpha()));
260 261
261 unsigned r = SkColorGetR(color); 262 unsigned r = SkColorGetR(color);
262 unsigned g = SkColorGetG(color); 263 unsigned g = SkColorGetG(color);
263 unsigned b = SkColorGetB(color); 264 unsigned b = SkColorGetB(color);
264 265
265 // we want this before we apply any alpha 266 // we want this before we apply any alpha
266 fColor16 = SkPack888ToRGB16(r, g, b); 267 fColor16 = SkPack888ToRGB16(r, g, b);
267 268
268 if (a != 255) { 269 if (a != 255) {
269 r = SkMulDiv255Round(r, a); 270 r = SkMulDiv255Round(r, a);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 #include "SkEmptyShader.h" 330 #include "SkEmptyShader.h"
330 331
331 void SkEmptyShader::toString(SkString* str) const { 332 void SkEmptyShader::toString(SkString* str) const {
332 str->append("SkEmptyShader: ("); 333 str->append("SkEmptyShader: (");
333 334
334 this->INHERITED::toString(str); 335 this->INHERITED::toString(str);
335 336
336 str->append(")"); 337 str->append(")");
337 } 338 }
338 #endif 339 #endif
OLDNEW
« no previous file with comments | « src/core/SkPictureShader.cpp ('k') | src/core/SkSmallAllocator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698