summaryrefslogtreecommitdiffstats
path: root/content/browser/android/in_process
diff options
context:
space:
mode:
authorboliu <boliu@chromium.org>2015-07-22 17:18:04 -0700
committerCommit bot <commit-bot@chromium.org>2015-07-23 00:19:29 +0000
commit1463e1e5261571689fca740aafb1bf156f722f9d (patch)
treeee07a42f5a14d9fdd1be1298582540bb4b8ea4c6 /content/browser/android/in_process
parentbc5335d01161852835a6952236e744fb26edf1aa (diff)
downloadchromium_src-1463e1e5261571689fca740aafb1bf156f722f9d.zip
chromium_src-1463e1e5261571689fca740aafb1bf156f722f9d.tar.gz
chromium_src-1463e1e5261571689fca740aafb1bf156f722f9d.tar.bz2
Add switch to use ipc command buffer in Android WebView
Still default to use in-process command buffer. Add switch to make testing easier. With ipc command buffer, no need to initialize bindings early in start up. This is ok because ipc command buffer is guaranteed to start before the in-process one on render thread is created. Video still runs with context on render thread. Child compositor, WebGL and accelerated canvas will run with ipc command buffer when switch is present. BUG=509702 Review URL: https://codereview.chromium.org/1253553002 Cr-Commit-Position: refs/heads/master@{#339999}
Diffstat (limited to 'content/browser/android/in_process')
-rw-r--r--content/browser/android/in_process/synchronous_compositor_factory_impl.cc65
-rw-r--r--content/browser/android/in_process/synchronous_compositor_factory_impl.h11
-rw-r--r--content/browser/android/in_process/synchronous_compositor_impl.cc5
3 files changed, 66 insertions, 15 deletions
diff --git a/content/browser/android/in_process/synchronous_compositor_factory_impl.cc b/content/browser/android/in_process/synchronous_compositor_factory_impl.cc
index 88d69af..4aa5ddb 100644
--- a/content/browser/android/in_process/synchronous_compositor_factory_impl.cc
+++ b/content/browser/android/in_process/synchronous_compositor_factory_impl.cc
@@ -13,10 +13,14 @@
#include "content/browser/android/in_process/synchronous_compositor_impl.h"
#include "content/browser/android/in_process/synchronous_compositor_output_surface.h"
#include "content/browser/gpu/browser_gpu_memory_buffer_manager.h"
+#include "content/common/gpu/client/context_provider_command_buffer.h"
+#include "content/common/gpu/client/gpu_channel_host.h"
+#include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
#include "content/gpu/in_process_gpu_thread.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/gpu_data_manager.h"
#include "content/renderer/gpu/frame_swap_message_queue.h"
+#include "content/renderer/render_thread_impl.h"
#include "gpu/blink/webgraphicscontext3d_in_process_command_buffer_impl.h"
#include "gpu/command_buffer/client/gl_in_process_context.h"
#include "gpu/command_buffer/common/gles2_cmd_utils.h"
@@ -76,6 +80,24 @@ ContextHolder CreateContextHolder(
return holder;
}
+scoped_ptr<WebGraphicsContext3DCommandBufferImpl> CreateContext3D(
+ const blink::WebGraphicsContext3D::Attributes& attributes,
+ const content::WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits&
+ mem_limits) {
+ DCHECK(RenderThreadImpl::current());
+ CauseForGpuLaunch cause =
+ CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE;
+ scoped_refptr<GpuChannelHost> gpu_channel_host(
+ RenderThreadImpl::current()->EstablishGpuChannelSync(cause));
+ CHECK(gpu_channel_host.get());
+
+ int surface_id = 0;
+ bool lose_context_when_out_of_memory = true;
+ return make_scoped_ptr(new WebGraphicsContext3DCommandBufferImpl(
+ surface_id, GURL(), gpu_channel_host.get(), attributes,
+ lose_context_when_out_of_memory, mem_limits, NULL));
+}
+
} // namespace
class SynchronousCompositorFactoryImpl::VideoContextProvider
@@ -123,9 +145,9 @@ class SynchronousCompositorFactoryImpl::VideoContextProvider
DISALLOW_COPY_AND_ASSIGN(VideoContextProvider);
};
-
SynchronousCompositorFactoryImpl::SynchronousCompositorFactoryImpl()
: record_full_layer_(true),
+ use_ipc_command_buffer_(false),
num_hardware_compositors_(0) {
SynchronousCompositorFactory::SetInstance(this);
}
@@ -147,9 +169,9 @@ SynchronousCompositorFactoryImpl::CreateOutputSurface(
int routing_id,
scoped_refptr<content::FrameSwapMessageQueue> frame_swap_message_queue) {
scoped_refptr<cc::ContextProvider> onscreen_context =
- CreateContextProviderForCompositor();
+ CreateContextProviderForCompositor(RENDER_COMPOSITOR_CONTEXT);
scoped_refptr<cc::ContextProvider> worker_context =
- CreateContextProviderForCompositor();
+ CreateContextProviderForCompositor(RENDER_WORKER_CONTEXT);
return make_scoped_ptr(new SynchronousCompositorOutputSurface(
onscreen_context, worker_context, routing_id, frame_swap_message_queue));
@@ -167,10 +189,15 @@ SynchronousCompositorFactoryImpl::CreateExternalBeginFrameSource(
new SynchronousCompositorExternalBeginFrameSource(routing_id));
}
+bool SynchronousCompositorFactoryImpl::OverrideWithFactory() {
+ return !use_ipc_command_buffer_;
+}
+
scoped_refptr<ContextProviderWebContext>
SynchronousCompositorFactoryImpl::CreateOffscreenContextProvider(
const blink::WebGraphicsContext3D::Attributes& attributes,
const std::string& debug_name) {
+ DCHECK(!use_ipc_command_buffer_);
ContextHolder holder =
CreateContextHolder(attributes, GpuThreadService(),
gpu::GLInProcessContextSharedMemoryLimits(), true);
@@ -179,17 +206,25 @@ SynchronousCompositorFactoryImpl::CreateOffscreenContextProvider(
}
scoped_refptr<cc::ContextProvider>
-SynchronousCompositorFactoryImpl::CreateContextProviderForCompositor() {
- blink::WebGraphicsContext3D::Attributes attributes = GetDefaultAttribs();
- gpu::GLInProcessContextSharedMemoryLimits mem_limits;
+SynchronousCompositorFactoryImpl::CreateContextProviderForCompositor(
+ CommandBufferContextType type) {
// This is half of what RenderWidget uses because synchronous compositor
- // pipeline is only one frame deep.
- if (base::SysInfo::IsLowEndDevice()) {
- // But twice of half here because 16bit texture is not supported.
- mem_limits.mapped_memory_reclaim_limit = 2 * 1024 * 1024;
- } else {
- mem_limits.mapped_memory_reclaim_limit = 6 * 1024 * 1024;
+ // pipeline is only one frame deep. But twice of half for low end here
+ // because 16bit texture is not supported.
+ unsigned int mapped_memory_reclaim_limit =
+ (base::SysInfo::IsLowEndDevice() ? 2 : 6) * 1024 * 1024;
+ blink::WebGraphicsContext3D::Attributes attributes = GetDefaultAttribs();
+
+ if (use_ipc_command_buffer_) {
+ WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits mem_limits;
+ mem_limits.mapped_memory_reclaim_limit = mapped_memory_reclaim_limit;
+ scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context =
+ CreateContext3D(GetDefaultAttribs(), mem_limits);
+ return ContextProviderCommandBuffer::Create(context.Pass(), type);
}
+
+ gpu::GLInProcessContextSharedMemoryLimits mem_limits;
+ mem_limits.mapped_memory_reclaim_limit = mapped_memory_reclaim_limit;
ContextHolder holder =
CreateContextHolder(attributes, GpuThreadService(), mem_limits, true);
return ContextProviderInProcess::Create(holder.command_buffer.Pass(),
@@ -210,6 +245,7 @@ SynchronousCompositorFactoryImpl::CreateStreamTextureFactory(int frame_id) {
WebGraphicsContext3DInProcessCommandBufferImpl*
SynchronousCompositorFactoryImpl::CreateOffscreenGraphicsContext3D(
const blink::WebGraphicsContext3D::Attributes& attributes) {
+ DCHECK(!use_ipc_command_buffer_);
ContextHolder holder =
CreateContextHolder(attributes, GpuThreadService(),
gpu::GLInProcessContextSharedMemoryLimits(), true);
@@ -217,6 +253,7 @@ SynchronousCompositorFactoryImpl::CreateOffscreenGraphicsContext3D(
}
gpu::GPUInfo SynchronousCompositorFactoryImpl::GetGPUInfo() const {
+ DCHECK(!use_ipc_command_buffer_);
return content::GpuDataManager::GetInstance()->GetGPUInfo();
}
@@ -311,4 +348,8 @@ void SynchronousCompositorFactoryImpl::SetRecordFullDocument(
record_full_layer_ = record_full_document;
}
+void SynchronousCompositorFactoryImpl::SetUseIpcCommandBuffer() {
+ use_ipc_command_buffer_ = true;
+}
+
} // namespace content
diff --git a/content/browser/android/in_process/synchronous_compositor_factory_impl.h b/content/browser/android/in_process/synchronous_compositor_factory_impl.h
index 91ef7f6..e15daf2 100644
--- a/content/browser/android/in_process/synchronous_compositor_factory_impl.h
+++ b/content/browser/android/in_process/synchronous_compositor_factory_impl.h
@@ -8,6 +8,7 @@
#include "base/synchronization/lock.h"
#include "cc/blink/context_provider_web_context.h"
#include "content/browser/android/in_process/synchronous_input_event_filter.h"
+#include "content/common/gpu/client/command_buffer_metrics.h"
#include "content/renderer/android/synchronous_compositor_factory.h"
#include "content/renderer/media/android/stream_texture_factory_synchronous_impl.h"
#include "gpu/command_buffer/service/in_process_command_buffer.h"
@@ -44,12 +45,13 @@ class SynchronousCompositorFactoryImpl : public SynchronousCompositorFactory {
InputHandlerManagerClient* GetInputHandlerManagerClient() override;
scoped_ptr<cc::BeginFrameSource> CreateExternalBeginFrameSource(
int routing_id) override;
+ scoped_refptr<StreamTextureFactory> CreateStreamTextureFactory(
+ int view_id) override;
+ bool OverrideWithFactory() override;
scoped_refptr<cc_blink::ContextProviderWebContext>
CreateOffscreenContextProvider(
const blink::WebGraphicsContext3D::Attributes& attributes,
const std::string& debug_name) override;
- scoped_refptr<StreamTextureFactory> CreateStreamTextureFactory(
- int view_id) override;
gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl*
CreateOffscreenGraphicsContext3D(
const blink::WebGraphicsContext3D::Attributes& attributes) override;
@@ -64,12 +66,14 @@ class SynchronousCompositorFactoryImpl : public SynchronousCompositorFactory {
base::Thread* CreateInProcessGpuThread(
const InProcessChildThreadParams& params);
void SetRecordFullDocument(bool record_full_document);
+ void SetUseIpcCommandBuffer();
void CompositorInitializedHardwareDraw();
void CompositorReleasedHardwareDraw();
- scoped_refptr<cc::ContextProvider> CreateContextProviderForCompositor();
private:
+ scoped_refptr<cc::ContextProvider> CreateContextProviderForCompositor(
+ CommandBufferContextType type);
bool CanCreateMainThreadContext();
scoped_refptr<StreamTextureFactorySynchronousImpl::ContextProvider>
TryCreateStreamTextureFactory();
@@ -85,6 +89,7 @@ class SynchronousCompositorFactoryImpl : public SynchronousCompositorFactory {
scoped_refptr<VideoContextProvider> video_context_provider_;
bool record_full_layer_;
+ bool use_ipc_command_buffer_;
// |num_hardware_compositor_lock_| is updated on UI thread only but can be
// read on renderer main thread.
diff --git a/content/browser/android/in_process/synchronous_compositor_impl.cc b/content/browser/android/in_process/synchronous_compositor_impl.cc
index 527f743..e16539e 100644
--- a/content/browser/android/in_process/synchronous_compositor_impl.cc
+++ b/content/browser/android/in_process/synchronous_compositor_impl.cc
@@ -147,6 +147,11 @@ void SynchronousCompositor::SetRecordFullDocument(bool record_full_document) {
g_factory.Get().SetRecordFullDocument(record_full_document);
}
+// static
+void SynchronousCompositor::SetUseIpcCommandBuffer() {
+ g_factory.Get().SetUseIpcCommandBuffer();
+}
+
void SynchronousCompositorImpl::DidInitializeRendererObjects(
SynchronousCompositorOutputSurface* output_surface,
SynchronousCompositorExternalBeginFrameSource* begin_frame_source,