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

Side by Side Diff: pdf/draw_utils.cc

Issue 465133005: pdf: Early out from CopyImage if there's nothing to copy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
« 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 // 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 <algorithm> 7 #include <algorithm>
8 #include <math.h> 8 #include <math.h>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 139
140 pp::Rect copy_rc(draw_rc); 140 pp::Rect copy_rc(draw_rc);
141 copy_rc.Offset(-gradient_rc.x(), -gradient_rc.y()); 141 copy_rc.Offset(-gradient_rc.x(), -gradient_rc.y());
142 AlphaBlend(gradient, copy_rc, image, draw_rc.point(), transparency); 142 AlphaBlend(gradient, copy_rc, image, draw_rc.point(), transparency);
143 } 143 }
144 144
145 void CopyImage(const pp::ImageData& src, const pp::Rect& src_rc, 145 void CopyImage(const pp::ImageData& src, const pp::Rect& src_rc,
146 pp::ImageData* dest, const pp::Rect& dest_rc, 146 pp::ImageData* dest, const pp::Rect& dest_rc,
147 bool stretch) { 147 bool stretch) {
148 DCHECK(src_rc.width() <= dest_rc.width() && 148 DCHECK(src_rc.width() <= dest_rc.width() &&
149 src_rc.height() <= dest_rc.height()); 149 src_rc.height() <= dest_rc.height());
150 if (src_rc.IsEmpty())
151 return;
150 152
151 const uint32_t* src_origin_pixel = src.GetAddr32(src_rc.point()); 153 const uint32_t* src_origin_pixel = src.GetAddr32(src_rc.point());
152 uint32_t* dest_origin_pixel = dest->GetAddr32(dest_rc.point()); 154 uint32_t* dest_origin_pixel = dest->GetAddr32(dest_rc.point());
153 if (stretch) { 155 if (stretch) {
154 double x_ratio = static_cast<double>(src_rc.width()) / dest_rc.width(); 156 double x_ratio = static_cast<double>(src_rc.width()) / dest_rc.width();
155 double y_ratio = static_cast<double>(src_rc.height()) / dest_rc.height(); 157 double y_ratio = static_cast<double>(src_rc.height()) / dest_rc.height();
156 int32_t height = dest_rc.height(); 158 int32_t height = dest_rc.height();
157 int32_t width = dest_rc.width(); 159 int32_t width = dest_rc.width();
158 for (int32_t y = 0; y < height; ++y) { 160 for (int32_t y = 0; y < height; ++y) {
159 uint32_t* dest_pixel = dest_origin_pixel; 161 uint32_t* dest_pixel = dest_origin_pixel;
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 PaintShadow(image, rc.Intersect(clip_rc), shadow_rc, matrix); 319 PaintShadow(image, rc.Intersect(clip_rc), shadow_rc, matrix);
318 320
319 // Fill right part. 321 // Fill right part.
320 rc = pp::Rect(object_rc.right(), object_rc.y(), 322 rc = pp::Rect(object_rc.right(), object_rc.y(),
321 shadow_rc.right() - object_rc.right(), object_rc.height()); 323 shadow_rc.right() - object_rc.right(), object_rc.height());
322 PaintShadow(image, rc.Intersect(clip_rc), shadow_rc, matrix); 324 PaintShadow(image, rc.Intersect(clip_rc), shadow_rc, matrix);
323 } 325 }
324 326
325 } // namespace chrome_pdf 327 } // namespace chrome_pdf
326 328
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