Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(484)

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_android.cc

Issue 11194042: Implement TextureImageTransportSurface using texture mailbox (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/logging.h" 10 #include "base/logging.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 RenderWidgetHostImpl* widget_host, 50 RenderWidgetHostImpl* widget_host,
51 ContentViewCoreImpl* content_view_core) 51 ContentViewCoreImpl* content_view_core)
52 : host_(widget_host), 52 : host_(widget_host),
53 // ContentViewCoreImpl represents the native side of the Java 53 // ContentViewCoreImpl represents the native side of the Java
54 // ContentViewCore. It being NULL means that it is not attached to the 54 // ContentViewCore. It being NULL means that it is not attached to the
55 // View system yet, so we treat it as hidden. 55 // View system yet, so we treat it as hidden.
56 is_hidden_(!content_view_core), 56 is_hidden_(!content_view_core),
57 content_view_core_(NULL), 57 content_view_core_(NULL),
58 ime_adapter_android_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 58 ime_adapter_android_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
59 cached_background_color_(SK_ColorWHITE), 59 cached_background_color_(SK_ColorWHITE),
60 texture_id_in_layer_(0) { 60 texture_id_in_layer_(0),
61 current_buffer_id_(0) {
61 if (CompositorImpl::UsesDirectGL()) { 62 if (CompositorImpl::UsesDirectGL()) {
62 surface_texture_transport_.reset(new SurfaceTextureTransportClient()); 63 surface_texture_transport_.reset(new SurfaceTextureTransportClient());
63 layer_ = surface_texture_transport_->Initialize(); 64 layer_ = surface_texture_transport_->Initialize();
64 } else { 65 } else {
65 // TODO: Cannot use CompositorImpl::CompositorSupport() in unit tests. 66 // TODO: Cannot use CompositorImpl::CompositorSupport() in unit tests.
66 texture_layer_.reset(WebKit::WebExternalTextureLayer::create()); 67 texture_layer_.reset(WebKit::WebExternalTextureLayer::create());
67 layer_ = texture_layer_->layer(); 68 layer_ = texture_layer_->layer();
68 } 69 }
69 70
70 host_->SetView(this); 71 host_->SetView(this);
71 SetContentViewCore(content_view_core); 72 SetContentViewCore(content_view_core);
72 // RenderWidgetHost is initialized as visible. If is_hidden_ is true, tell 73 // RenderWidgetHost is initialized as visible. If is_hidden_ is true, tell
73 // RenderWidgetHost to hide. 74 // RenderWidgetHost to hide.
74 if (is_hidden_) 75 if (is_hidden_)
75 host_->WasHidden(); 76 host_->WasHidden();
76 77
77 layer_->setOpaque(true); 78 layer_->setOpaque(true);
78 layer_->setDrawsContent(!is_hidden_); 79 layer_->setDrawsContent(!is_hidden_);
79 } 80 }
80 81
81 RenderWidgetHostViewAndroid::~RenderWidgetHostViewAndroid() { 82 RenderWidgetHostViewAndroid::~RenderWidgetHostViewAndroid() {
82 if (!shared_surface_.is_null()) { 83 if (!shared_surface_.is_null()) {
83 ImageTransportFactoryAndroid::GetInstance()->DestroySharedSurfaceHandle( 84 ImageTransportFactoryAndroid::GetInstance()->DestroySharedSurfaceHandle(
84 shared_surface_); 85 shared_surface_);
85 } 86 }
87 if (texture_id_in_layer_)
piman 2012/11/30 03:54:32 nit: braces around body
88 ImageTransportFactoryAndroid::GetInstance()->DeleteTexture(
89 texture_id_in_layer_);
86 } 90 }
87 91
88 void RenderWidgetHostViewAndroid::InitAsChild(gfx::NativeView parent_view) { 92 void RenderWidgetHostViewAndroid::InitAsChild(gfx::NativeView parent_view) {
89 NOTIMPLEMENTED(); 93 NOTIMPLEMENTED();
90 } 94 }
91 95
92 void RenderWidgetHostViewAndroid::InitAsPopup( 96 void RenderWidgetHostViewAndroid::InitAsPopup(
93 RenderWidgetHostView* parent_host_view, const gfx::Rect& pos) { 97 RenderWidgetHostView* parent_host_view, const gfx::Rect& pos) {
94 NOTIMPLEMENTED(); 98 NOTIMPLEMENTED();
95 } 99 }
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 388
385 content_view_core_->ShowDisambiguationPopup(target_rect, zoomed_bitmap); 389 content_view_core_->ShowDisambiguationPopup(target_rect, zoomed_bitmap);
386 } 390 }
387 391
388 void RenderWidgetHostViewAndroid::OnAcceleratedCompositingStateChange() { 392 void RenderWidgetHostViewAndroid::OnAcceleratedCompositingStateChange() {
389 } 393 }
390 394
391 void RenderWidgetHostViewAndroid::AcceleratedSurfaceBuffersSwapped( 395 void RenderWidgetHostViewAndroid::AcceleratedSurfaceBuffersSwapped(
392 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, 396 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params,
393 int gpu_host_id) { 397 int gpu_host_id) {
394 texture_layer_->setTextureId(params.surface_handle); 398 ImageTransportFactoryAndroid* factory =
395 DCHECK(texture_layer_->layer() == layer_); 399 ImageTransportFactoryAndroid::GetInstance();
396 layer_->setBounds(params.size); 400
397 texture_id_in_layer_ = params.surface_handle; 401 // TODO(sievers): When running the impl thread in the browser we
402 // need to delay the ACK until after commit and use more than a single
403 // texture.
404 DCHECK(!CompositorImpl::CompositorSupport()->isThreadingEnabled());
405
406 uint64 previous_buffer = current_buffer_id_;
407 if (previous_buffer && texture_id_in_layer_) {
408 DCHECK(id_to_mailbox_.find(previous_buffer) != id_to_mailbox_.end());
409 ImageTransportFactoryAndroid::GetInstance()->ReleaseTexture(
410 texture_id_in_layer_,
411 reinterpret_cast<const signed char*>(
412 id_to_mailbox_[previous_buffer].c_str()));
413 }
414
415 current_buffer_id_ = params.surface_handle;
416 if (!texture_id_in_layer_) {
417 texture_id_in_layer_ = factory->CreateTexture();
418 texture_layer_->setTextureId(texture_id_in_layer_);
419 }
420
421 DCHECK(id_to_mailbox_.find(current_buffer_id_) != id_to_mailbox_.end());
422 ImageTransportFactoryAndroid::GetInstance()->AcquireTexture(
423 texture_id_in_layer_,
424 reinterpret_cast<const signed char*>(
425 id_to_mailbox_[current_buffer_id_].c_str()));
426 texture_layer_->layer()->invalidate();
427 texture_layer_->layer()->setBounds(params.size);
398 texture_size_in_layer_ = params.size; 428 texture_size_in_layer_ = params.size;
399 429
400 // TODO(sievers): When running the impl thread in the browser we
401 // need to delay the ACK until after commit.
402 DCHECK(!CompositorImpl::CompositorSupport()->isThreadingEnabled());
403 uint32 sync_point = 430 uint32 sync_point =
404 ImageTransportFactoryAndroid::GetInstance()->InsertSyncPoint(); 431 ImageTransportFactoryAndroid::GetInstance()->InsertSyncPoint();
405 RenderWidgetHostImpl::AcknowledgeBufferPresent( 432 RenderWidgetHostImpl::AcknowledgeBufferPresent(
406 params.route_id, gpu_host_id, true, sync_point); 433 params.route_id, gpu_host_id, previous_buffer, sync_point);
407 } 434 }
408 435
409 void RenderWidgetHostViewAndroid::AcceleratedSurfacePostSubBuffer( 436 void RenderWidgetHostViewAndroid::AcceleratedSurfacePostSubBuffer(
410 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, 437 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params,
411 int gpu_host_id) { 438 int gpu_host_id) {
412 NOTREACHED(); 439 NOTREACHED();
413 } 440 }
414 441
415 void RenderWidgetHostViewAndroid::AcceleratedSurfaceSuspend() { 442 void RenderWidgetHostViewAndroid::AcceleratedSurfaceSuspend() {
416 NOTREACHED(); 443 NOTREACHED();
417 } 444 }
418 445
446 void RenderWidgetHostViewAndroid::AcceleratedSurfaceNew(
447 int32 width_in_pixel, int32 height_in_pixel, uint64 surface_id,
448 const std::string& mailbox_name) {
449 DCHECK(surface_id == 1 || surface_id == 2);
450 id_to_mailbox_[surface_id] = mailbox_name;
451 }
452
453 void RenderWidgetHostViewAndroid::AcceleratedSurfaceRelease(uint64 surface_id) {
454 // This tells us we should free the frontbuffer.
455 if (texture_id_in_layer_) {
456 texture_layer_->setTextureId(0);
457 ImageTransportFactoryAndroid::GetInstance()->DeleteTexture(
458 texture_id_in_layer_);
459 texture_id_in_layer_ = 0;
460 }
461 }
462
419 bool RenderWidgetHostViewAndroid::HasAcceleratedSurface( 463 bool RenderWidgetHostViewAndroid::HasAcceleratedSurface(
420 const gfx::Size& desired_size) { 464 const gfx::Size& desired_size) {
421 NOTREACHED(); 465 NOTREACHED();
422 return false; 466 return false;
423 } 467 }
424 468
425 void RenderWidgetHostViewAndroid::StartContentIntent( 469 void RenderWidgetHostViewAndroid::StartContentIntent(
426 const GURL& content_url) { 470 const GURL& content_url) {
427 if (content_view_core_) 471 if (content_view_core_)
428 content_view_core_->StartContentIntent(content_url); 472 content_view_core_->StartContentIntent(content_url);
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 // RenderWidgetHostView, public: 641 // RenderWidgetHostView, public:
598 642
599 // static 643 // static
600 RenderWidgetHostView* 644 RenderWidgetHostView*
601 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) { 645 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) {
602 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget); 646 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget);
603 return new RenderWidgetHostViewAndroid(rwhi, NULL); 647 return new RenderWidgetHostViewAndroid(rwhi, NULL);
604 } 648 }
605 649
606 } // namespace content 650 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698