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

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

Issue 1138263002: Revert of stop calling SkScalarDiv (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 | « src/core/SkPathMeasure.cpp ('k') | src/core/SkRRect.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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 scale.set(SkScalarSqrt(m.getScaleX() * m.getScaleX() + m.getSkewX() * m. getSkewX()), 161 scale.set(SkScalarSqrt(m.getScaleX() * m.getScaleX() + m.getSkewX() * m. getSkewX()),
162 SkScalarSqrt(m.getScaleY() * m.getScaleY() + m.getSkewY() * m. getSkewY())); 162 SkScalarSqrt(m.getScaleY() * m.getScaleY() + m.getSkewY() * m. getSkewY()));
163 } 163 }
164 SkSize scaledSize = SkSize::Make(SkScalarAbs(scale.x() * fTile.width()), 164 SkSize scaledSize = SkSize::Make(SkScalarAbs(scale.x() * fTile.width()),
165 SkScalarAbs(scale.y() * fTile.height())); 165 SkScalarAbs(scale.y() * fTile.height()));
166 166
167 // Clamp the tile size to about 4M pixels 167 // Clamp the tile size to about 4M pixels
168 static const SkScalar kMaxTileArea = 2048 * 2048; 168 static const SkScalar kMaxTileArea = 2048 * 2048;
169 SkScalar tileArea = SkScalarMul(scaledSize.width(), scaledSize.height()); 169 SkScalar tileArea = SkScalarMul(scaledSize.width(), scaledSize.height());
170 if (tileArea > kMaxTileArea) { 170 if (tileArea > kMaxTileArea) {
171 SkScalar clampScale = SkScalarSqrt(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 = maxTextureSize / SkMax32(scaledSize.width(), sc aledSize.height()); 179 SkScalar downScale = SkScalarDiv(maxTextureSize,
180 SkMax32(scaledSize.width(), scaledSi ze.height()));
180 scaledSize.set(SkScalarFloorToScalar(SkScalarMul(scaledSize.width(), downScale)), 181 scaledSize.set(SkScalarFloorToScalar(SkScalarMul(scaledSize.width(), downScale)),
181 SkScalarFloorToScalar(SkScalarMul(scaledSize.height() , downScale))); 182 SkScalarFloorToScalar(SkScalarMul(scaledSize.height() , downScale)));
182 } 183 }
183 } 184 }
184 #endif 185 #endif
185 186
186 SkISize tileSize = scaledSize.toRound(); 187 SkISize tileSize = scaledSize.toRound();
187 if (tileSize.isEmpty()) { 188 if (tileSize.isEmpty()) {
188 return NULL; 189 return NULL;
189 } 190 }
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 return bitmapShader->asFragmentProcessor(context, paint, viewM, NULL, paintC olor, fp); 322 return bitmapShader->asFragmentProcessor(context, paint, viewM, NULL, paintC olor, fp);
322 } 323 }
323 #else 324 #else
324 bool SkPictureShader::asFragmentProcessor(GrContext*, const SkPaint&, const SkMa trix&, 325 bool SkPictureShader::asFragmentProcessor(GrContext*, const SkPaint&, const SkMa trix&,
325 const SkMatrix*, GrColor*, 326 const SkMatrix*, GrColor*,
326 GrFragmentProcessor**) const { 327 GrFragmentProcessor**) const {
327 SkDEBUGFAIL("Should not call in GPU-less build"); 328 SkDEBUGFAIL("Should not call in GPU-less build");
328 return false; 329 return false;
329 } 330 }
330 #endif 331 #endif
OLDNEW
« no previous file with comments | « src/core/SkPathMeasure.cpp ('k') | src/core/SkRRect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698