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

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

Issue 1401743004: Fix floating point data loss in SkPictureShader (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 5 years, 2 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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 SkScalar tileArea = SkScalarMul(scaledSize.width(), scaledSize.height()); 183 SkScalar tileArea = SkScalarMul(scaledSize.width(), scaledSize.height());
184 if (tileArea > kMaxTileArea) { 184 if (tileArea > kMaxTileArea) {
185 SkScalar clampScale = SkScalarSqrt(kMaxTileArea / tileArea); 185 SkScalar clampScale = SkScalarSqrt(kMaxTileArea / tileArea);
186 scaledSize.set(SkScalarMul(scaledSize.width(), clampScale), 186 scaledSize.set(SkScalarMul(scaledSize.width(), clampScale),
187 SkScalarMul(scaledSize.height(), clampScale)); 187 SkScalarMul(scaledSize.height(), clampScale));
188 } 188 }
189 #if SK_SUPPORT_GPU 189 #if SK_SUPPORT_GPU
190 // Scale down the tile size if larger than maxTextureSize for GPU Path or it should fail on create texture 190 // Scale down the tile size if larger than maxTextureSize for GPU Path or it should fail on create texture
191 if (maxTextureSize) { 191 if (maxTextureSize) {
192 if (scaledSize.width() > maxTextureSize || scaledSize.height() > maxText ureSize) { 192 if (scaledSize.width() > maxTextureSize || scaledSize.height() > maxText ureSize) {
193 SkScalar downScale = maxTextureSize / SkMax32(scaledSize.width(), sc aledSize.height()); 193 SkScalar downScale = maxTextureSize / SkMaxScalar(scaledSize.width() , scaledSize.height());
194 scaledSize.set(SkScalarFloorToScalar(SkScalarMul(scaledSize.width(), downScale)), 194 scaledSize.set(SkScalarFloorToScalar(SkScalarMul(scaledSize.width(), downScale)),
195 SkScalarFloorToScalar(SkScalarMul(scaledSize.height() , downScale))); 195 SkScalarFloorToScalar(SkScalarMul(scaledSize.height() , downScale)));
196 } 196 }
197 } 197 }
198 #endif 198 #endif
199 199
200 SkISize tileSize = scaledSize.toRound(); 200 SkISize tileSize = scaledSize.toRound();
201 if (tileSize.isEmpty()) { 201 if (tileSize.isEmpty()) {
202 return SkShader::CreateEmptyShader(); 202 return SkShader::CreateEmptyShader();
203 } 203 }
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 if (context) { 323 if (context) {
324 maxTextureSize = context->caps()->maxTextureSize(); 324 maxTextureSize = context->caps()->maxTextureSize();
325 } 325 }
326 SkAutoTUnref<SkShader> bitmapShader(this->refBitmapShader(viewM, localMatrix , maxTextureSize)); 326 SkAutoTUnref<SkShader> bitmapShader(this->refBitmapShader(viewM, localMatrix , maxTextureSize));
327 if (!bitmapShader) { 327 if (!bitmapShader) {
328 return nullptr; 328 return nullptr;
329 } 329 }
330 return bitmapShader->asFragmentProcessor(context, viewM, nullptr, fq); 330 return bitmapShader->asFragmentProcessor(context, viewM, nullptr, fq);
331 } 331 }
332 #endif 332 #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