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/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 264 gfx::Rect(bitmap.size()), | 264 gfx::Rect(bitmap.size()), |
| 265 static_cast<unsigned char*> (bitmap.pixels())); | 265 static_cast<unsigned char*> (bitmap.pixels())); |
| 266 | 266 |
| 267 WebKit::WebGraphicsContext3D* context = | 267 WebKit::WebGraphicsContext3D* context = |
| 268 ImageTransportFactoryAndroid::GetInstance()->GetContext3D(); | 268 ImageTransportFactoryAndroid::GetInstance()->GetContext3D(); |
| 269 context->deleteTexture(texture); | 269 context->deleteTexture(texture); |
| 270 | 270 |
| 271 return true; | 271 return true; |
| 272 } | 272 } |
| 273 | 273 |
| 274 bool RenderWidgetHostViewAndroid::PopulateBitmapWithContents( | |
|
no sievers
2013/08/05 21:46:44
Oh no... we are trying to deprecate any readbacks
| |
| 275 const gfx::Size& size, SkBitmap* bitmap) { | |
| 276 if (!CompositorImpl::IsInitialized() || | |
| 277 texture_id_in_layer_ == 0 || | |
| 278 texture_size_in_layer_.IsEmpty()) | |
| 279 return false; | |
| 280 | |
| 281 GLHelper* helper = ImageTransportFactoryAndroid::GetInstance()->GetGLHelper(); | |
| 282 | |
| 283 WebKit::WebGLId texture = helper->CopyAndScaleTexture( | |
| 284 texture_id_in_layer_, | |
| 285 texture_size_in_layer_, | |
| 286 size, | |
| 287 true, | |
| 288 GLHelper::SCALER_QUALITY_FAST); | |
| 289 if (texture == 0) | |
| 290 return false; | |
| 291 | |
| 292 helper->ReadbackTextureSync(texture, | |
| 293 gfx::Rect(size), | |
| 294 static_cast<unsigned char*> (bitmap->getPixels())) ; | |
| 295 | |
| 296 WebKit::WebGraphicsContext3D* context = | |
| 297 ImageTransportFactoryAndroid::GetInstance()->GetContext3D(); | |
| 298 context->deleteTexture(texture); | |
| 299 | |
| 300 return true; | |
| 301 } | |
| 302 | |
| 274 bool RenderWidgetHostViewAndroid::HasValidFrame() const { | 303 bool RenderWidgetHostViewAndroid::HasValidFrame() const { |
| 275 return texture_id_in_layer_ != 0 && | 304 return texture_id_in_layer_ != 0 && |
| 276 content_view_core_ && | 305 content_view_core_ && |
| 277 !texture_size_in_layer_.IsEmpty(); | 306 !texture_size_in_layer_.IsEmpty(); |
| 278 } | 307 } |
| 279 | 308 |
| 280 gfx::NativeView RenderWidgetHostViewAndroid::GetNativeView() const { | 309 gfx::NativeView RenderWidgetHostViewAndroid::GetNativeView() const { |
| 281 return content_view_core_->GetViewAndroid(); | 310 return content_view_core_->GetViewAndroid(); |
| 282 } | 311 } |
| 283 | 312 |
| (...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1159 // RenderWidgetHostView, public: | 1188 // RenderWidgetHostView, public: |
| 1160 | 1189 |
| 1161 // static | 1190 // static |
| 1162 RenderWidgetHostView* | 1191 RenderWidgetHostView* |
| 1163 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) { | 1192 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) { |
| 1164 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget); | 1193 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget); |
| 1165 return new RenderWidgetHostViewAndroid(rwhi, NULL); | 1194 return new RenderWidgetHostViewAndroid(rwhi, NULL); |
| 1166 } | 1195 } |
| 1167 | 1196 |
| 1168 } // namespace content | 1197 } // namespace content |
| OLD | NEW |