OLD | NEW |
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/gfx/rect_conversions.h" | 9 #include "ui/gfx/rect_conversions.h" |
| 10 #include "ui/gfx/size_conversions.h" |
10 #include "ui/surface/transport_dib.h" | 11 #include "ui/surface/transport_dib.h" |
11 | 12 |
12 namespace content { | 13 namespace content { |
13 | 14 |
14 // Max height and width for layers | 15 // Max height and width for layers |
15 static const int kMaxSize = 23170; | 16 static const int kMaxSize = 23170; |
16 | 17 |
17 BrowserPluginBackingStore::BrowserPluginBackingStore( | 18 BrowserPluginBackingStore::BrowserPluginBackingStore( |
18 const gfx::Size& size, | 19 const gfx::Size& size, |
19 float scale_factor) | 20 float scale_factor) |
20 : size_(size), | 21 : size_(size), |
21 scale_factor_(scale_factor) { | 22 scale_factor_(scale_factor) { |
22 gfx::Size pixel_size = size.Scale(scale_factor); | 23 gfx::Size pixel_size = gfx::ToFlooredSize(size.Scale(scale_factor)); |
23 bitmap_.setConfig(SkBitmap::kARGB_8888_Config, | 24 bitmap_.setConfig(SkBitmap::kARGB_8888_Config, |
24 pixel_size.width(), pixel_size.height()); | 25 pixel_size.width(), pixel_size.height()); |
25 bitmap_.allocPixels(); | 26 bitmap_.allocPixels(); |
26 canvas_.reset(new SkCanvas(bitmap_)); | 27 canvas_.reset(new SkCanvas(bitmap_)); |
27 } | 28 } |
28 | 29 |
29 BrowserPluginBackingStore::~BrowserPluginBackingStore() { | 30 BrowserPluginBackingStore::~BrowserPluginBackingStore() { |
30 } | 31 } |
31 | 32 |
32 void BrowserPluginBackingStore::PaintToBackingStore( | 33 void BrowserPluginBackingStore::PaintToBackingStore( |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 | 85 |
85 int x = std::min(pixel_rect.x(), pixel_rect.x() - pixel_dx); | 86 int x = std::min(pixel_rect.x(), pixel_rect.x() - pixel_dx); |
86 int y = std::min(pixel_rect.y(), pixel_rect.y() - pixel_dy); | 87 int y = std::min(pixel_rect.y(), pixel_rect.y() - pixel_dy); |
87 int w = pixel_rect.width() + abs(pixel_dx); | 88 int w = pixel_rect.width() + abs(pixel_dx); |
88 int h = pixel_rect.height() + abs(pixel_dy); | 89 int h = pixel_rect.height() + abs(pixel_dy); |
89 SkIRect rect = SkIRect::MakeXYWH(x, y, w, h); | 90 SkIRect rect = SkIRect::MakeXYWH(x, y, w, h); |
90 bitmap_.scrollRect(&rect, pixel_dx, pixel_dy); | 91 bitmap_.scrollRect(&rect, pixel_dx, pixel_dy); |
91 } | 92 } |
92 | 93 |
93 } // namespace content | 94 } // namespace content |
OLD | NEW |