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/logging.h" | 10 #include "base/logging.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 ContentViewCoreImpl* content_view_core) | 49 ContentViewCoreImpl* content_view_core) |
50 : host_(widget_host), | 50 : host_(widget_host), |
51 // ContentViewCoreImpl represents the native side of the Java | 51 // ContentViewCoreImpl represents the native side of the Java |
52 // ContentViewCore. It being NULL means that it is not attached to the | 52 // ContentViewCore. It being NULL means that it is not attached to the |
53 // View system yet, so we treat it as hidden. | 53 // View system yet, so we treat it as hidden. |
54 is_hidden_(!content_view_core), | 54 is_hidden_(!content_view_core), |
55 content_view_core_(NULL), | 55 content_view_core_(NULL), |
56 ime_adapter_android_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 56 ime_adapter_android_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
57 cached_background_color_(SK_ColorWHITE), | 57 cached_background_color_(SK_ColorWHITE), |
58 texture_layer_(WebKit::WebExternalTextureLayer::create()), | 58 texture_layer_(WebKit::WebExternalTextureLayer::create()), |
59 texture_id_in_layer_(0) { | 59 texture_id_in_layer_(0), |
| 60 current_buffer_id_(0) { |
60 host_->SetView(this); | 61 host_->SetView(this); |
61 SetContentViewCore(content_view_core); | 62 SetContentViewCore(content_view_core); |
62 // RenderWidgetHost is initialized as visible. If is_hidden_ is true, tell | 63 // RenderWidgetHost is initialized as visible. If is_hidden_ is true, tell |
63 // RenderWidgetHost to hide. | 64 // RenderWidgetHost to hide. |
64 if (is_hidden_) | 65 if (is_hidden_) |
65 host_->WasHidden(); | 66 host_->WasHidden(); |
66 texture_layer_->layer()->setOpaque(true); | 67 texture_layer_->layer()->setOpaque(true); |
67 texture_layer_->layer()->setDrawsContent(!is_hidden_); | 68 texture_layer_->layer()->setDrawsContent(!is_hidden_); |
68 } | 69 } |
69 | 70 |
70 RenderWidgetHostViewAndroid::~RenderWidgetHostViewAndroid() { | 71 RenderWidgetHostViewAndroid::~RenderWidgetHostViewAndroid() { |
71 if (!shared_surface_.is_null()) { | 72 if (!shared_surface_.is_null()) { |
72 ImageTransportFactoryAndroid::GetInstance()->DestroySharedSurfaceHandle( | 73 ImageTransportFactoryAndroid::GetInstance()->DestroySharedSurfaceHandle( |
73 shared_surface_); | 74 shared_surface_); |
74 } | 75 } |
| 76 if (texture_id_in_layer_) |
| 77 ImageTransportFactoryAndroid::GetInstance()->DeleteTexture( |
| 78 texture_id_in_layer_); |
75 } | 79 } |
76 | 80 |
77 void RenderWidgetHostViewAndroid::InitAsChild(gfx::NativeView parent_view) { | 81 void RenderWidgetHostViewAndroid::InitAsChild(gfx::NativeView parent_view) { |
78 NOTIMPLEMENTED(); | 82 NOTIMPLEMENTED(); |
79 } | 83 } |
80 | 84 |
81 void RenderWidgetHostViewAndroid::InitAsPopup( | 85 void RenderWidgetHostViewAndroid::InitAsPopup( |
82 RenderWidgetHostView* parent_host_view, const gfx::Rect& pos) { | 86 RenderWidgetHostView* parent_host_view, const gfx::Rect& pos) { |
83 NOTIMPLEMENTED(); | 87 NOTIMPLEMENTED(); |
84 } | 88 } |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 | 374 |
371 content_view_core_->ShowDisambiguationPopup(target_rect, zoomed_bitmap); | 375 content_view_core_->ShowDisambiguationPopup(target_rect, zoomed_bitmap); |
372 } | 376 } |
373 | 377 |
374 void RenderWidgetHostViewAndroid::OnAcceleratedCompositingStateChange() { | 378 void RenderWidgetHostViewAndroid::OnAcceleratedCompositingStateChange() { |
375 } | 379 } |
376 | 380 |
377 void RenderWidgetHostViewAndroid::AcceleratedSurfaceBuffersSwapped( | 381 void RenderWidgetHostViewAndroid::AcceleratedSurfaceBuffersSwapped( |
378 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, | 382 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, |
379 int gpu_host_id) { | 383 int gpu_host_id) { |
380 texture_layer_->setTextureId(params.surface_handle); | 384 ImageTransportFactoryAndroid* factory = |
| 385 ImageTransportFactoryAndroid::GetInstance(); |
| 386 |
| 387 // TODO(sievers): When running the impl thread in the browser we |
| 388 // need to delay the ACK until after commit and use more than a single |
| 389 // texture. |
| 390 DCHECK(!CompositorImpl::CompositorSupport()->isThreadingEnabled()); |
| 391 |
| 392 uint64 previous_buffer = current_buffer_id_; |
| 393 if (previous_buffer && texture_id_in_layer_) { |
| 394 DCHECK(id_to_mailbox_.find(previous_buffer) != id_to_mailbox_.end()); |
| 395 ImageTransportFactoryAndroid::GetInstance()->ReleaseTexture( |
| 396 texture_id_in_layer_, |
| 397 (signed char*)id_to_mailbox_[previous_buffer].c_str()); |
| 398 } |
| 399 |
| 400 current_buffer_id_ = params.surface_handle; |
| 401 if (!texture_id_in_layer_) { |
| 402 texture_id_in_layer_ = factory->CreateTexture(); |
| 403 texture_layer_->setTextureId(texture_id_in_layer_); |
| 404 } |
| 405 |
| 406 DCHECK(id_to_mailbox_.find(current_buffer_id_) != id_to_mailbox_.end()); |
| 407 ImageTransportFactoryAndroid::GetInstance()->AcquireTexture( |
| 408 texture_id_in_layer_, |
| 409 (signed char*)id_to_mailbox_[current_buffer_id_].c_str()); |
| 410 texture_layer_->layer()->invalidate(); |
381 texture_layer_->layer()->setBounds(params.size); | 411 texture_layer_->layer()->setBounds(params.size); |
382 texture_id_in_layer_ = params.surface_handle; | |
383 texture_size_in_layer_ = params.size; | 412 texture_size_in_layer_ = params.size; |
384 | 413 |
385 // TODO(sievers): When running the impl thread in the browser we | |
386 // need to delay the ACK until after commit. | |
387 DCHECK(!CompositorImpl::CompositorSupport()->isThreadingEnabled()); | |
388 uint32 sync_point = | 414 uint32 sync_point = |
389 ImageTransportFactoryAndroid::GetInstance()->InsertSyncPoint(); | 415 ImageTransportFactoryAndroid::GetInstance()->InsertSyncPoint(); |
390 RenderWidgetHostImpl::AcknowledgeBufferPresent( | 416 RenderWidgetHostImpl::AcknowledgeBufferPresent( |
391 params.route_id, gpu_host_id, true, sync_point); | 417 params.route_id, gpu_host_id, previous_buffer, sync_point); |
392 } | 418 } |
393 | 419 |
394 void RenderWidgetHostViewAndroid::AcceleratedSurfacePostSubBuffer( | 420 void RenderWidgetHostViewAndroid::AcceleratedSurfacePostSubBuffer( |
395 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, | 421 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, |
396 int gpu_host_id) { | 422 int gpu_host_id) { |
397 NOTREACHED(); | 423 NOTREACHED(); |
398 } | 424 } |
399 | 425 |
400 void RenderWidgetHostViewAndroid::AcceleratedSurfaceSuspend() { | 426 void RenderWidgetHostViewAndroid::AcceleratedSurfaceSuspend() { |
401 NOTREACHED(); | 427 NOTREACHED(); |
402 } | 428 } |
403 | 429 |
| 430 void RenderWidgetHostViewAndroid::AcceleratedSurfaceNew( |
| 431 int32 width_in_pixel, int32 height_in_pixel, uint64 surface_id, |
| 432 const std::string& mailbox_name) { |
| 433 DCHECK(surface_id == 1 || surface_id == 2); |
| 434 id_to_mailbox_[surface_id] = mailbox_name; |
| 435 } |
| 436 |
| 437 void RenderWidgetHostViewAndroid::AcceleratedSurfaceRelease(uint64 surface_id) { |
| 438 // This tells us we should free the frontbuffer. |
| 439 if (texture_id_in_layer_) { |
| 440 texture_layer_->setTextureId(0); |
| 441 ImageTransportFactoryAndroid::GetInstance()->DeleteTexture( |
| 442 texture_id_in_layer_); |
| 443 texture_id_in_layer_ = 0; |
| 444 } |
| 445 } |
| 446 |
404 bool RenderWidgetHostViewAndroid::HasAcceleratedSurface( | 447 bool RenderWidgetHostViewAndroid::HasAcceleratedSurface( |
405 const gfx::Size& desired_size) { | 448 const gfx::Size& desired_size) { |
406 NOTREACHED(); | 449 NOTREACHED(); |
407 return false; | 450 return false; |
408 } | 451 } |
409 | 452 |
410 void RenderWidgetHostViewAndroid::StartContentIntent( | 453 void RenderWidgetHostViewAndroid::StartContentIntent( |
411 const GURL& content_url) { | 454 const GURL& content_url) { |
412 if (content_view_core_) | 455 if (content_view_core_) |
413 content_view_core_->StartContentIntent(content_url); | 456 content_view_core_->StartContentIntent(content_url); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 // RenderWidgetHostView, public: | 619 // RenderWidgetHostView, public: |
577 | 620 |
578 // static | 621 // static |
579 RenderWidgetHostView* | 622 RenderWidgetHostView* |
580 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) { | 623 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) { |
581 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget); | 624 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget); |
582 return new RenderWidgetHostViewAndroid(rwhi, NULL); | 625 return new RenderWidgetHostViewAndroid(rwhi, NULL); |
583 } | 626 } |
584 | 627 |
585 } // namespace content | 628 } // namespace content |
OLD | NEW |