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/render_widget_host_view_android.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
6 | 6 |
7 #include <android/bitmap.h> | 7 #include <android/bitmap.h> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 default_size_ = size; | 246 default_size_ = size; |
247 WasResized(); | 247 WasResized(); |
248 } | 248 } |
249 | 249 |
250 void RenderWidgetHostViewAndroid::SetBounds(const gfx::Rect& rect) { | 250 void RenderWidgetHostViewAndroid::SetBounds(const gfx::Rect& rect) { |
251 SetSize(rect.size()); | 251 SetSize(rect.size()); |
252 } | 252 } |
253 | 253 |
254 void RenderWidgetHostViewAndroid::GetScaledContentBitmap( | 254 void RenderWidgetHostViewAndroid::GetScaledContentBitmap( |
255 float scale, | 255 float scale, |
| 256 SkBitmap::Config bitmap_config, |
256 const base::Callback<void(bool, const SkBitmap&)>& result_callback) { | 257 const base::Callback<void(bool, const SkBitmap&)>& result_callback) { |
257 if (!IsSurfaceAvailableForCopy()) { | 258 if (!IsSurfaceAvailableForCopy()) { |
258 result_callback.Run(false, SkBitmap()); | 259 result_callback.Run(false, SkBitmap()); |
259 return; | 260 return; |
260 } | 261 } |
261 | 262 |
262 gfx::Size bounds = layer_->bounds(); | 263 gfx::Size bounds = layer_->bounds(); |
263 gfx::Rect src_subrect(bounds); | 264 gfx::Rect src_subrect(bounds); |
264 const gfx::Display& display = | 265 const gfx::Display& display = |
265 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); | 266 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); |
266 float device_scale_factor = display.device_scale_factor(); | 267 float device_scale_factor = display.device_scale_factor(); |
267 DCHECK_GT(device_scale_factor, 0); | 268 DCHECK_GT(device_scale_factor, 0); |
268 gfx::Size dst_size( | 269 gfx::Size dst_size( |
269 gfx::ToCeiledSize(gfx::ScaleSize(bounds, scale / device_scale_factor))); | 270 gfx::ToCeiledSize(gfx::ScaleSize(bounds, scale / device_scale_factor))); |
270 CopyFromCompositingSurface( | 271 CopyFromCompositingSurface( |
271 src_subrect, dst_size, result_callback, SkBitmap::kARGB_8888_Config); | 272 src_subrect, dst_size, result_callback, bitmap_config); |
272 } | 273 } |
273 | 274 |
274 bool RenderWidgetHostViewAndroid::PopulateBitmapWithContents(jobject jbitmap) { | 275 bool RenderWidgetHostViewAndroid::PopulateBitmapWithContents(jobject jbitmap) { |
275 if (!CompositorImpl::IsInitialized() || | 276 if (!CompositorImpl::IsInitialized() || |
276 texture_id_in_layer_ == 0 || | 277 texture_id_in_layer_ == 0 || |
277 texture_size_in_layer_.IsEmpty()) | 278 texture_size_in_layer_.IsEmpty()) |
278 return false; | 279 return false; |
279 | 280 |
280 gfx::JavaBitmap bitmap(jbitmap); | 281 gfx::JavaBitmap bitmap(jbitmap); |
281 | 282 |
(...skipping 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1439 // RenderWidgetHostView, public: | 1440 // RenderWidgetHostView, public: |
1440 | 1441 |
1441 // static | 1442 // static |
1442 RenderWidgetHostView* | 1443 RenderWidgetHostView* |
1443 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) { | 1444 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) { |
1444 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget); | 1445 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget); |
1445 return new RenderWidgetHostViewAndroid(rwhi, NULL); | 1446 return new RenderWidgetHostViewAndroid(rwhi, NULL); |
1446 } | 1447 } |
1447 | 1448 |
1448 } // namespace content | 1449 } // namespace content |
OLD | NEW |