| 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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 WasResized(); | 255 WasResized(); |
| 256 } | 256 } |
| 257 | 257 |
| 258 void RenderWidgetHostViewAndroid::SetBounds(const gfx::Rect& rect) { | 258 void RenderWidgetHostViewAndroid::SetBounds(const gfx::Rect& rect) { |
| 259 SetSize(rect.size()); | 259 SetSize(rect.size()); |
| 260 } | 260 } |
| 261 | 261 |
| 262 void RenderWidgetHostViewAndroid::GetScaledContentBitmap( | 262 void RenderWidgetHostViewAndroid::GetScaledContentBitmap( |
| 263 float scale, | 263 float scale, |
| 264 gfx::Size* out_size, | 264 gfx::Size* out_size, |
| 265 SkBitmap::Config bitmap_config, |
| 265 const base::Callback<void(bool, const SkBitmap&)>& result_callback) { | 266 const base::Callback<void(bool, const SkBitmap&)>& result_callback) { |
| 266 if (!IsSurfaceAvailableForCopy()) { | 267 if (!IsSurfaceAvailableForCopy()) { |
| 267 result_callback.Run(false, SkBitmap()); | 268 result_callback.Run(false, SkBitmap()); |
| 268 return; | 269 return; |
| 269 } | 270 } |
| 270 | 271 |
| 271 gfx::Size bounds = layer_->bounds(); | 272 gfx::Size bounds = layer_->bounds(); |
| 272 gfx::Rect src_subrect(bounds); | 273 gfx::Rect src_subrect(bounds); |
| 273 const gfx::Display& display = | 274 const gfx::Display& display = |
| 274 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); | 275 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); |
| 275 float device_scale_factor = display.device_scale_factor(); | 276 float device_scale_factor = display.device_scale_factor(); |
| 276 DCHECK_GT(device_scale_factor, 0); | 277 DCHECK_GT(device_scale_factor, 0); |
| 277 gfx::Size dst_size( | 278 gfx::Size dst_size( |
| 278 gfx::ToCeiledSize(gfx::ScaleSize(bounds, scale / device_scale_factor))); | 279 gfx::ToCeiledSize(gfx::ScaleSize(bounds, scale / device_scale_factor))); |
| 279 *out_size = dst_size; | 280 *out_size = dst_size; |
| 280 CopyFromCompositingSurface( | 281 CopyFromCompositingSurface( |
| 281 src_subrect, dst_size, result_callback, SkBitmap::kARGB_8888_Config); | 282 src_subrect, dst_size, result_callback, bitmap_config); |
| 282 } | 283 } |
| 283 | 284 |
| 284 bool RenderWidgetHostViewAndroid::PopulateBitmapWithContents(jobject jbitmap) { | 285 bool RenderWidgetHostViewAndroid::PopulateBitmapWithContents(jobject jbitmap) { |
| 285 if (!CompositorImpl::IsInitialized() || | 286 if (!CompositorImpl::IsInitialized() || |
| 286 texture_id_in_layer_ == 0 || | 287 texture_id_in_layer_ == 0 || |
| 287 texture_size_in_layer_.IsEmpty()) | 288 texture_size_in_layer_.IsEmpty()) |
| 288 return false; | 289 return false; |
| 289 | 290 |
| 290 gfx::JavaBitmap bitmap(jbitmap); | 291 gfx::JavaBitmap bitmap(jbitmap); |
| 291 | 292 |
| (...skipping 1214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1506 // RenderWidgetHostView, public: | 1507 // RenderWidgetHostView, public: |
| 1507 | 1508 |
| 1508 // static | 1509 // static |
| 1509 RenderWidgetHostView* | 1510 RenderWidgetHostView* |
| 1510 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) { | 1511 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) { |
| 1511 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget); | 1512 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget); |
| 1512 return new RenderWidgetHostViewAndroid(rwhi, NULL); | 1513 return new RenderWidgetHostViewAndroid(rwhi, NULL); |
| 1513 } | 1514 } |
| 1514 | 1515 |
| 1515 } // namespace content | 1516 } // namespace content |
| OLD | NEW |