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

Side by Side Diff: content/renderer/browser_plugin/browser_plugin_backing_store.cc

Issue 10996037: Do not convert from RectF to Rect by flooring. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/renderer/browser_plugin/browser_plugin_backing_store.h" 5 #include "content/renderer/browser_plugin/browser_plugin_backing_store.h"
6 6
7 #include "ui/gfx/canvas.h" 7 #include "ui/gfx/canvas.h"
8 #include "ui/gfx/rect.h" 8 #include "ui/gfx/rect.h"
9 #include "ui/surface/transport_dib.h" 9 #include "ui/surface/transport_dib.h"
10 10
(...skipping 17 matching lines...) Expand all
28 BrowserPluginBackingStore::~BrowserPluginBackingStore() { 28 BrowserPluginBackingStore::~BrowserPluginBackingStore() {
29 } 29 }
30 30
31 void BrowserPluginBackingStore::PaintToBackingStore( 31 void BrowserPluginBackingStore::PaintToBackingStore(
32 const gfx::Rect& bitmap_rect, 32 const gfx::Rect& bitmap_rect,
33 const std::vector<gfx::Rect>& copy_rects, 33 const std::vector<gfx::Rect>& copy_rects,
34 TransportDIB* dib) { 34 TransportDIB* dib) {
35 if (bitmap_rect.IsEmpty()) 35 if (bitmap_rect.IsEmpty())
36 return; 36 return;
37 37
38 gfx::Rect pixel_bitmap_rect = bitmap_rect.Scale(scale_factor_); 38 gfx::Rect pixel_bitmap_rect = bitmap_rect.ScaleUnsafe(scale_factor_);
39 39
40 const int width = pixel_bitmap_rect.width(); 40 const int width = pixel_bitmap_rect.width();
41 const int height = pixel_bitmap_rect.height(); 41 const int height = pixel_bitmap_rect.height();
42 42
43 if (width <= 0 || width > kMaxSize || 43 if (width <= 0 || width > kMaxSize ||
44 height <= 0 || height > kMaxSize) 44 height <= 0 || height > kMaxSize)
45 return; 45 return;
46 46
47 if (!dib) 47 if (!dib)
48 return; 48 return;
49 49
50 SkPaint copy_paint; 50 SkPaint copy_paint;
51 copy_paint.setXfermodeMode(SkXfermode::kSrc_Mode); 51 copy_paint.setXfermodeMode(SkXfermode::kSrc_Mode);
52 52
53 SkBitmap sk_bitmap; 53 SkBitmap sk_bitmap;
54 sk_bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height); 54 sk_bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
55 sk_bitmap.setPixels(dib->memory()); 55 sk_bitmap.setPixels(dib->memory());
56 for (size_t i = 0; i < copy_rects.size(); i++) { 56 for (size_t i = 0; i < copy_rects.size(); i++) {
57 const gfx::Rect& pixel_copy_rect = copy_rects[i].Scale(scale_factor_); 57 const gfx::Rect& pixel_copy_rect = copy_rects[i].ScaleUnsafe(scale_factor_);
58 int x = pixel_copy_rect.x() - pixel_bitmap_rect.x(); 58 int x = pixel_copy_rect.x() - pixel_bitmap_rect.x();
59 int y = pixel_copy_rect.y() - pixel_bitmap_rect.y(); 59 int y = pixel_copy_rect.y() - pixel_bitmap_rect.y();
60 SkIRect srcrect = SkIRect::MakeXYWH(x, y, 60 SkIRect srcrect = SkIRect::MakeXYWH(x, y,
61 pixel_copy_rect.width(), 61 pixel_copy_rect.width(),
62 pixel_copy_rect.height()); 62 pixel_copy_rect.height());
63 63
64 SkRect dstrect = SkRect::MakeXYWH( 64 SkRect dstrect = SkRect::MakeXYWH(
65 SkIntToScalar(pixel_copy_rect.x()), 65 SkIntToScalar(pixel_copy_rect.x()),
66 SkIntToScalar(pixel_copy_rect.y()), 66 SkIntToScalar(pixel_copy_rect.y()),
67 SkIntToScalar(pixel_copy_rect.width()), 67 SkIntToScalar(pixel_copy_rect.width()),
68 SkIntToScalar(pixel_copy_rect.height())); 68 SkIntToScalar(pixel_copy_rect.height()));
69 canvas_.get()->drawBitmapRect(sk_bitmap, &srcrect, dstrect, &copy_paint); 69 canvas_.get()->drawBitmapRect(sk_bitmap, &srcrect, dstrect, &copy_paint);
70 } 70 }
71 } 71 }
72 72
73 void BrowserPluginBackingStore::ScrollBackingStore( 73 void BrowserPluginBackingStore::ScrollBackingStore(
74 int dx, 74 int dx,
75 int dy, 75 int dy,
76 const gfx::Rect& clip_rect, 76 const gfx::Rect& clip_rect,
77 const gfx::Size& view_size) { 77 const gfx::Size& view_size) {
78 gfx::Rect pixel_rect = clip_rect.Scale(scale_factor_); 78 gfx::Rect pixel_rect = clip_rect.ScaleUnsafe(scale_factor_);
79 int pixel_dx = dx * scale_factor_; 79 int pixel_dx = dx * scale_factor_;
80 int pixel_dy = dy * scale_factor_; 80 int pixel_dy = dy * scale_factor_;
81 81
82 int x = std::min(pixel_rect.x(), pixel_rect.x() - pixel_dx); 82 int x = std::min(pixel_rect.x(), pixel_rect.x() - pixel_dx);
83 int y = std::min(pixel_rect.y(), pixel_rect.y() - pixel_dy); 83 int y = std::min(pixel_rect.y(), pixel_rect.y() - pixel_dy);
84 int w = pixel_rect.width() + abs(pixel_dx); 84 int w = pixel_rect.width() + abs(pixel_dx);
85 int h = pixel_rect.height() + abs(pixel_dy); 85 int h = pixel_rect.height() + abs(pixel_dy);
86 SkIRect rect = SkIRect::MakeXYWH(x, y, w, h); 86 SkIRect rect = SkIRect::MakeXYWH(x, y, w, h);
87 bitmap_.scrollRect(&rect, pixel_dx, pixel_dy); 87 bitmap_.scrollRect(&rect, pixel_dx, pixel_dy);
88 } 88 }
89 89
90 } // namespace content 90 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698