| 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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 gfx::Size* out_size, | 256 gfx::Size* out_size, |
| 257 SkBitmap::Config bitmap_config, |
| 257 const base::Callback<void(bool, const SkBitmap&)>& result_callback) { | 258 const base::Callback<void(bool, const SkBitmap&)>& result_callback) { |
| 258 if (!IsSurfaceAvailableForCopy()) { | 259 if (!IsSurfaceAvailableForCopy()) { |
| 259 result_callback.Run(false, SkBitmap()); | 260 result_callback.Run(false, SkBitmap()); |
| 260 return; | 261 return; |
| 261 } | 262 } |
| 262 | 263 |
| 263 gfx::Size bounds = layer_->bounds(); | 264 gfx::Size bounds = layer_->bounds(); |
| 264 gfx::Rect src_subrect(bounds); | 265 gfx::Rect src_subrect(bounds); |
| 265 const gfx::Display& display = | 266 const gfx::Display& display = |
| 266 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); | 267 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); |
| 267 float device_scale_factor = display.device_scale_factor(); | 268 float device_scale_factor = display.device_scale_factor(); |
| 268 DCHECK_GT(device_scale_factor, 0); | 269 DCHECK_GT(device_scale_factor, 0); |
| 269 gfx::Size dst_size( | 270 gfx::Size dst_size( |
| 270 gfx::ToCeiledSize(gfx::ScaleSize(bounds, scale / device_scale_factor))); | 271 gfx::ToCeiledSize(gfx::ScaleSize(bounds, scale / device_scale_factor))); |
| 271 *out_size = dst_size; | 272 *out_size = dst_size; |
| 272 CopyFromCompositingSurface( | 273 CopyFromCompositingSurface( |
| 273 src_subrect, dst_size, result_callback, SkBitmap::kARGB_8888_Config); | 274 src_subrect, dst_size, result_callback, bitmap_config); |
| 274 } | 275 } |
| 275 | 276 |
| 276 bool RenderWidgetHostViewAndroid::PopulateBitmapWithContents(jobject jbitmap) { | 277 bool RenderWidgetHostViewAndroid::PopulateBitmapWithContents(jobject jbitmap) { |
| 277 if (!CompositorImpl::IsInitialized() || | 278 if (!CompositorImpl::IsInitialized() || |
| 278 texture_id_in_layer_ == 0 || | 279 texture_id_in_layer_ == 0 || |
| 279 texture_size_in_layer_.IsEmpty()) | 280 texture_size_in_layer_.IsEmpty()) |
| 280 return false; | 281 return false; |
| 281 | 282 |
| 282 gfx::JavaBitmap bitmap(jbitmap); | 283 gfx::JavaBitmap bitmap(jbitmap); |
| 283 | 284 |
| (...skipping 1214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1498 // RenderWidgetHostView, public: | 1499 // RenderWidgetHostView, public: |
| 1499 | 1500 |
| 1500 // static | 1501 // static |
| 1501 RenderWidgetHostView* | 1502 RenderWidgetHostView* |
| 1502 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) { | 1503 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) { |
| 1503 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget); | 1504 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget); |
| 1504 return new RenderWidgetHostViewAndroid(rwhi, NULL); | 1505 return new RenderWidgetHostViewAndroid(rwhi, NULL); |
| 1505 } | 1506 } |
| 1506 | 1507 |
| 1507 } // namespace content | 1508 } // namespace content |
| OLD | NEW |