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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 | 139 |
140 int x = std::min(pixel_rect.x(), pixel_rect.x() - pixel_dx); | 140 int x = std::min(pixel_rect.x(), pixel_rect.x() - pixel_dx); |
141 int y = std::min(pixel_rect.y(), pixel_rect.y() - pixel_dy); | 141 int y = std::min(pixel_rect.y(), pixel_rect.y() - pixel_dy); |
142 int w = pixel_rect.width() + abs(pixel_dx); | 142 int w = pixel_rect.width() + abs(pixel_dx); |
143 int h = pixel_rect.height() + abs(pixel_dy); | 143 int h = pixel_rect.height() + abs(pixel_dy); |
144 SkIRect rect = SkIRect::MakeXYWH(x, y, w, h); | 144 SkIRect rect = SkIRect::MakeXYWH(x, y, w, h); |
145 bitmap_.scrollRect(&rect, pixel_dx, pixel_dy); | 145 bitmap_.scrollRect(&rect, pixel_dx, pixel_dy); |
146 } | 146 } |
147 | 147 |
148 bool BackingStoreAura::CopyFromBackingStore(const gfx::Rect& rect, | 148 bool BackingStoreAura::CopyFromBackingStore(const gfx::Rect& rect, |
149 skia::PlatformCanvas* output) { | 149 skia::PlatformBitmap* output) { |
150 const int width = | 150 const int width = |
151 std::min(size().width(), rect.width()) * device_scale_factor_; | 151 std::min(size().width(), rect.width()) * device_scale_factor_; |
152 const int height = | 152 const int height = |
153 std::min(size().height(), rect.height()) * device_scale_factor_; | 153 std::min(size().height(), rect.height()) * device_scale_factor_; |
154 if (!output->initialize(width, height, true)) | 154 if (!output->Allocate(width, height, true)) |
155 return false; | 155 return false; |
156 | 156 |
157 SkBitmap bitmap = skia::GetTopDevice(*output)->accessBitmap(true); | |
158 SkIRect skrect = SkIRect::MakeXYWH(rect.x(), rect.y(), width, height); | 157 SkIRect skrect = SkIRect::MakeXYWH(rect.x(), rect.y(), width, height); |
159 SkBitmap b; | 158 SkBitmap b; |
160 if (!canvas_->readPixels(skrect, &b)) | 159 if (!canvas_->readPixels(skrect, &b)) |
161 return false; | 160 return false; |
162 output->writePixels(b, rect.x(), rect.y()); | 161 SkCanvas(output->GetBitmap()).writePixels(b, rect.x(), rect.y()); |
163 return true; | 162 return true; |
164 } | 163 } |
165 | 164 |
166 } // namespace content | 165 } // namespace content |
OLD | NEW |