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

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

Issue 998423004: Lower SkPictureShader tile size limits (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: 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 | « no previous file | no next file » | 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 // Use a rotation-invariant scale 153 // Use a rotation-invariant scale
154 SkPoint scale; 154 SkPoint scale;
155 if (!SkDecomposeUpper2x2(m, NULL, &scale, NULL)) { 155 if (!SkDecomposeUpper2x2(m, NULL, &scale, NULL)) {
156 // Decomposition failed, use an approximation. 156 // Decomposition failed, use an approximation.
157 scale.set(SkScalarSqrt(m.getScaleX() * m.getScaleX() + m.getSkewX() * m. getSkewX()), 157 scale.set(SkScalarSqrt(m.getScaleX() * m.getScaleX() + m.getSkewX() * m. getSkewX()),
158 SkScalarSqrt(m.getScaleY() * m.getScaleY() + m.getSkewY() * m. getSkewY())); 158 SkScalarSqrt(m.getScaleY() * m.getScaleY() + m.getSkewY() * m. getSkewY()));
159 } 159 }
160 SkSize scaledSize = SkSize::Make(SkScalarAbs(scale.x() * fTile.width()), 160 SkSize scaledSize = SkSize::Make(SkScalarAbs(scale.x() * fTile.width()),
161 SkScalarAbs(scale.y() * fTile.height())); 161 SkScalarAbs(scale.y() * fTile.height()));
162 162
163 // Clamp the tile size to about 16M pixels 163 // Clamp the tile size to about 4M pixels
164 static const SkScalar kMaxTileArea = 4096 * 4096; 164 static const SkScalar kMaxTileArea = 2048 * 2048;
165 SkScalar tileArea = SkScalarMul(scaledSize.width(), scaledSize.height()); 165 SkScalar tileArea = SkScalarMul(scaledSize.width(), scaledSize.height());
166 if (tileArea > kMaxTileArea) { 166 if (tileArea > kMaxTileArea) {
167 SkScalar clampScale = SkScalarSqrt(SkScalarDiv(kMaxTileArea, tileArea)); 167 SkScalar clampScale = SkScalarSqrt(SkScalarDiv(kMaxTileArea, tileArea));
168 scaledSize.set(SkScalarMul(scaledSize.width(), clampScale), 168 scaledSize.set(SkScalarMul(scaledSize.width(), clampScale),
169 SkScalarMul(scaledSize.height(), clampScale)); 169 SkScalarMul(scaledSize.height(), clampScale));
170 } 170 }
171 171
172 SkISize tileSize = scaledSize.toRound(); 172 SkISize tileSize = scaledSize.toRound();
173 if (tileSize.isEmpty()) { 173 if (tileSize.isEmpty()) {
174 return NULL; 174 return NULL;
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 return bitmapShader->asFragmentProcessor(context, paint, viewM, NULL, paintC olor, fp); 303 return bitmapShader->asFragmentProcessor(context, paint, viewM, NULL, paintC olor, fp);
304 } 304 }
305 #else 305 #else
306 bool SkPictureShader::asFragmentProcessor(GrContext*, const SkPaint&, const SkMa trix&, 306 bool SkPictureShader::asFragmentProcessor(GrContext*, const SkPaint&, const SkMa trix&,
307 const SkMatrix*, GrColor*, 307 const SkMatrix*, GrColor*,
308 GrFragmentProcessor**) const { 308 GrFragmentProcessor**) const {
309 SkDEBUGFAIL("Should not call in GPU-less build"); 309 SkDEBUGFAIL("Should not call in GPU-less build");
310 return false; 310 return false;
311 } 311 }
312 #endif 312 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698