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

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

Issue 279903002: reland hide get/setLocalMatrix (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: remember global initialization of flattenables 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
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
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 "SkPictureShader.h" 8 #include "SkPictureShader.h"
9 9
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 49
50 buffer.write32(fTmx); 50 buffer.write32(fTmx);
51 buffer.write32(fTmy); 51 buffer.write32(fTmy);
52 fPicture->flatten(buffer); 52 fPicture->flatten(buffer);
53 } 53 }
54 54
55 SkShader* SkPictureShader::refBitmapShader(const SkMatrix& matrix, const SkMatri x* localM) const { 55 SkShader* SkPictureShader::refBitmapShader(const SkMatrix& matrix, const SkMatri x* localM) const {
56 SkASSERT(fPicture && fPicture->width() > 0 && fPicture->height() > 0); 56 SkASSERT(fPicture && fPicture->width() > 0 && fPicture->height() > 0);
57 57
58 SkMatrix m; 58 SkMatrix m;
59 if (this->hasLocalMatrix()) { 59 m.setConcat(matrix, this->getLocalMatrix());
60 m.setConcat(matrix, this->getLocalMatrix());
61 } else {
62 m = matrix;
63 }
64 if (localM) { 60 if (localM) {
65 m.preConcat(*localM); 61 m.preConcat(*localM);
66 } 62 }
67 63
68 // Use a rotation-invariant scale 64 // Use a rotation-invariant scale
69 SkPoint scale; 65 SkPoint scale;
70 if (!SkDecomposeUpper2x2(m, NULL, &scale, NULL)) { 66 if (!SkDecomposeUpper2x2(m, NULL, &scale, NULL)) {
71 // Decomposition failed, use an approximation. 67 // Decomposition failed, use an approximation.
72 scale.set(SkScalarSqrt(m.getScaleX() * m.getScaleX() + m.getSkewX() * m. getSkewX()), 68 scale.set(SkScalarSqrt(m.getScaleX() * m.getScaleX() + m.getSkewX() * m. getSkewX()),
73 SkScalarSqrt(m.getScaleY() * m.getScaleY() + m.getSkewY() * m. getSkewY())); 69 SkScalarSqrt(m.getScaleY() * m.getScaleY() + m.getSkewY() * m. getSkewY()));
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 #if SK_SUPPORT_GPU 190 #if SK_SUPPORT_GPU
195 GrEffectRef* SkPictureShader::asNewEffect(GrContext* context, const SkPaint& pai nt, 191 GrEffectRef* SkPictureShader::asNewEffect(GrContext* context, const SkPaint& pai nt,
196 const SkMatrix* localMatrix) const { 192 const SkMatrix* localMatrix) const {
197 SkAutoTUnref<SkShader> bitmapShader(this->refBitmapShader(context->getMatrix (), localMatrix)); 193 SkAutoTUnref<SkShader> bitmapShader(this->refBitmapShader(context->getMatrix (), localMatrix));
198 if (!bitmapShader) { 194 if (!bitmapShader) {
199 return NULL; 195 return NULL;
200 } 196 }
201 return bitmapShader->asNewEffect(context, paint, NULL); 197 return bitmapShader->asNewEffect(context, paint, NULL);
202 } 198 }
203 #endif 199 #endif
OLDNEW
« no previous file with comments | « src/core/SkLocalMatrixShader.cpp ('k') | src/core/SkShader.cpp » ('j') | src/core/SkShader.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698