Commit b95a2eec authored by jbauman@chromium.org's avatar jbauman@chromium.org

Add use-surfaces command-line flag

When this flag is given, the new surfaces system will be used to display the browser contents.

BUG=

Review URL: https://codereview.chromium.org/307693005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@274113 0039d316-1c4b-4281-b951-d872f2087c98
parent 3186150d
......@@ -16,7 +16,6 @@ include_rules = [
"-base/prefs",
"+cc",
"-cc/surfaces",
# If you want to use any of these files, move them to src/base first.
"-cc/base/scoped_ptr_algorithm.h",
"-cc/base/scoped_ptr_deque.h",
......
......@@ -14,11 +14,14 @@
#include "base/threading/thread.h"
#include "cc/output/compositor_frame.h"
#include "cc/output/output_surface.h"
#include "cc/surfaces/surface_manager.h"
#include "content/browser/compositor/browser_compositor_output_surface.h"
#include "content/browser/compositor/browser_compositor_output_surface_proxy.h"
#include "content/browser/compositor/gpu_browser_compositor_output_surface.h"
#include "content/browser/compositor/onscreen_display_client.h"
#include "content/browser/compositor/reflector_impl.h"
#include "content/browser/compositor/software_browser_compositor_output_surface.h"
#include "content/browser/compositor/surface_display_output_surface.h"
#include "content/browser/gpu/browser_gpu_channel_host_factory.h"
#include "content/browser/gpu/gpu_data_manager_impl.h"
#include "content/browser/gpu/gpu_surface_tracker.h"
......@@ -29,6 +32,7 @@
#include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
#include "content/common/gpu/gpu_process_launch_causes.h"
#include "content/common/host_shared_bitmap_manager.h"
#include "content/public/common/content_switches.h"
#include "gpu/GLES2/gl2extchromium.h"
#include "gpu/command_buffer/client/gles2_interface.h"
#include "gpu/command_buffer/common/mailbox.h"
......@@ -59,6 +63,7 @@ namespace content {
struct GpuProcessTransportFactory::PerCompositorData {
int surface_id;
scoped_refptr<ReflectorImpl> reflector;
scoped_ptr<OnscreenDisplayClient> display_client;
};
GpuProcessTransportFactory::GpuProcessTransportFactory()
......@@ -75,6 +80,10 @@ GpuProcessTransportFactory::GpuProcessTransportFactory()
compositor_thread_.reset(new base::Thread("Browser Compositor"));
compositor_thread_->Start();
}
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kUseSurfaces)) {
surface_manager_ = make_scoped_ptr(new cc::SurfaceManager);
}
}
GpuProcessTransportFactory::~GpuProcessTransportFactory() {
......@@ -141,6 +150,7 @@ scoped_ptr<cc::OutputSurface> GpuProcessTransportFactory::CreateOutputSurface(
#endif
scoped_refptr<ContextProviderCommandBuffer> context_provider;
if (!create_software_renderer) {
context_provider = ContextProviderCommandBuffer::Create(
GpuProcessTransportFactory::CreateContextCommon(data->surface_id),
......@@ -149,6 +159,34 @@ scoped_ptr<cc::OutputSurface> GpuProcessTransportFactory::CreateOutputSurface(
UMA_HISTOGRAM_BOOLEAN("Aura.CreatedGpuBrowserCompositor", !!context_provider);
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kUseSurfaces)) {
if (!context_provider.get())
LOG(FATAL) << "Surfaces do not support software compositing yet";
// This gets a bit confusing. Here we have a ContextProvider configured to
// render directly to this widget. We need to make an OnscreenDisplayClient
// associated with this context, then return a SurfaceDisplayOutputSurface
// set up to draw to the display's surface.
cc::SurfaceManager* manager = surface_manager_.get();
scoped_ptr<OnscreenDisplayClient> display_client(
new OnscreenDisplayClient(context_provider, manager));
// TODO(jamesr): Need to set up filtering for the
// GpuHostMsg_UpdateVSyncParameters message.
scoped_refptr<cc::ContextProvider> offscreen_context_provider =
ContextProviderCommandBuffer::Create(
GpuProcessTransportFactory::CreateOffscreenCommandBufferContext(),
"Offscreen-MainThread");
scoped_ptr<cc::SoftwareOutputDevice> software_device;
scoped_ptr<SurfaceDisplayOutputSurface> output_surface(
new SurfaceDisplayOutputSurface(display_client->display(),
manager,
offscreen_context_provider,
software_device.Pass()));
data->display_client = display_client.Pass();
return output_surface.PassAs<cc::OutputSurface>();
}
if (!context_provider.get()) {
if (compositor_thread_.get()) {
LOG(FATAL) << "Failed to create UI context, but can't use software"
......
......@@ -19,6 +19,10 @@ namespace base {
class Thread;
}
namespace cc {
class SurfaceManager;
}
namespace content {
class BrowserCompositorOutputSurface;
class BrowserCompositorOutputSurfaceProxy;
......@@ -78,6 +82,7 @@ class GpuProcessTransportFactory
scoped_ptr<GLHelper> gl_helper_;
ObserverList<ImageTransportFactoryObserver> observer_list_;
base::WeakPtrFactory<GpuProcessTransportFactory> callback_factory_;
scoped_ptr<cc::SurfaceManager> surface_manager_;
// The contents of this map and its methods may only be used on the compositor
// thread.
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/browser/compositor/onscreen_display_client.h"
#include "cc/output/output_surface.h"
namespace content {
OnscreenDisplayClient::OnscreenDisplayClient(
const scoped_refptr<cc::ContextProvider>& onscreen_context_provider,
cc::SurfaceManager* manager)
: onscreen_context_provider_(onscreen_context_provider),
display_(this, manager) {
}
OnscreenDisplayClient::~OnscreenDisplayClient() {
}
scoped_ptr<cc::OutputSurface> OnscreenDisplayClient::CreateOutputSurface() {
return make_scoped_ptr(new cc::OutputSurface(onscreen_context_provider_))
.Pass();
}
} // namespace content
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_BROWSER_COMPOSITOR_ONSCREEN_DISPLAY_CLIENT_H_
#define CONTENT_BROWSER_COMPOSITOR_ONSCREEN_DISPLAY_CLIENT_H_
#include "cc/surfaces/display_client.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "cc/surfaces/display.h"
namespace cc {
class ContextProvider;
class SurfaceManager;
}
namespace content {
// This class provides a DisplayClient implementation for drawing directly to an
// onscreen context.
class OnscreenDisplayClient : cc::DisplayClient {
public:
OnscreenDisplayClient(
const scoped_refptr<cc::ContextProvider>& onscreen_context_provider,
cc::SurfaceManager* manager);
virtual ~OnscreenDisplayClient();
cc::Display* display() { return &display_; }
// cc::DisplayClient implementation.
virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface() OVERRIDE;
private:
scoped_refptr<cc::ContextProvider> onscreen_context_provider_;
cc::Display display_;
DISALLOW_COPY_AND_ASSIGN(OnscreenDisplayClient);
};
} // namespace content
#endif // CONTENT_BROWSER_COMPOSITOR_ONSCREEN_DISPLAY_CLIENT_H_
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/browser/compositor/surface_display_output_surface.h"
#include "cc/output/compositor_frame.h"
#include "cc/surfaces/display.h"
#include "cc/surfaces/surface.h"
#include "cc/surfaces/surface_manager.h"
namespace content {
SurfaceDisplayOutputSurface::SurfaceDisplayOutputSurface(
cc::Display* display,
cc::SurfaceManager* surface_manager,
const scoped_refptr<cc::ContextProvider>& context_provider,
scoped_ptr<cc::SoftwareOutputDevice> software_device)
: cc::OutputSurface(context_provider, software_device.Pass()),
display_(display),
surface_manager_(surface_manager) {
capabilities_.delegated_rendering = true;
capabilities_.max_frames_pending = 1;
}
SurfaceDisplayOutputSurface::~SurfaceDisplayOutputSurface() {
}
void SurfaceDisplayOutputSurface::SwapBuffers(cc::CompositorFrame* frame) {
gfx::Size frame_size =
frame->delegated_frame_data->render_pass_list.back()->output_rect.size();
display_->Resize(frame_size);
int surface_id = display_->CurrentSurfaceID();
cc::Surface* surface = surface_manager_->GetSurfaceForID(surface_id);
if (!surface)
return;
scoped_ptr<cc::CompositorFrame> frame_copy(new cc::CompositorFrame());
frame->AssignTo(frame_copy.get());
surface->QueueFrame(frame_copy.Pass());
if (!display_->Draw())
return;
client_->DidSwapBuffers();
client_->DidSwapBuffersComplete();
}
} // namespace content
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_BROWSER_COMPOSITOR_SURFACE_DISPLAY_OUTPUT_SURFACE_H_
#define CONTENT_BROWSER_COMPOSITOR_SURFACE_DISPLAY_OUTPUT_SURFACE_H_
#include "cc/output/output_surface.h"
namespace cc {
class Display;
class SurfaceManager;
}
namespace content {
// This class is maps a compositor OutputSurface to the surface system's Display
// concept, allowing a compositor client to submit frames for a native root
// window or physical display.
class SurfaceDisplayOutputSurface : public cc::OutputSurface {
public:
// The underlying cc::Display and cc::SurfaceManager must outlive this class.
SurfaceDisplayOutputSurface(
cc::Display* display,
cc::SurfaceManager* surface_manager,
const scoped_refptr<cc::ContextProvider>& context_provider,
scoped_ptr<cc::SoftwareOutputDevice> software_device);
virtual ~SurfaceDisplayOutputSurface();
// cc::OutputSurface implementation.
virtual void SwapBuffers(cc::CompositorFrame* frame) OVERRIDE;
private:
cc::Display* display_;
cc::SurfaceManager* surface_manager_;
DISALLOW_COPY_AND_ASSIGN(SurfaceDisplayOutputSurface);
};
} // namespace content
#endif // CONTENT_BROWSER_COMPOSITOR_SURFACE_DISPLAY_OUTPUT_SURFACE_H_
......@@ -373,6 +373,8 @@
'browser/compositor/image_transport_factory.h',
'browser/compositor/no_transport_image_transport_factory.cc',
'browser/compositor/no_transport_image_transport_factory.h',
'browser/compositor/onscreen_display_client.cc',
'browser/compositor/onscreen_display_client.h',
'browser/compositor/overlay_candidate_validator_ozone.cc',
'browser/compositor/overlay_candidate_validator_ozone.h',
'browser/compositor/owned_mailbox.h',
......@@ -393,6 +395,8 @@
'browser/compositor/software_output_device_win.h',
'browser/compositor/software_output_device_x11.cc',
'browser/compositor/software_output_device_x11.h',
'browser/compositor/surface_display_output_surface.cc',
'browser/compositor/surface_display_output_surface.h',
'browser/context_factory.cc',
'browser/cross_site_request_manager.cc',
'browser/cross_site_request_manager.h',
......@@ -1458,6 +1462,7 @@
'browser/devtools/devtools_resources.gyp:devtools_resources',
'content_common_mojo_bindings',
'../cc/cc.gyp:cc',
'../cc/cc.gyp:cc_surfaces',
'../mojo/mojo.gyp:mojo_cpp_bindings',
'../mojo/mojo.gyp:mojo_js_bindings',
'../mojo/mojo.gyp:mojo_service_provider_bindings',
......
......@@ -878,6 +878,9 @@ const char kUseFakeUIForMediaStream[] = "use-fake-ui-for-media-stream";
// Set when Chromium should use a mobile user agent.
const char kUseMobileUserAgent[] = "use-mobile-user-agent";
// Use the new surfaces system to handle compositor delegation.
const char kUseSurfaces[] = "use-surfaces";
// On POSIX only: the contents of this flag are prepended to the utility
// process command line. Useful values might be "valgrind" or "xterm -e gdb
// --args".
......
......@@ -246,6 +246,7 @@ CONTENT_EXPORT extern const char kUIPrioritizeInGpuProcess[];
CONTENT_EXPORT extern const char kUseDiscardableMemory[];
CONTENT_EXPORT extern const char kUseFakeUIForMediaStream[];
CONTENT_EXPORT extern const char kUseMobileUserAgent[];
extern const char kUseSurfaces[];
extern const char kUtilityCmdPrefix[];
CONTENT_EXPORT extern const char kUtilityProcess[];
extern const char kUtilityProcessAllowedDir[];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment