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

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: uncomment setLocalMatrix Created 6 years, 8 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
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(" ");
196 this->getLocalMatrix().toString(str); 200 this->getLocalMatrix().toString(str);
197 } 201 }
198 } 202 }
199 #endif 203 #endif
200 204
201 ////////////////////////////////////////////////////////////////////////////// 205 //////////////////////////////////////////////////////////////////////////////
202 206
203 #include "SkColorShader.h" 207 #include "SkColorShader.h"
204 #include "SkUtils.h" 208 #include "SkUtils.h"
205 209
206 SkColorShader::SkColorShader() 210 SkColorShader::SkColorShader(const SkMatrix* localMatrix)
207 : fColor() 211 : INHERITED(localMatrix)
212 , fColor()
208 , fInheritColor(true) { 213 , fInheritColor(true) {
209 } 214 }
210 215
211 SkColorShader::SkColorShader(SkColor c) 216 SkColorShader::SkColorShader(SkColor c, const SkMatrix* localMatrix)
212 : fColor(c) 217 : INHERITED(localMatrix)
218 , fColor(c)
213 , fInheritColor(false) { 219 , fInheritColor(false) {
214 } 220 }
215 221
216 bool SkColorShader::isOpaque() const { 222 bool SkColorShader::isOpaque() const {
217 if (fInheritColor) { 223 if (fInheritColor) {
218 return true; // using paint's alpha 224 return true; // using paint's alpha
219 } 225 }
220 return SkColorGetA(fColor) == 255; 226 return SkColorGetA(fColor) == 255;
221 } 227 }
222 228
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 #include "SkEmptyShader.h" 352 #include "SkEmptyShader.h"
347 353
348 void SkEmptyShader::toString(SkString* str) const { 354 void SkEmptyShader::toString(SkString* str) const {
349 str->append("SkEmptyShader: ("); 355 str->append("SkEmptyShader: (");
350 356
351 this->INHERITED::toString(str); 357 this->INHERITED::toString(str);
352 358
353 str->append(")"); 359 str->append(")");
354 } 360 }
355 #endif 361 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698