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

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

Issue 1129413002: SkPictureShader: floor scaledSize not to exceed maxTextureSize (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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
« 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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 SkScalar clampScale = SkScalarSqrt(SkScalarDiv(kMaxTileArea, tileArea)); 171 SkScalar clampScale = SkScalarSqrt(SkScalarDiv(kMaxTileArea, tileArea));
172 scaledSize.set(SkScalarMul(scaledSize.width(), clampScale), 172 scaledSize.set(SkScalarMul(scaledSize.width(), clampScale),
173 SkScalarMul(scaledSize.height(), clampScale)); 173 SkScalarMul(scaledSize.height(), clampScale));
174 } 174 }
175 #if SK_SUPPORT_GPU 175 #if SK_SUPPORT_GPU
176 // Scale down the tile size if larger than maxTextureSize for GPU Path or it should fail on create texture 176 // Scale down the tile size if larger than maxTextureSize for GPU Path or it should fail on create texture
177 if (maxTextureSize) { 177 if (maxTextureSize) {
178 if (scaledSize.width() > maxTextureSize || scaledSize.height() > maxText ureSize) { 178 if (scaledSize.width() > maxTextureSize || scaledSize.height() > maxText ureSize) {
179 SkScalar downScale = SkScalarDiv(maxTextureSize, 179 SkScalar downScale = SkScalarDiv(maxTextureSize,
180 SkMax32(scaledSize.width(), scaledSi ze.height())); 180 SkMax32(scaledSize.width(), scaledSi ze.height()));
181 scaledSize.set(SkScalarMul(scaledSize.width(), downScale), 181 scaledSize.set(SkScalarFloorToScalar(SkScalarMul(scaledSize.width(), downScale)),
182 SkScalarMul(scaledSize.height(), downScale)); 182 SkScalarFloorToScalar(SkScalarMul(scaledSize.height() , downScale)));
183 } 183 }
184 } 184 }
185 #endif 185 #endif
186 186
187 SkISize tileSize = scaledSize.toRound(); 187 SkISize tileSize = scaledSize.toRound();
188 if (tileSize.isEmpty()) { 188 if (tileSize.isEmpty()) {
189 return NULL; 189 return NULL;
190 } 190 }
191 191
192 // The actual scale, compensating for rounding & clamping. 192 // The actual scale, compensating for rounding & clamping.
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 return bitmapShader->asFragmentProcessor(context, paint, viewM, NULL, paintC olor, fp); 322 return bitmapShader->asFragmentProcessor(context, paint, viewM, NULL, paintC olor, fp);
323 } 323 }
324 #else 324 #else
325 bool SkPictureShader::asFragmentProcessor(GrContext*, const SkPaint&, const SkMa trix&, 325 bool SkPictureShader::asFragmentProcessor(GrContext*, const SkPaint&, const SkMa trix&,
326 const SkMatrix*, GrColor*, 326 const SkMatrix*, GrColor*,
327 GrFragmentProcessor**) const { 327 GrFragmentProcessor**) const {
328 SkDEBUGFAIL("Should not call in GPU-less build"); 328 SkDEBUGFAIL("Should not call in GPU-less build");
329 return false; 329 return false;
330 } 330 }
331 #endif 331 #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