Chromium Code Reviews| 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 gfx::Rect src_subrect, | |
|
powei
2014/02/22 02:06:32
Can you add a dcheck to make sure that src_subrect
clholgat
2014/02/24 17:15:56
Done.
| |
| 256 gfx::Size* out_size, | 257 gfx::Size* out_size, |
| 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 if (src_subrect.IsEmpty()) |
| 266 src_subrect = gfx::Rect(bounds); | |
| 265 const gfx::Display& display = | 267 const gfx::Display& display = |
| 266 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); | 268 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); |
| 267 float device_scale_factor = display.device_scale_factor(); | 269 float device_scale_factor = display.device_scale_factor(); |
| 268 DCHECK_GT(device_scale_factor, 0); | 270 DCHECK_GT(device_scale_factor, 0); |
| 269 gfx::Size dst_size( | 271 gfx::Size dst_size( |
| 270 gfx::ToCeiledSize(gfx::ScaleSize(bounds, scale / device_scale_factor))); | 272 gfx::ToCeiledSize(gfx::ScaleSize(bounds, scale / device_scale_factor))); |
| 271 *out_size = dst_size; | 273 *out_size = dst_size; |
| 272 CopyFromCompositingSurface( | 274 CopyFromCompositingSurface( |
| 273 src_subrect, dst_size, result_callback, SkBitmap::kARGB_8888_Config); | 275 src_subrect, dst_size, result_callback, SkBitmap::kARGB_8888_Config); |
| 274 } | 276 } |
| (...skipping 1223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1498 // RenderWidgetHostView, public: | 1500 // RenderWidgetHostView, public: |
| 1499 | 1501 |
| 1500 // static | 1502 // static |
| 1501 RenderWidgetHostView* | 1503 RenderWidgetHostView* |
| 1502 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) { | 1504 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) { |
| 1503 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget); | 1505 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget); |
| 1504 return new RenderWidgetHostViewAndroid(rwhi, NULL); | 1506 return new RenderWidgetHostViewAndroid(rwhi, NULL); |
| 1505 } | 1507 } |
| 1506 | 1508 |
| 1507 } // namespace content | 1509 } // namespace content |
| OLD | NEW |