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

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

Issue 1006173005: add SkMatrix::decomposeScale (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add unittest Created 5 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 | « src/core/SkMatrix.cpp ('k') | tests/MatrixTest.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 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 SkASSERT(fPicture && !fPicture->cullRect().isEmpty()); 145 SkASSERT(fPicture && !fPicture->cullRect().isEmpty());
146 146
147 SkMatrix m; 147 SkMatrix m;
148 m.setConcat(matrix, this->getLocalMatrix()); 148 m.setConcat(matrix, this->getLocalMatrix());
149 if (localM) { 149 if (localM) {
150 m.preConcat(*localM); 150 m.preConcat(*localM);
151 } 151 }
152 152
153 // Use a rotation-invariant scale 153 // Use a rotation-invariant scale
154 SkPoint scale; 154 SkPoint scale;
155 //
156 // TODO: replace this with decomposeScale() -- but beware LayoutTest rebasel ines!
157 //
155 if (!SkDecomposeUpper2x2(m, NULL, &scale, NULL)) { 158 if (!SkDecomposeUpper2x2(m, NULL, &scale, NULL)) {
156 // Decomposition failed, use an approximation. 159 // Decomposition failed, use an approximation.
157 scale.set(SkScalarSqrt(m.getScaleX() * m.getScaleX() + m.getSkewX() * m. getSkewX()), 160 scale.set(SkScalarSqrt(m.getScaleX() * m.getScaleX() + m.getSkewX() * m. getSkewX()),
158 SkScalarSqrt(m.getScaleY() * m.getScaleY() + m.getSkewY() * m. getSkewY())); 161 SkScalarSqrt(m.getScaleY() * m.getScaleY() + m.getSkewY() * m. getSkewY()));
159 } 162 }
160 SkSize scaledSize = SkSize::Make(SkScalarAbs(scale.x() * fTile.width()), 163 SkSize scaledSize = SkSize::Make(SkScalarAbs(scale.x() * fTile.width()),
161 SkScalarAbs(scale.y() * fTile.height())); 164 SkScalarAbs(scale.y() * fTile.height()));
162 165
163 // Clamp the tile size to about 4M pixels 166 // Clamp the tile size to about 4M pixels
164 static const SkScalar kMaxTileArea = 2048 * 2048; 167 static const SkScalar kMaxTileArea = 2048 * 2048;
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 return bitmapShader->asFragmentProcessor(context, paint, viewM, NULL, paintC olor, fp); 306 return bitmapShader->asFragmentProcessor(context, paint, viewM, NULL, paintC olor, fp);
304 } 307 }
305 #else 308 #else
306 bool SkPictureShader::asFragmentProcessor(GrContext*, const SkPaint&, const SkMa trix&, 309 bool SkPictureShader::asFragmentProcessor(GrContext*, const SkPaint&, const SkMa trix&,
307 const SkMatrix*, GrColor*, 310 const SkMatrix*, GrColor*,
308 GrFragmentProcessor**) const { 311 GrFragmentProcessor**) const {
309 SkDEBUGFAIL("Should not call in GPU-less build"); 312 SkDEBUGFAIL("Should not call in GPU-less build");
310 return false; 313 return false;
311 } 314 }
312 #endif 315 #endif
OLDNEW
« no previous file with comments | « src/core/SkMatrix.cpp ('k') | tests/MatrixTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698