| Index: content/browser/renderer_host/compositor_impl_android.cc
|
| diff --git a/content/browser/renderer_host/compositor_impl_android.cc b/content/browser/renderer_host/compositor_impl_android.cc
|
| index 3a203abf41bbfeeab357ffce24518d901531a3b9..fa7c344af330bd3dfcfbb1c825284255d90a7f6e 100644
|
| --- a/content/browser/renderer_host/compositor_impl_android.cc
|
| +++ b/content/browser/renderer_host/compositor_impl_android.cc
|
| @@ -10,6 +10,7 @@
|
| #include "base/android/jni_android.h"
|
| #include "base/android/scoped_java_ref.h"
|
| #include "base/bind.h"
|
| +#include "base/cancelable_callback.h"
|
| #include "base/command_line.h"
|
| #include "base/containers/hash_tables.h"
|
| #include "base/lazy_instance.h"
|
| @@ -29,6 +30,7 @@
|
| #include "content/browser/android/child_process_launcher_android.h"
|
| #include "content/browser/gpu/browser_gpu_channel_host_factory.h"
|
| #include "content/browser/gpu/gpu_surface_tracker.h"
|
| +#include "content/browser/renderer_host/render_widget_host_impl.h"
|
| #include "content/common/gpu/client/command_buffer_proxy_impl.h"
|
| #include "content/common/gpu/client/context_provider_command_buffer.h"
|
| #include "content/common/gpu/client/gl_helper.h"
|
| @@ -37,6 +39,7 @@
|
| #include "content/common/gpu/gpu_process_launch_causes.h"
|
| #include "content/common/host_shared_bitmap_manager.h"
|
| #include "content/public/browser/android/compositor_client.h"
|
| +#include "gpu/command_buffer/client/context_support.h"
|
| #include "gpu/command_buffer/client/gles2_interface.h"
|
| #include "third_party/khronos/GLES2/gl2.h"
|
| #include "third_party/khronos/GLES2/gl2ext.h"
|
| @@ -49,6 +52,8 @@
|
| #include "webkit/common/gpu/context_provider_in_process.h"
|
| #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h"
|
|
|
| +namespace content {
|
| +
|
| namespace {
|
|
|
| const unsigned int kMaxSwapBuffers = 2U;
|
| @@ -56,10 +61,13 @@ const unsigned int kMaxSwapBuffers = 2U;
|
| // Used to override capabilities_.adjust_deadline_for_parent to false
|
| class OutputSurfaceWithoutParent : public cc::OutputSurface {
|
| public:
|
| - OutputSurfaceWithoutParent(const scoped_refptr<
|
| - content::ContextProviderCommandBuffer>& context_provider,
|
| - base::WeakPtr<content::CompositorImpl> compositor_impl)
|
| - : cc::OutputSurface(context_provider) {
|
| + OutputSurfaceWithoutParent(
|
| + const scoped_refptr<ContextProviderCommandBuffer>& context_provider,
|
| + base::WeakPtr<CompositorImpl> compositor_impl)
|
| + : cc::OutputSurface(context_provider),
|
| + swap_buffers_completion_callback_(
|
| + base::Bind(&OutputSurfaceWithoutParent::OnSwapBuffersCompleted,
|
| + base::Unretained(this))) {
|
| capabilities_.adjust_deadline_for_parent = false;
|
| compositor_impl_ = compositor_impl;
|
| main_thread_ = base::MessageLoopProxy::current();
|
| @@ -71,32 +79,50 @@ class OutputSurfaceWithoutParent : public cc::OutputSurface {
|
| ui::INPUT_EVENT_BROWSER_SWAP_BUFFER_COMPONENT, 0, 0);
|
| }
|
|
|
| - content::ContextProviderCommandBuffer* provider_command_buffer =
|
| - static_cast<content::ContextProviderCommandBuffer*>(
|
| - context_provider_.get());
|
| - content::CommandBufferProxyImpl* command_buffer_proxy =
|
| - provider_command_buffer->GetCommandBufferProxy();
|
| - DCHECK(command_buffer_proxy);
|
| - command_buffer_proxy->SetLatencyInfo(frame->metadata.latency_info);
|
| -
|
| - OutputSurface::SwapBuffers(frame);
|
| + GetCommandBufferProxy()->SetLatencyInfo(frame->metadata.latency_info);
|
| + DCHECK(frame->gl_frame_data->sub_buffer_rect ==
|
| + gfx::Rect(frame->gl_frame_data->size));
|
| + context_provider_->ContextSupport()->Swap();
|
| }
|
|
|
| virtual bool BindToClient(cc::OutputSurfaceClient* client) override {
|
| if (!OutputSurface::BindToClient(client))
|
| return false;
|
|
|
| + GetCommandBufferProxy()->SetSwapBuffersCompletionCallback(
|
| + swap_buffers_completion_callback_.callback());
|
| +
|
| main_thread_->PostTask(
|
| FROM_HERE,
|
| - base::Bind(&content::CompositorImpl::PopulateGpuCapabilities,
|
| + base::Bind(&CompositorImpl::PopulateGpuCapabilities,
|
| compositor_impl_,
|
| context_provider_->ContextCapabilities().gpu));
|
|
|
| return true;
|
| }
|
|
|
| + private:
|
| + CommandBufferProxyImpl* GetCommandBufferProxy() {
|
| + ContextProviderCommandBuffer* provider_command_buffer =
|
| + static_cast<content::ContextProviderCommandBuffer*>(
|
| + context_provider_.get());
|
| + CommandBufferProxyImpl* command_buffer_proxy =
|
| + provider_command_buffer->GetCommandBufferProxy();
|
| + DCHECK(command_buffer_proxy);
|
| + return command_buffer_proxy;
|
| + }
|
| +
|
| + void OnSwapBuffersCompleted(
|
| + const std::vector<ui::LatencyInfo>& latency_info) {
|
| + RenderWidgetHostImpl::CompositorFrameDrawn(latency_info);
|
| + OutputSurface::OnSwapBuffersComplete();
|
| + }
|
| +
|
| + base::CancelableCallback<void(const std::vector<ui::LatencyInfo>&)>
|
| + swap_buffers_completion_callback_;
|
| +
|
| scoped_refptr<base::MessageLoopProxy> main_thread_;
|
| - base::WeakPtr<content::CompositorImpl> compositor_impl_;
|
| + base::WeakPtr<CompositorImpl> compositor_impl_;
|
| };
|
|
|
| class SurfaceTextureTrackerImpl : public gfx::SurfaceTextureTracker {
|
| @@ -130,7 +156,7 @@ class SurfaceTextureTrackerImpl : public gfx::SurfaceTextureTracker {
|
| SurfaceTextureMapKey key(surface_texture_id, child_process_id);
|
| DCHECK(surface_textures_.find(key) == surface_textures_.end());
|
| surface_textures_[key] = surface_texture;
|
| - content::RegisterChildProcessSurfaceTexture(
|
| + RegisterChildProcessSurfaceTexture(
|
| surface_texture_id,
|
| child_process_id,
|
| surface_texture->j_surface_texture().obj());
|
| @@ -143,8 +169,7 @@ class SurfaceTextureTrackerImpl : public gfx::SurfaceTextureTracker {
|
| SurfaceTextureMap::iterator it = surface_textures_.begin();
|
| while (it != surface_textures_.end()) {
|
| if (it->first.second == child_process_id) {
|
| - content::UnregisterChildProcessSurfaceTexture(it->first.first,
|
| - it->first.second);
|
| + UnregisterChildProcessSurfaceTexture(it->first.first, it->first.second);
|
| surface_textures_.erase(it++);
|
| } else {
|
| ++it;
|
| @@ -169,8 +194,6 @@ static bool g_initialized = false;
|
|
|
| } // anonymous namespace
|
|
|
| -namespace content {
|
| -
|
| // static
|
| Compositor* Compositor::Create(CompositorClient* client,
|
| gfx::NativeWindow root_window) {
|
| @@ -402,7 +425,7 @@ void CompositorImpl::SetSurface(jobject surface) {
|
|
|
| // First, cleanup any existing surface references.
|
| if (surface_id_)
|
| - content::UnregisterViewSurface(surface_id_);
|
| + UnregisterViewSurface(surface_id_);
|
| SetWindowSurface(NULL);
|
|
|
| // Now, set the new surface if we have one.
|
| @@ -417,7 +440,7 @@ void CompositorImpl::SetSurface(jobject surface) {
|
| if (window) {
|
| SetWindowSurface(window);
|
| ANativeWindow_release(window);
|
| - content::RegisterViewSurface(surface_id_, j_surface.obj());
|
| + RegisterViewSurface(surface_id_, j_surface.obj());
|
| }
|
| }
|
|
|
|
|