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

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

Issue 279563002: hide get/setLocalMatrix (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: 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 | Annotate | Revision Log
« no previous file with comments | « src/core/SkPictureShader.cpp ('k') | src/effects/SkRectShaderImageFilter.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 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 "SkEmptyShader.h" 9 #include "SkEmptyShader.h"
10 #include "SkReadBuffer.h" 10 #include "SkReadBuffer.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 fLocalMatrix.reset(); 53 fLocalMatrix.reset();
54 } 54 }
55 } 55 }
56 56
57 SkShader::~SkShader() { 57 SkShader::~SkShader() {
58 dec_shader_counter(); 58 dec_shader_counter();
59 } 59 }
60 60
61 void SkShader::flatten(SkWriteBuffer& buffer) const { 61 void SkShader::flatten(SkWriteBuffer& buffer) const {
62 this->INHERITED::flatten(buffer); 62 this->INHERITED::flatten(buffer);
63 bool hasLocalM = this->hasLocalMatrix(); 63 bool hasLocalM = !fLocalMatrix.isIdentity();
64 buffer.writeBool(hasLocalM); 64 buffer.writeBool(hasLocalM);
65 if (hasLocalM) { 65 if (hasLocalM) {
66 buffer.writeMatrix(fLocalMatrix); 66 buffer.writeMatrix(fLocalMatrix);
67 } 67 }
68 } 68 }
69 69
70 bool SkShader::computeTotalInverse(const ContextRec& rec, SkMatrix* totalInverse ) const { 70 bool SkShader::computeTotalInverse(const ContextRec& rec, SkMatrix* totalInverse ) const {
71 const SkMatrix* m = rec.fMatrix; 71 SkMatrix total;
72 SkMatrix total; 72 total.setConcat(*rec.fMatrix, fLocalMatrix);
73 73
74 if (this->hasLocalMatrix()) { 74 const SkMatrix* m = &total;
75 total.setConcat(*m, this->getLocalMatrix());
76 m = &total;
77 }
78 if (rec.fLocalMatrix) { 75 if (rec.fLocalMatrix) {
79 total.setConcat(*m, *rec.fLocalMatrix); 76 total.setConcat(*m, *rec.fLocalMatrix);
80 m = &total; 77 m = &total;
81 } 78 }
82 return m->invert(totalInverse); 79 return m->invert(totalInverse);
83 } 80 }
84 81
85 SkShader::Context* SkShader::createContext(const ContextRec& rec, void* storage) const { 82 SkShader::Context* SkShader::createContext(const ContextRec& rec, void* storage) const {
86 if (!this->computeTotalInverse(rec, NULL)) { 83 if (!this->computeTotalInverse(rec, NULL)) {
87 return NULL; 84 return NULL;
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 return ::CreateBitmapShader(src, tmx, tmy, localMatrix, NULL); 225 return ::CreateBitmapShader(src, tmx, tmy, localMatrix, NULL);
229 } 226 }
230 227
231 SkShader* SkShader::CreatePictureShader(SkPicture* src, TileMode tmx, TileMode t my, 228 SkShader* SkShader::CreatePictureShader(SkPicture* src, TileMode tmx, TileMode t my,
232 const SkMatrix* localMatrix) { 229 const SkMatrix* localMatrix) {
233 return SkPictureShader::Create(src, tmx, tmy, localMatrix); 230 return SkPictureShader::Create(src, tmx, tmy, localMatrix);
234 } 231 }
235 232
236 #ifndef SK_IGNORE_TO_STRING 233 #ifndef SK_IGNORE_TO_STRING
237 void SkShader::toString(SkString* str) const { 234 void SkShader::toString(SkString* str) const {
238 if (this->hasLocalMatrix()) { 235 if (!fLocalMatrix.isIdentity()) {
239 str->append(" "); 236 str->append(" ");
240 this->getLocalMatrix().toString(str); 237 fLocalMatrix.toString(str);
241 } 238 }
242 } 239 }
243 #endif 240 #endif
244 241
245 ////////////////////////////////////////////////////////////////////////////// 242 //////////////////////////////////////////////////////////////////////////////
246 243
247 #include "SkColorShader.h" 244 #include "SkColorShader.h"
248 #include "SkUtils.h" 245 #include "SkUtils.h"
249 246
250 SkColorShader::SkColorShader(SkColor c) 247 SkColorShader::SkColorShader(SkColor c)
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 #include "SkEmptyShader.h" 360 #include "SkEmptyShader.h"
364 361
365 void SkEmptyShader::toString(SkString* str) const { 362 void SkEmptyShader::toString(SkString* str) const {
366 str->append("SkEmptyShader: ("); 363 str->append("SkEmptyShader: (");
367 364
368 this->INHERITED::toString(str); 365 this->INHERITED::toString(str);
369 366
370 str->append(")"); 367 str->append(")");
371 } 368 }
372 #endif 369 #endif
OLDNEW
« no previous file with comments | « src/core/SkPictureShader.cpp ('k') | src/effects/SkRectShaderImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698