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

Side by Side Diff: pdf/draw_utils.cc

Issue 1533413002: Switch to standard integer types in pdf/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 5 years 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 | « pdf/draw_utils.h ('k') | pdf/out_of_process_instance.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "pdf/draw_utils.h" 5 #include "pdf/draw_utils.h"
6 6
7 #include <math.h>
8 #include <stddef.h>
9 #include <stdint.h>
7 #include <algorithm> 10 #include <algorithm>
8 #include <math.h>
9 #include <vector> 11 #include <vector>
10 12
11 #include "base/logging.h" 13 #include "base/logging.h"
12 #include "base/numerics/safe_math.h" 14 #include "base/numerics/safe_math.h"
13 15
14 namespace chrome_pdf { 16 namespace chrome_pdf {
15 17
16 inline uint8 GetBlue(const uint32& pixel) { 18 inline uint8_t GetBlue(const uint32_t& pixel) {
17 return static_cast<uint8>(pixel & 0xFF); 19 return static_cast<uint8_t>(pixel & 0xFF);
18 } 20 }
19 21
20 inline uint8 GetGreen(const uint32& pixel) { 22 inline uint8_t GetGreen(const uint32_t& pixel) {
21 return static_cast<uint8>((pixel >> 8) & 0xFF); 23 return static_cast<uint8_t>((pixel >> 8) & 0xFF);
22 } 24 }
23 25
24 inline uint8 GetRed(const uint32& pixel) { 26 inline uint8_t GetRed(const uint32_t& pixel) {
25 return static_cast<uint8>((pixel >> 16) & 0xFF); 27 return static_cast<uint8_t>((pixel >> 16) & 0xFF);
26 } 28 }
27 29
28 inline uint8 GetAlpha(const uint32& pixel) { 30 inline uint8_t GetAlpha(const uint32_t& pixel) {
29 return static_cast<uint8>((pixel >> 24) & 0xFF); 31 return static_cast<uint8_t>((pixel >> 24) & 0xFF);
30 } 32 }
31 33
32 inline uint32_t MakePixel(uint8 red, uint8 green, uint8 blue, uint8 alpha) { 34 inline uint32_t MakePixel(uint8_t red,
35 uint8_t green,
36 uint8_t blue,
37 uint8_t alpha) {
33 return (static_cast<uint32_t>(alpha) << 24) | 38 return (static_cast<uint32_t>(alpha) << 24) |
34 (static_cast<uint32_t>(red) << 16) | 39 (static_cast<uint32_t>(red) << 16) |
35 (static_cast<uint32_t>(green) << 8) | 40 (static_cast<uint32_t>(green) << 8) |
36 static_cast<uint32_t>(blue); 41 static_cast<uint32_t>(blue);
37 } 42 }
38 43
39 inline uint8 GradientChannel(uint8 start, uint8 end, double ratio) { 44 inline uint8_t GradientChannel(uint8_t start, uint8_t end, double ratio) {
40 double new_channel = start - (static_cast<double>(start) - end) * ratio; 45 double new_channel = start - (static_cast<double>(start) - end) * ratio;
41 if (new_channel < 0) 46 if (new_channel < 0)
42 return 0; 47 return 0;
43 if (new_channel > 255) 48 if (new_channel > 255)
44 return 255; 49 return 255;
45 return static_cast<uint8>(new_channel + 0.5); 50 return static_cast<uint8_t>(new_channel + 0.5);
46 } 51 }
47 52
48 inline uint8 ProcessColor(uint8 src_color, uint8 dest_color, uint8 alpha) { 53 inline uint8_t ProcessColor(uint8_t src_color,
49 uint32 processed = static_cast<uint32>(src_color) * alpha + 54 uint8_t dest_color,
50 static_cast<uint32>(dest_color) * (0xFF - alpha); 55 uint8_t alpha) {
51 return static_cast<uint8>((processed / 0xFF) & 0xFF); 56 uint32_t processed = static_cast<uint32_t>(src_color) * alpha +
57 static_cast<uint32_t>(dest_color) * (0xFF - alpha);
58 return static_cast<uint8_t>((processed / 0xFF) & 0xFF);
52 } 59 }
53 60
54 inline bool ImageDataContainsRect(const pp::ImageData& image_data, 61 inline bool ImageDataContainsRect(const pp::ImageData& image_data,
55 const pp::Rect& rect) { 62 const pp::Rect& rect) {
56 return rect.width() >= 0 && rect.height() >= 0 && 63 return rect.width() >= 0 && rect.height() >= 0 &&
57 pp::Rect(image_data.size()).Contains(rect); 64 pp::Rect(image_data.size()).Contains(rect);
58 } 65 }
59 66
60 void AlphaBlend(const pp::ImageData& src, const pp::Rect& src_rc, 67 void AlphaBlend(const pp::ImageData& src,
61 pp::ImageData* dest, const pp::Point& dest_origin, 68 const pp::Rect& src_rc,
62 uint8 alpha_adjustment) { 69 pp::ImageData* dest,
70 const pp::Point& dest_origin,
71 uint8_t alpha_adjustment) {
63 if (src_rc.IsEmpty() || !ImageDataContainsRect(src, src_rc)) 72 if (src_rc.IsEmpty() || !ImageDataContainsRect(src, src_rc))
64 return; 73 return;
65 74
66 pp::Rect dest_rc(dest_origin, src_rc.size()); 75 pp::Rect dest_rc(dest_origin, src_rc.size());
67 if (dest_rc.IsEmpty() || !ImageDataContainsRect(*dest, dest_rc)) 76 if (dest_rc.IsEmpty() || !ImageDataContainsRect(*dest, dest_rc))
68 return; 77 return;
69 78
70 const uint32_t* src_origin_pixel = src.GetAddr32(src_rc.point()); 79 const uint32_t* src_origin_pixel = src.GetAddr32(src_rc.point());
71 uint32_t* dest_origin_pixel = dest->GetAddr32(dest_origin); 80 uint32_t* dest_origin_pixel = dest->GetAddr32(dest_origin);
72 81
73 int height = src_rc.height(); 82 int height = src_rc.height();
74 int width = src_rc.width(); 83 int width = src_rc.width();
75 for (int y = 0; y < height; y++) { 84 for (int y = 0; y < height; y++) {
76 const uint32_t* src_pixel = src_origin_pixel; 85 const uint32_t* src_pixel = src_origin_pixel;
77 uint32_t* dest_pixel = dest_origin_pixel; 86 uint32_t* dest_pixel = dest_origin_pixel;
78 for (int x = 0; x < width; x++) { 87 for (int x = 0; x < width; x++) {
79 uint8 alpha = static_cast<uint8>(static_cast<uint32_t>(alpha_adjustment) * 88 uint8_t alpha =
80 GetAlpha(*src_pixel) / 0xFF); 89 static_cast<uint8_t>(static_cast<uint32_t>(alpha_adjustment) *
81 uint8 red = ProcessColor(GetRed(*src_pixel), GetRed(*dest_pixel), alpha); 90 GetAlpha(*src_pixel) / 0xFF);
82 uint8 green = ProcessColor(GetGreen(*src_pixel), 91 uint8_t red =
83 GetGreen(*dest_pixel), alpha); 92 ProcessColor(GetRed(*src_pixel), GetRed(*dest_pixel), alpha);
84 uint8 blue = ProcessColor(GetBlue(*src_pixel), 93 uint8_t green =
85 GetBlue(*dest_pixel), alpha); 94 ProcessColor(GetGreen(*src_pixel), GetGreen(*dest_pixel), alpha);
95 uint8_t blue =
96 ProcessColor(GetBlue(*src_pixel), GetBlue(*dest_pixel), alpha);
86 *dest_pixel = MakePixel(red, green, blue, GetAlpha(*dest_pixel)); 97 *dest_pixel = MakePixel(red, green, blue, GetAlpha(*dest_pixel));
87 98
88 src_pixel++; 99 src_pixel++;
89 dest_pixel++; 100 dest_pixel++;
90 } 101 }
91 src_origin_pixel = reinterpret_cast<const uint32_t*>( 102 src_origin_pixel = reinterpret_cast<const uint32_t*>(
92 reinterpret_cast<const char*>(src_origin_pixel) + src.stride()); 103 reinterpret_cast<const char*>(src_origin_pixel) + src.stride());
93 dest_origin_pixel = reinterpret_cast<uint32_t*>( 104 dest_origin_pixel = reinterpret_cast<uint32_t*>(
94 reinterpret_cast<char*>(dest_origin_pixel) + dest->stride()); 105 reinterpret_cast<char*>(dest_origin_pixel) + dest->stride());
95 } 106 }
96 } 107 }
97 108
98 void GradientFill(pp::ImageData* image, const pp::Rect& rc, 109 void GradientFill(pp::ImageData* image,
99 uint32 start_color, uint32 end_color, bool horizontal) { 110 const pp::Rect& rc,
100 std::vector<uint32> colors; 111 uint32_t start_color,
112 uint32_t end_color,
113 bool horizontal) {
114 std::vector<uint32_t> colors;
101 colors.resize(horizontal ? rc.width() : rc.height()); 115 colors.resize(horizontal ? rc.width() : rc.height());
102 for (size_t i = 0; i < colors.size(); ++i) { 116 for (size_t i = 0; i < colors.size(); ++i) {
103 double ratio = static_cast<double>(i) / colors.size(); 117 double ratio = static_cast<double>(i) / colors.size();
104 colors[i] = MakePixel( 118 colors[i] = MakePixel(
105 GradientChannel(GetRed(start_color), GetRed(end_color), ratio), 119 GradientChannel(GetRed(start_color), GetRed(end_color), ratio),
106 GradientChannel(GetGreen(start_color), GetGreen(end_color), ratio), 120 GradientChannel(GetGreen(start_color), GetGreen(end_color), ratio),
107 GradientChannel(GetBlue(start_color), GetBlue(end_color), ratio), 121 GradientChannel(GetBlue(start_color), GetBlue(end_color), ratio),
108 GradientChannel(GetAlpha(start_color), GetAlpha(end_color), ratio)); 122 GradientChannel(GetAlpha(start_color), GetAlpha(end_color), ratio));
109 } 123 }
110 124
(...skipping 17 matching lines...) Expand all
128 origin_pixel = reinterpret_cast<uint32_t*>( 142 origin_pixel = reinterpret_cast<uint32_t*>(
129 reinterpret_cast<char*>(origin_pixel) + image->stride()); 143 reinterpret_cast<char*>(origin_pixel) + image->stride());
130 } 144 }
131 } 145 }
132 } 146 }
133 147
134 void GradientFill(pp::Instance* instance, 148 void GradientFill(pp::Instance* instance,
135 pp::ImageData* image, 149 pp::ImageData* image,
136 const pp::Rect& dirty_rc, 150 const pp::Rect& dirty_rc,
137 const pp::Rect& gradient_rc, 151 const pp::Rect& gradient_rc,
138 uint32 start_color, 152 uint32_t start_color,
139 uint32 end_color, 153 uint32_t end_color,
140 bool horizontal, 154 bool horizontal,
141 uint8 transparency) { 155 uint8_t transparency) {
142 pp::Rect draw_rc = gradient_rc.Intersect(dirty_rc); 156 pp::Rect draw_rc = gradient_rc.Intersect(dirty_rc);
143 if (draw_rc.IsEmpty()) 157 if (draw_rc.IsEmpty())
144 return; 158 return;
145 159
146 pp::ImageData gradient(instance, PP_IMAGEDATAFORMAT_BGRA_PREMUL, 160 pp::ImageData gradient(instance, PP_IMAGEDATAFORMAT_BGRA_PREMUL,
147 gradient_rc.size(), false); 161 gradient_rc.size(), false);
148 162
149 GradientFill(&gradient, pp::Rect(pp::Point(), gradient_rc.size()), 163 GradientFill(&gradient, pp::Rect(pp::Point(), gradient_rc.size()),
150 start_color, end_color, horizontal); 164 start_color, end_color, horizontal);
151 165
(...skipping 16 matching lines...) Expand all
168 const uint32_t* src_origin_pixel = src.GetAddr32(src_rc.point()); 182 const uint32_t* src_origin_pixel = src.GetAddr32(src_rc.point());
169 uint32_t* dest_origin_pixel = dest->GetAddr32(dest_rc.point()); 183 uint32_t* dest_origin_pixel = dest->GetAddr32(dest_rc.point());
170 if (stretch) { 184 if (stretch) {
171 double x_ratio = static_cast<double>(src_rc.width()) / dest_rc.width(); 185 double x_ratio = static_cast<double>(src_rc.width()) / dest_rc.width();
172 double y_ratio = static_cast<double>(src_rc.height()) / dest_rc.height(); 186 double y_ratio = static_cast<double>(src_rc.height()) / dest_rc.height();
173 int32_t height = dest_rc.height(); 187 int32_t height = dest_rc.height();
174 int32_t width = dest_rc.width(); 188 int32_t width = dest_rc.width();
175 for (int32_t y = 0; y < height; ++y) { 189 for (int32_t y = 0; y < height; ++y) {
176 uint32_t* dest_pixel = dest_origin_pixel; 190 uint32_t* dest_pixel = dest_origin_pixel;
177 for (int32_t x = 0; x < width; ++x) { 191 for (int32_t x = 0; x < width; ++x) {
178 uint32 src_x = static_cast<uint32>(x * x_ratio); 192 uint32_t src_x = static_cast<uint32_t>(x * x_ratio);
179 uint32 src_y = static_cast<uint32>(y * y_ratio); 193 uint32_t src_y = static_cast<uint32_t>(y * y_ratio);
180 const uint32_t* src_pixel = src.GetAddr32( 194 const uint32_t* src_pixel = src.GetAddr32(
181 pp::Point(src_rc.x() + src_x, src_rc.y() + src_y)); 195 pp::Point(src_rc.x() + src_x, src_rc.y() + src_y));
182 *dest_pixel = *src_pixel; 196 *dest_pixel = *src_pixel;
183 dest_pixel++; 197 dest_pixel++;
184 } 198 }
185 dest_origin_pixel = reinterpret_cast<uint32_t*>( 199 dest_origin_pixel = reinterpret_cast<uint32_t*>(
186 reinterpret_cast<char*>(dest_origin_pixel) + dest->stride()); 200 reinterpret_cast<char*>(dest_origin_pixel) + dest->stride());
187 } 201 }
188 } else { 202 } else {
189 int32_t height = src_rc.height(); 203 int32_t height = src_rc.height();
190 base::CheckedNumeric<int32_t> width_bytes = src_rc.width(); 204 base::CheckedNumeric<int32_t> width_bytes = src_rc.width();
191 width_bytes *= 4; 205 width_bytes *= 4;
192 for (int32_t y = 0; y < height; ++y) { 206 for (int32_t y = 0; y < height; ++y) {
193 memcpy(dest_origin_pixel, src_origin_pixel, width_bytes.ValueOrDie()); 207 memcpy(dest_origin_pixel, src_origin_pixel, width_bytes.ValueOrDie());
194 src_origin_pixel = reinterpret_cast<const uint32_t*>( 208 src_origin_pixel = reinterpret_cast<const uint32_t*>(
195 reinterpret_cast<const char*>(src_origin_pixel) + src.stride()); 209 reinterpret_cast<const char*>(src_origin_pixel) + src.stride());
196 dest_origin_pixel = reinterpret_cast<uint32_t*>( 210 dest_origin_pixel = reinterpret_cast<uint32_t*>(
197 reinterpret_cast<char*>(dest_origin_pixel) + dest->stride()); 211 reinterpret_cast<char*>(dest_origin_pixel) + dest->stride());
198 } 212 }
199 } 213 }
200 } 214 }
201 215
202 void FillRect(pp::ImageData* image, const pp::Rect& rc, uint32 color) { 216 void FillRect(pp::ImageData* image, const pp::Rect& rc, uint32_t color) {
203 int height = rc.height(); 217 int height = rc.height();
204 if (height == 0) 218 if (height == 0)
205 return; 219 return;
206 220
207 // Fill in first row. 221 // Fill in first row.
208 uint32_t* top_line = image->GetAddr32(rc.point()); 222 uint32_t* top_line = image->GetAddr32(rc.point());
209 int width = rc.width(); 223 int width = rc.width();
210 for (int x = 0; x < width; x++) 224 for (int x = 0; x < width; x++)
211 top_line[x] = color; 225 top_line[x] = color;
212 226
213 // Fill in the rest of the rectangle. 227 // Fill in the rest of the rectangle.
214 int byte_width = width * 4; 228 int byte_width = width * 4;
215 uint32_t* cur_line = reinterpret_cast<uint32_t*>( 229 uint32_t* cur_line = reinterpret_cast<uint32_t*>(
216 reinterpret_cast<char*>(top_line) + image->stride()); 230 reinterpret_cast<char*>(top_line) + image->stride());
217 for (int y = 1; y < height; y++) { 231 for (int y = 1; y < height; y++) {
218 memcpy(cur_line, top_line, byte_width); 232 memcpy(cur_line, top_line, byte_width);
219 cur_line = reinterpret_cast<uint32_t*>( 233 cur_line = reinterpret_cast<uint32_t*>(
220 reinterpret_cast<char*>(cur_line) + image->stride()); 234 reinterpret_cast<char*>(cur_line) + image->stride());
221 } 235 }
222 } 236 }
223 237
224 ShadowMatrix::ShadowMatrix(uint32 depth, double factor, uint32 background) 238 ShadowMatrix::ShadowMatrix(uint32_t depth, double factor, uint32_t background)
225 : depth_(depth), factor_(factor), background_(background) { 239 : depth_(depth), factor_(factor), background_(background) {
226 DCHECK(depth_ > 0); 240 DCHECK(depth_ > 0);
227 matrix_.resize(depth_ * depth_); 241 matrix_.resize(depth_ * depth_);
228 242
229 // pv - is a rounding power factor for smoothing corners. 243 // pv - is a rounding power factor for smoothing corners.
230 // pv = 2.0 will make corners completely round. 244 // pv = 2.0 will make corners completely round.
231 const double pv = 4.0; 245 const double pv = 4.0;
232 // pow_pv - cache to avoid recalculating pow(x, pv) every time. 246 // pow_pv - cache to avoid recalculating pow(x, pv) every time.
233 std::vector<double> pow_pv(depth_, 0.0); 247 std::vector<double> pow_pv(depth_, 0.0);
234 248
235 double r = static_cast<double>(depth_); 249 double r = static_cast<double>(depth_);
236 double coef = 256.0 / pow(r, factor); 250 double coef = 256.0 / pow(r, factor);
237 251
238 for (uint32 y = 0; y < depth_; y++) { 252 for (uint32_t y = 0; y < depth_; y++) {
239 // Since matrix is symmetrical, we can reduce the number of calculations 253 // Since matrix is symmetrical, we can reduce the number of calculations
240 // by mirroring results. 254 // by mirroring results.
241 for (uint32 x = 0; x <= y; x++) { 255 for (uint32_t x = 0; x <= y; x++) {
242 // Fill cache if needed. 256 // Fill cache if needed.
243 if (pow_pv[x] == 0.0) 257 if (pow_pv[x] == 0.0)
244 pow_pv[x] = pow(x, pv); 258 pow_pv[x] = pow(x, pv);
245 if (pow_pv[y] == 0.0) 259 if (pow_pv[y] == 0.0)
246 pow_pv[y] = pow(y, pv); 260 pow_pv[y] = pow(y, pv);
247 261
248 // v - is a value for the smoothing function. 262 // v - is a value for the smoothing function.
249 // If x == 0 simplify calculations. 263 // If x == 0 simplify calculations.
250 double v = (x == 0) ? y : pow(pow_pv[x] + pow_pv[y], 1 / pv); 264 double v = (x == 0) ? y : pow(pow_pv[x] + pow_pv[y], 1 / pv);
251 265
252 // Smoothing function. 266 // Smoothing function.
253 // If factor == 1, smoothing will be linear from 0 to the end, 267 // If factor == 1, smoothing will be linear from 0 to the end,
254 // if 0 < factor < 1, smoothing will drop faster near 0. 268 // if 0 < factor < 1, smoothing will drop faster near 0.
255 // if factor > 1, smoothing will drop faster near the end (depth). 269 // if factor > 1, smoothing will drop faster near the end (depth).
256 double f = 256.0 - coef * pow(v, factor); 270 double f = 256.0 - coef * pow(v, factor);
257 271
258 uint8 alpha = 0; 272 uint8_t alpha = 0;
259 if (f > kOpaqueAlpha) 273 if (f > kOpaqueAlpha)
260 alpha = kOpaqueAlpha; 274 alpha = kOpaqueAlpha;
261 else if (f < kTransparentAlpha) 275 else if (f < kTransparentAlpha)
262 alpha = kTransparentAlpha; 276 alpha = kTransparentAlpha;
263 else 277 else
264 alpha = static_cast<uint8>(f); 278 alpha = static_cast<uint8_t>(f);
265 279
266 uint8 red = ProcessColor(0, GetRed(background), alpha); 280 uint8_t red = ProcessColor(0, GetRed(background), alpha);
267 uint8 green = ProcessColor(0, GetGreen(background), alpha); 281 uint8_t green = ProcessColor(0, GetGreen(background), alpha);
268 uint8 blue = ProcessColor(0, GetBlue(background), alpha); 282 uint8_t blue = ProcessColor(0, GetBlue(background), alpha);
269 uint32 pixel = MakePixel(red, green, blue, GetAlpha(background)); 283 uint32_t pixel = MakePixel(red, green, blue, GetAlpha(background));
270 284
271 // Mirror matrix. 285 // Mirror matrix.
272 matrix_[y * depth_ + x] = pixel; 286 matrix_[y * depth_ + x] = pixel;
273 matrix_[x * depth_ + y] = pixel; 287 matrix_[x * depth_ + y] = pixel;
274 } 288 }
275 } 289 }
276 } 290 }
277 291
278 ShadowMatrix::~ShadowMatrix() { 292 ShadowMatrix::~ShadowMatrix() {
279 } 293 }
280 294
281 void PaintShadow(pp::ImageData* image, 295 void PaintShadow(pp::ImageData* image,
282 const pp::Rect& clip_rc, 296 const pp::Rect& clip_rc,
283 const pp::Rect& shadow_rc, 297 const pp::Rect& shadow_rc,
284 const ShadowMatrix& matrix) { 298 const ShadowMatrix& matrix) {
285 pp::Rect draw_rc = shadow_rc.Intersect(clip_rc); 299 pp::Rect draw_rc = shadow_rc.Intersect(clip_rc);
286 if (draw_rc.IsEmpty()) 300 if (draw_rc.IsEmpty())
287 return; 301 return;
288 302
289 int32 depth = static_cast<int32>(matrix.depth()); 303 int32_t depth = static_cast<int32_t>(matrix.depth());
290 for (int32_t y = draw_rc.y(); y < draw_rc.bottom(); y++) { 304 for (int32_t y = draw_rc.y(); y < draw_rc.bottom(); y++) {
291 for (int32_t x = draw_rc.x(); x < draw_rc.right(); x++) { 305 for (int32_t x = draw_rc.x(); x < draw_rc.right(); x++) {
292 int32_t matrix_x = std::max(depth + shadow_rc.x() - x - 1, 306 int32_t matrix_x = std::max(depth + shadow_rc.x() - x - 1,
293 depth - shadow_rc.right() + x); 307 depth - shadow_rc.right() + x);
294 int32_t matrix_y = std::max(depth + shadow_rc.y() - y - 1, 308 int32_t matrix_y = std::max(depth + shadow_rc.y() - y - 1,
295 depth - shadow_rc.bottom() + y); 309 depth - shadow_rc.bottom() + y);
296 uint32_t* pixel = image->GetAddr32(pp::Point(x, y)); 310 uint32_t* pixel = image->GetAddr32(pp::Point(x, y));
297 311
298 if (matrix_x < 0) 312 if (matrix_x < 0)
299 matrix_x = 0; 313 matrix_x = 0;
300 else if (matrix_x >= static_cast<int32>(depth)) 314 else if (matrix_x >= static_cast<int32_t>(depth))
301 matrix_x = depth - 1; 315 matrix_x = depth - 1;
302 316
303 if (matrix_y < 0) 317 if (matrix_y < 0)
304 matrix_y = 0; 318 matrix_y = 0;
305 else if (matrix_y >= static_cast<int32>(depth)) 319 else if (matrix_y >= static_cast<int32_t>(depth))
306 matrix_y = depth - 1; 320 matrix_y = depth - 1;
307 321
308 *pixel = matrix.GetValue(matrix_x, matrix_y); 322 *pixel = matrix.GetValue(matrix_x, matrix_y);
309 } 323 }
310 } 324 }
311 } 325 }
312 326
313 void DrawShadow(pp::ImageData* image, 327 void DrawShadow(pp::ImageData* image,
314 const pp::Rect& shadow_rc, 328 const pp::Rect& shadow_rc,
315 const pp::Rect& object_rc, 329 const pp::Rect& object_rc,
(...skipping 18 matching lines...) Expand all
334 PaintShadow(image, rc.Intersect(clip_rc), shadow_rc, matrix); 348 PaintShadow(image, rc.Intersect(clip_rc), shadow_rc, matrix);
335 349
336 // Fill right part. 350 // Fill right part.
337 rc = pp::Rect(object_rc.right(), object_rc.y(), 351 rc = pp::Rect(object_rc.right(), object_rc.y(),
338 shadow_rc.right() - object_rc.right(), object_rc.height()); 352 shadow_rc.right() - object_rc.right(), object_rc.height());
339 PaintShadow(image, rc.Intersect(clip_rc), shadow_rc, matrix); 353 PaintShadow(image, rc.Intersect(clip_rc), shadow_rc, matrix);
340 } 354 }
341 355
342 } // namespace chrome_pdf 356 } // namespace chrome_pdf
343 357
OLDNEW
« no previous file with comments | « pdf/draw_utils.h ('k') | pdf/out_of_process_instance.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698