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/browser/renderer_host/backing_store_aura.h" | 5 #include "content/browser/renderer_host/backing_store_aura.h" |
6 | 6 |
7 #include "content/browser/renderer_host/dip_util.h" | 7 #include "content/browser/renderer_host/dip_util.h" |
8 #include "content/browser/renderer_host/render_process_host_impl.h" | 8 #include "content/browser/renderer_host/render_process_host_impl.h" |
9 #include "content/public/browser/render_widget_host.h" | 9 #include "content/public/browser/render_widget_host.h" |
10 #include "skia/ext/platform_canvas.h" | 10 #include "skia/ext/platform_canvas.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 // with signed numbers. If the maximum value is 2**31, then 2**31 / 4 = | 31 // with signed numbers. If the maximum value is 2**31, then 2**31 / 4 = |
32 // 2**29 and floor(sqrt(2**29)) = 23170. | 32 // 2**29 and floor(sqrt(2**29)) = 23170. |
33 | 33 |
34 // Max height and width for layers | 34 // Max height and width for layers |
35 static const int kMaxVideoLayerSize = 23170; | 35 static const int kMaxVideoLayerSize = 23170; |
36 | 36 |
37 BackingStoreAura::BackingStoreAura(RenderWidgetHost* widget, | 37 BackingStoreAura::BackingStoreAura(RenderWidgetHost* widget, |
38 const gfx::Size& size) | 38 const gfx::Size& size) |
39 : BackingStore(widget, size) { | 39 : BackingStore(widget, size) { |
40 device_scale_factor_ = | 40 device_scale_factor_ = |
41 ui::GetScaleFactorScale(GetScaleFactorForView(widget->GetView())); | 41 ui::GetImageScale(GetScaleFactorForView(widget->GetView())); |
42 gfx::Size pixel_size = ToPixelSize(size, device_scale_factor_); | 42 gfx::Size pixel_size = ToPixelSize(size, device_scale_factor_); |
43 bitmap_.setConfig(SkBitmap::kARGB_8888_Config, | 43 bitmap_.setConfig(SkBitmap::kARGB_8888_Config, |
44 pixel_size.width(), pixel_size.height()); | 44 pixel_size.width(), pixel_size.height()); |
45 bitmap_.allocPixels(); | 45 bitmap_.allocPixels(); |
46 canvas_.reset(new SkCanvas(bitmap_)); | 46 canvas_.reset(new SkCanvas(bitmap_)); |
47 } | 47 } |
48 | 48 |
49 BackingStoreAura::~BackingStoreAura() { | 49 BackingStoreAura::~BackingStoreAura() { |
50 } | 50 } |
51 | 51 |
52 void BackingStoreAura::SkiaShowRect(const gfx::Point& point, | 52 void BackingStoreAura::SkiaShowRect(const gfx::Point& point, |
53 gfx::Canvas* canvas) { | 53 gfx::Canvas* canvas) { |
54 gfx::ImageSkia image = gfx::ImageSkia(gfx::ImageSkiaRep(bitmap_, | 54 gfx::ImageSkia image = gfx::ImageSkia(gfx::ImageSkiaRep(bitmap_, |
55 ui::GetScaleFactorFromScale(device_scale_factor_))); | 55 device_scale_factor_)); |
56 canvas->DrawImageInt(image, point.x(), point.y()); | 56 canvas->DrawImageInt(image, point.x(), point.y()); |
57 } | 57 } |
58 | 58 |
59 void BackingStoreAura::ScaleFactorChanged(float device_scale_factor) { | 59 void BackingStoreAura::ScaleFactorChanged(float device_scale_factor) { |
60 if (device_scale_factor == device_scale_factor_) | 60 if (device_scale_factor == device_scale_factor_) |
61 return; | 61 return; |
62 | 62 |
63 gfx::Size old_pixel_size = ToPixelSize(size(), device_scale_factor_); | 63 gfx::Size old_pixel_size = ToPixelSize(size(), device_scale_factor_); |
64 device_scale_factor_ = device_scale_factor; | 64 device_scale_factor_ = device_scale_factor; |
65 | 65 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 | 167 |
168 SkIRect skrect = SkIRect::MakeXYWH(rect.x(), rect.y(), width, height); | 168 SkIRect skrect = SkIRect::MakeXYWH(rect.x(), rect.y(), width, height); |
169 SkBitmap b; | 169 SkBitmap b; |
170 if (!canvas_->readPixels(skrect, &b)) | 170 if (!canvas_->readPixels(skrect, &b)) |
171 return false; | 171 return false; |
172 SkCanvas(output->GetBitmap()).writePixels(b, rect.x(), rect.y()); | 172 SkCanvas(output->GetBitmap()).writePixels(b, rect.x(), rect.y()); |
173 return true; | 173 return true; |
174 } | 174 } |
175 | 175 |
176 } // namespace content | 176 } // namespace content |
OLD | NEW |