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

Side by Side Diff: src/pdf/SkPDFShader.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/pdf/SkPDFGraphicState.cpp ('k') | src/ports/SkFontHost_FreeType.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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkPDFShader.h" 10 #include "SkPDFShader.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 @param result The result ps function. 51 @param result The result ps function.
52 */ 52 */
53 static void interpolateColorCode(SkScalar range, SkScalar* curColor, 53 static void interpolateColorCode(SkScalar range, SkScalar* curColor,
54 SkScalar* prevColor, SkString* result) { 54 SkScalar* prevColor, SkString* result) {
55 SkASSERT(range != SkIntToScalar(0)); 55 SkASSERT(range != SkIntToScalar(0));
56 static const int kColorComponents = 3; 56 static const int kColorComponents = 3;
57 57
58 // Figure out how to scale each color component. 58 // Figure out how to scale each color component.
59 SkScalar multiplier[kColorComponents]; 59 SkScalar multiplier[kColorComponents];
60 for (int i = 0; i < kColorComponents; i++) { 60 for (int i = 0; i < kColorComponents; i++) {
61 multiplier[i] = (curColor[i] - prevColor[i]) / range; 61 multiplier[i] = SkScalarDiv(curColor[i] - prevColor[i], range);
62 } 62 }
63 63
64 // Calculate when we no longer need to keep a copy of the input parameter t. 64 // Calculate when we no longer need to keep a copy of the input parameter t.
65 // If the last component to use t is i, then dupInput[0..i - 1] = true 65 // If the last component to use t is i, then dupInput[0..i - 1] = true
66 // and dupInput[i .. components] = false. 66 // and dupInput[i .. components] = false.
67 bool dupInput[kColorComponents]; 67 bool dupInput[kColorComponents];
68 dupInput[kColorComponents - 1] = false; 68 dupInput[kColorComponents - 1] = false;
69 for (int i = kColorComponents - 2; i >= 0; i--) { 69 for (int i = kColorComponents - 2; i >= 0; i--) {
70 dupInput[i] = dupInput[i + 1] || multiplier[i + 1] != 0; 70 dupInput[i] = dupInput[i + 1] || multiplier[i + 1] != 0;
71 } 71 }
(...skipping 1053 matching lines...) Expand 10 before | Expand all | Expand 10 after
1125 SkRect shaderRect = SkRect::Make(bbox); 1125 SkRect shaderRect = SkRect::Make(bbox);
1126 if (!inverse_transform_bbox(canvasTransform, &shaderRect)) { 1126 if (!inverse_transform_bbox(canvasTransform, &shaderRect)) {
1127 fImage.reset(); 1127 fImage.reset();
1128 return; 1128 return;
1129 } 1129 }
1130 1130
1131 // Clamp the bitmap size to about 1M pixels 1131 // Clamp the bitmap size to about 1M pixels
1132 static const SkScalar kMaxBitmapArea = 1024 * 1024; 1132 static const SkScalar kMaxBitmapArea = 1024 * 1024;
1133 SkScalar bitmapArea = rasterScale * bbox.width() * rasterScale * bbo x.height(); 1133 SkScalar bitmapArea = rasterScale * bbox.width() * rasterScale * bbo x.height();
1134 if (bitmapArea > kMaxBitmapArea) { 1134 if (bitmapArea > kMaxBitmapArea) {
1135 rasterScale *= SkScalarSqrt(kMaxBitmapArea / bitmapArea); 1135 rasterScale *= SkScalarSqrt(SkScalarDiv(kMaxBitmapArea, bitmapAr ea));
1136 } 1136 }
1137 1137
1138 SkISize size = SkISize::Make(SkScalarRoundToInt(rasterScale * bbox.w idth()), 1138 SkISize size = SkISize::Make(SkScalarRoundToInt(rasterScale * bbox.w idth()),
1139 SkScalarRoundToInt(rasterScale * bbox.h eight())); 1139 SkScalarRoundToInt(rasterScale * bbox.h eight()));
1140 SkSize scale = SkSize::Make(SkIntToScalar(size.width()) / shaderRect .width(), 1140 SkSize scale = SkSize::Make(SkIntToScalar(size.width()) / shaderRect .width(),
1141 SkIntToScalar(size.height()) / shaderRec t.height()); 1141 SkIntToScalar(size.height()) / shaderRec t.height());
1142 1142
1143 fImage.allocN32Pixels(size.width(), size.height()); 1143 fImage.allocN32Pixels(size.width(), size.height());
1144 fImage.eraseColor(SK_ColorTRANSPARENT); 1144 fImage.eraseColor(SK_ColorTRANSPARENT);
1145 1145
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1234 return false; 1234 return false;
1235 } 1235 }
1236 1236
1237 void SkPDFShader::State::AllocateGradientInfoStorage() { 1237 void SkPDFShader::State::AllocateGradientInfoStorage() {
1238 fColorData.set(sk_malloc_throw( 1238 fColorData.set(sk_malloc_throw(
1239 fInfo.fColorCount * (sizeof(SkColor) + sizeof(SkScalar)))); 1239 fInfo.fColorCount * (sizeof(SkColor) + sizeof(SkScalar))));
1240 fInfo.fColors = reinterpret_cast<SkColor*>(fColorData.get()); 1240 fInfo.fColors = reinterpret_cast<SkColor*>(fColorData.get());
1241 fInfo.fColorOffsets = 1241 fInfo.fColorOffsets =
1242 reinterpret_cast<SkScalar*>(fInfo.fColors + fInfo.fColorCount); 1242 reinterpret_cast<SkScalar*>(fInfo.fColors + fInfo.fColorCount);
1243 } 1243 }
OLDNEW
« no previous file with comments | « src/pdf/SkPDFGraphicState.cpp ('k') | src/ports/SkFontHost_FreeType.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698