Commit 7a46143e authored by boliu@chromium.org's avatar boliu@chromium.org

aw: Remove legacy rendering path

Remove locks, post tasks, and complexity used to support legacy
rendering path.

BUG=344087

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@277907 0039d316-1c4b-4281-b951-d872f2087c98
parent fe03d587
......@@ -168,9 +168,6 @@
'browser/gpu_memory_buffer_factory_impl.h',
'browser/hardware_renderer.cc',
'browser/hardware_renderer.h',
'browser/hardware_renderer_legacy.cc',
'browser/hardware_renderer_legacy.h',
'browser/hardware_renderer_interface.h',
'browser/icon_helper.cc',
'browser/icon_helper.h',
'browser/input_stream.h',
......@@ -212,8 +209,6 @@
'common/aw_hit_test_data.cc',
'common/aw_hit_test_data.h',
'common/aw_resource.h',
'common/aw_switches.cc',
'common/aw_switches.h',
'common/devtools_instrumentation.h',
'common/print_messages.cc',
'common/print_messages.h',
......
......@@ -6,7 +6,6 @@
#include "android_webview/browser/aw_browser_context.h"
#include "android_webview/browser/aw_result_codes.h"
#include "android_webview/common/aw_switches.h"
#include "base/android/build_info.h"
#include "base/android/memory_pressure_listener_android.h"
#include "base/command_line.h"
......
......@@ -12,6 +12,7 @@
#include "base/callback.h"
#include "base/cancelable_callback.h"
#include "base/values.h"
#include "content/public/browser/android/synchronous_compositor.h"
#include "content/public/browser/android/synchronous_compositor_client.h"
#include "skia/ext/refptr.h"
#include "ui/gfx/rect.h"
......@@ -24,7 +25,6 @@ struct AwDrawSWFunctionTable;
namespace content {
class ContentViewCore;
class SynchronousCompositor;
struct SynchronousCompositorMemoryPolicy;
class WebContents;
}
......@@ -81,8 +81,7 @@ class BrowserViewRenderer : public content::SynchronousCompositorClient,
const gfx::Vector2d& scroll,
const gfx::Rect& global_visible_rect,
const gfx::Rect& clip);
void DidDrawGL(scoped_ptr<DrawGLResult> result);
void DidDrawDelegated(scoped_ptr<DrawGLResult> result);
void DidDrawDelegated();
// CapturePicture API methods.
skia::RefPtr<SkPicture> CapturePicture(int width, int height);
......@@ -149,12 +148,11 @@ class BrowserViewRenderer : public content::SynchronousCompositorClient,
void EnsureContinuousInvalidation(bool force_invalidate);
bool DrawSWInternal(jobject java_canvas, const gfx::Rect& clip_bounds);
bool CompositeSW(SkCanvas* canvas);
void DidComposite(bool force_invalidate);
void DidComposite();
scoped_ptr<base::Value> RootLayerStateAsValue(
const gfx::Vector2dF& total_scroll_offset_dip,
const gfx::SizeF& scrollable_size_dip);
bool OnDrawHardwareLegacy(jobject java_canvas);
bool OnDrawHardware(jobject java_canvas);
void ReturnResources();
......@@ -188,7 +186,7 @@ class BrowserViewRenderer : public content::SynchronousCompositorClient,
base::WeakPtr<BrowserViewRenderer> ui_thread_weak_ptr_;
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
bool has_compositor_;
content::SynchronousCompositor* compositor_;
bool is_paused_;
bool view_visible_;
......@@ -230,18 +228,13 @@ class BrowserViewRenderer : public content::SynchronousCompositorClient,
gfx::Vector2dF overscroll_rounding_error_;
GlobalTileManager::Key tile_manager_key_;
content::SynchronousCompositorMemoryPolicy memory_policy_;
// The following 2 are used to construct a memory policy and set the memory
// policy on the shared_renderer_state_ atomically.
size_t num_tiles_;
size_t num_bytes_;
// TODO(boliu): This is a short term solution to support
// SynchronousCompositorClient methods called on RenderThread. This is only
// used on data that must be modified immediately instead of being posted
// back to UI.
base::Lock render_thread_lock_;
DISALLOW_COPY_AND_ASSIGN(BrowserViewRenderer);
};
......
......@@ -128,8 +128,7 @@ void HardwareRenderer::DidBeginMainFrame() {
bool HardwareRenderer::DrawGL(bool stencil_enabled,
int framebuffer_binding_ext,
AwDrawGLInfo* draw_info,
DrawGLResult* result) {
AwDrawGLInfo* draw_info) {
TRACE_EVENT0("android_webview", "HardwareRenderer::DrawGL");
// We need to watch if the current Android context has changed and enforce
......
......@@ -5,7 +5,6 @@
#ifndef ANDROID_WEBVIEW_BROWSER_HARDWARE_RENDERER_H_
#define ANDROID_WEBVIEW_BROWSER_HARDWARE_RENDERER_H_
#include "android_webview/browser/hardware_renderer_interface.h"
#include "android_webview/browser/shared_renderer_state.h"
#include "base/memory/scoped_ptr.h"
#include "cc/layers/delegated_frame_resource_collection.h"
......@@ -26,19 +25,16 @@ namespace android_webview {
class AwGLSurface;
class ParentOutputSurface;
class HardwareRenderer : public HardwareRendererInterface,
public cc::LayerTreeHostClient,
class HardwareRenderer : public cc::LayerTreeHostClient,
public cc::LayerTreeHostSingleThreadClient,
public cc::DelegatedFrameResourceCollectionClient {
public:
explicit HardwareRenderer(SharedRendererState* state);
virtual ~HardwareRenderer();
// HardwareRendererInterface overrides.
virtual bool DrawGL(bool stencil_enabled,
int framebuffer_binding_ext,
AwDrawGLInfo* draw_info,
DrawGLResult* result) OVERRIDE;
bool DrawGL(bool stencil_enabled,
int framebuffer_binding_ext,
AwDrawGLInfo* draw_info);
// cc::LayerTreeHostClient overrides.
virtual void WillBeginMainFrame(int frame_id) OVERRIDE {}
......
// 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 ANDROID_WEBVIEW_BROWSER_HARDWARE_RENDERER_INTERFACE_H_
#define ANDROID_WEBVIEW_BROWSER_HARDWARE_RENDERER_INTERFACE_H_
struct AwDrawGLInfo;
namespace android_webview {
struct DrawGLResult;
class HardwareRendererInterface {
public:
virtual ~HardwareRendererInterface() {}
virtual bool DrawGL(bool stencil_enabled,
int framebuffer_binding_ext,
AwDrawGLInfo* draw_info,
DrawGLResult* result) = 0;
};
} // namespace android_webview
#endif // ANDROID_WEBVIEW_BROWSER_HARDWARE_RENDERER_INTERFACE_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 "android_webview/browser/hardware_renderer_legacy.h"
#include "android_webview/browser/aw_gl_surface.h"
#include "android_webview/browser/shared_renderer_state.h"
#include "android_webview/public/browser/draw_gl.h"
#include "base/debug/trace_event.h"
#include "base/strings/string_number_conversions.h"
#include "cc/output/compositor_frame.h"
#include "content/public/browser/android/synchronous_compositor.h"
#include "content/public/browser/browser_thread.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/geometry/rect_f.h"
#include "ui/gfx/transform.h"
#include "ui/gl/gl_bindings.h"
namespace android_webview {
HardwareRendererLegacy::HardwareRendererLegacy(SharedRendererState* state)
: shared_renderer_state_(state), last_egl_context_(eglGetCurrentContext()) {
DCHECK(last_egl_context_);
gl_surface_ = new AwGLSurface;
bool success =
shared_renderer_state_->GetCompositor()->InitializeHwDraw(gl_surface_);
DCHECK(success);
}
HardwareRendererLegacy::~HardwareRendererLegacy() {
draw_gl_input_ = shared_renderer_state_->PassDrawGLInput();
shared_renderer_state_->GetCompositor()->ReleaseHwDraw();
gl_surface_ = NULL;
}
bool HardwareRendererLegacy::DrawGL(bool stencil_enabled,
int framebuffer_binding_ext,
AwDrawGLInfo* draw_info,
DrawGLResult* result) {
TRACE_EVENT0("android_webview", "HardwareRendererLegacy::DrawGL");
// We need to watch if the current Android context has changed and enforce
// a clean-up in the compositor.
EGLContext current_context = eglGetCurrentContext();
if (!current_context) {
DLOG(ERROR) << "DrawGL called without EGLContext";
return false;
}
// TODO(boliu): Handle context loss.
if (last_egl_context_ != current_context)
DLOG(WARNING) << "EGLContextChanged";
// Should only need to access SharedRendererState in kModeDraw and kModeSync.
scoped_ptr<DrawGLInput> input = shared_renderer_state_->PassDrawGLInput();
if (input.get())
draw_gl_input_ = input.Pass();
SetCompositorMemoryPolicy();
gl_surface_->SetBackingFrameBufferObject(framebuffer_binding_ext);
gfx::Transform transform;
transform.matrix().setColMajorf(draw_info->transform);
transform.Translate(draw_gl_input_->scroll_offset.x(),
draw_gl_input_->scroll_offset.y());
gfx::Rect clip_rect(draw_info->clip_left,
draw_info->clip_top,
draw_info->clip_right - draw_info->clip_left,
draw_info->clip_bottom - draw_info->clip_top);
gfx::Rect viewport(draw_info->width, draw_info->height);
if (!draw_info->is_layer) {
gfx::RectF view_rect(draw_gl_input_->width, draw_gl_input_->height);
transform.TransformRect(&view_rect);
viewport.Intersect(gfx::ToEnclosingRect(view_rect));
}
scoped_ptr<cc::CompositorFrame> frame =
shared_renderer_state_->GetCompositor()->DemandDrawHw(
gfx::Size(draw_info->width, draw_info->height),
transform,
viewport,
clip_rect,
framebuffer_binding_ext);
gl_surface_->ResetBackingFrameBufferObject();
if (frame.get()) {
result->clip_contains_visible_rect =
clip_rect.Contains(draw_gl_input_->global_visible_rect);
}
return !!frame.get();
}
void HardwareRendererLegacy::SetCompositorMemoryPolicy() {
if (shared_renderer_state_->IsMemoryPolicyDirty()) {
content::SynchronousCompositorMemoryPolicy policy =
shared_renderer_state_->GetMemoryPolicy();
// Memory policy is set by BrowserViewRenderer on UI thread.
shared_renderer_state_->GetCompositor()->SetMemoryPolicy(policy);
shared_renderer_state_->SetMemoryPolicyDirty(false);
}
}
} // namespace android_webview
// 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 ANDROID_WEBVIEW_BROWSER_HARDWARE_RENDERER_LEGACY_H_
#define ANDROID_WEBVIEW_BROWSER_HARDWARE_RENDERER_LEGACY_H_
#include "android_webview/browser/hardware_renderer_interface.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
struct AwDrawGLInfo;
namespace android_webview {
class AwGLSurface;
class SharedRendererState;
struct DrawGLInput;
class HardwareRendererLegacy : public HardwareRendererInterface {
public:
explicit HardwareRendererLegacy(SharedRendererState* state);
virtual ~HardwareRendererLegacy();
virtual bool DrawGL(bool stencil_enabled,
int framebuffer_binding_ext,
AwDrawGLInfo* draw_info,
DrawGLResult* result) OVERRIDE;
private:
void SetCompositorMemoryPolicy();
SharedRendererState* shared_renderer_state_;
scoped_ptr<DrawGLInput> draw_gl_input_;
typedef void* EGLContext;
EGLContext last_egl_context_;
scoped_refptr<AwGLSurface> gl_surface_;
DISALLOW_COPY_AND_ASSIGN(HardwareRendererLegacy);
};
} // namespace android_webview
#endif // ANDROID_WEBVIEW_BROWSER_HARDWARE_RENDERER_LEGACY_H_
......@@ -16,9 +16,6 @@ DrawGLInput::DrawGLInput() : width(0), height(0) {
DrawGLInput::~DrawGLInput() {
}
DrawGLResult::DrawGLResult() : clip_contains_visible_rect(false) {
}
SharedRendererState::SharedRendererState(
scoped_refptr<base::MessageLoopProxy> ui_loop,
BrowserViewRendererClient* client)
......@@ -26,8 +23,6 @@ SharedRendererState::SharedRendererState(
client_on_ui_(client),
weak_factory_on_ui_thread_(this),
ui_thread_weak_ptr_(weak_factory_on_ui_thread_.GetWeakPtr()),
compositor_(NULL),
memory_policy_dirty_(false),
hardware_allowed_(false),
hardware_initialized_(false),
share_context_(NULL) {
......@@ -55,34 +50,6 @@ void SharedRendererState::ClientRequestDrawGLOnUIThread() {
}
}
void SharedRendererState::SetCompositorOnUiThread(
content::SynchronousCompositor* compositor) {
base::AutoLock lock(lock_);
DCHECK(ui_loop_->BelongsToCurrentThread());
compositor_ = compositor;
}
content::SynchronousCompositor* SharedRendererState::GetCompositor() {
base::AutoLock lock(lock_);
DCHECK(compositor_);
return compositor_;
}
void SharedRendererState::SetMemoryPolicy(
const content::SynchronousCompositorMemoryPolicy new_policy) {
base::AutoLock lock(lock_);
if (memory_policy_ != new_policy) {
memory_policy_ = new_policy;
memory_policy_dirty_ = true;
}
}
content::SynchronousCompositorMemoryPolicy
SharedRendererState::GetMemoryPolicy() const {
base::AutoLock lock(lock_);
return memory_policy_;
}
void SharedRendererState::SetDrawGLInput(scoped_ptr<DrawGLInput> input) {
base::AutoLock lock(lock_);
DCHECK(!draw_gl_input_.get());
......@@ -126,16 +93,6 @@ gpu::GLInProcessContext* SharedRendererState::GetSharedContext() const {
return share_context_;
}
void SharedRendererState::SetMemoryPolicyDirty(bool is_dirty) {
base::AutoLock lock(lock_);
memory_policy_dirty_ = is_dirty;
}
bool SharedRendererState::IsMemoryPolicyDirty() const {
base::AutoLock lock(lock_);
return memory_policy_dirty_;
}
void SharedRendererState::ReturnResources(
const cc::TransferableResourceArray& input) {
base::AutoLock lock(lock_);
......
......@@ -5,11 +5,11 @@
#ifndef ANDROID_WEBVIEW_BROWSER_SHARED_RENDERER_STATE_H_
#define ANDROID_WEBVIEW_BROWSER_SHARED_RENDERER_STATE_H_
#include "base/memory/weak_ptr.h"
#include "base/message_loop/message_loop_proxy.h"
#include "base/synchronization/lock.h"
#include "cc/output/compositor_frame.h"
#include "cc/output/compositor_frame_ack.h"
#include "content/public/browser/android/synchronous_compositor.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/vector2d.h"
......@@ -27,7 +27,6 @@ class BrowserViewRendererClient;
// Set by BrowserViewRenderer and read by HardwareRenderer.
struct DrawGLInput {
gfx::Rect global_visible_rect;
gfx::Vector2d scroll_offset;
int width;
int height;
......@@ -37,13 +36,6 @@ struct DrawGLInput {
~DrawGLInput();
};
// Set by HardwareRenderer and read by BrowserViewRenderer.
struct DrawGLResult {
bool clip_contains_visible_rect;
DrawGLResult();
};
// This class holds renderer state that is shared between UI and RT threads.
// Android framework will block the UI thread when RT is drawing, so no locking
// is needed in this class. In the interim, this class is also responsible for
......@@ -57,17 +49,6 @@ class SharedRendererState {
void ClientRequestDrawGL();
// This function should only be called on UI thread.
void SetCompositorOnUiThread(content::SynchronousCompositor* compositor);
// This function can be called on both UI and RT thread.
content::SynchronousCompositor* GetCompositor();
void SetMemoryPolicy(const content::SynchronousCompositorMemoryPolicy policy);
content::SynchronousCompositorMemoryPolicy GetMemoryPolicy() const;
void SetMemoryPolicyDirty(bool is_dirty);
bool IsMemoryPolicyDirty() const;
void SetDrawGLInput(scoped_ptr<DrawGLInput> input);
scoped_ptr<DrawGLInput> PassDrawGLInput();
......@@ -98,11 +79,6 @@ class SharedRendererState {
// Accessed by both UI and RT thread.
mutable base::Lock lock_;
content::SynchronousCompositor* compositor_;
content::SynchronousCompositorMemoryPolicy memory_policy_;
// Set to true when SetMemoryPolicy called with a different memory policy.
// Set to false when memory policy is read and enforced to compositor.
bool memory_policy_dirty_;
scoped_ptr<DrawGLInput> draw_gl_input_;
bool hardware_allowed_;
bool hardware_initialized_;
......
// 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 "android_webview/common/aw_switches.h"
#include "base/command_line.h"
namespace switches {
const char kEnableUbercomp[] = "enable-ubercomp";
bool UbercompEnabled() {
static bool ubercomp_enabled =
CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableUbercomp);
return ubercomp_enabled;
}
} // namespace switches
// 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 ANDROID_WEBVIEW_COMMON_AW_SWITCHES_H_
#define ANDROID_WEBVIEW_COMMON_AW_SWITCHES_H_
namespace switches {
extern const char kEnableUbercomp[];
bool UbercompEnabled();
} // namespace switches
#endif // ANDROID_WEBVIEW_COMMON_AW_SWITCHES_H_
......@@ -8,7 +8,6 @@
#include "android_webview/browser/browser_view_renderer.h"
#include "android_webview/browser/gpu_memory_buffer_factory_impl.h"
#include "android_webview/browser/scoped_allow_wait_for_legacy_web_view_api.h"
#include "android_webview/common/aw_switches.h"
#include "android_webview/lib/aw_browser_dependency_factory_impl.h"
#include "android_webview/native/aw_quota_manager_bridge_impl.h"
#include "android_webview/native/aw_web_contents_view_delegate.h"
......@@ -66,11 +65,6 @@ bool AwMainDelegate::BasicStartupComplete(int* exit_code) {
// Not yet supported in single-process mode.
cl->AppendSwitch(switches::kDisableSharedWorkers);
cl->AppendSwitch(switches::kEnableUbercomp);
if (!switches::UbercompEnabled()) {
cl->AppendSwitch(switches::kDisableDelegatedRenderer);
}
// File system API not supported (requires some new API; internal bug 6930981)
cl->AppendSwitch(switches::kDisableFileSystem);
......
......@@ -13,12 +13,10 @@
#include "android_webview/browser/deferred_gpu_command_service.h"
#include "android_webview/browser/gpu_memory_buffer_factory_impl.h"
#include "android_webview/browser/hardware_renderer.h"
#include "android_webview/browser/hardware_renderer_legacy.h"
#include "android_webview/browser/net_disk_cache_remover.h"
#include "android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.h"
#include "android_webview/browser/scoped_app_gl_state_restore.h"
#include "android_webview/common/aw_hit_test_data.h"
#include "android_webview/common/aw_switches.h"
#include "android_webview/common/devtools_instrumentation.h"
#include "android_webview/native/aw_autofill_client.h"
#include "android_webview/native/aw_browser_dependency_factory.h"
......@@ -369,25 +367,14 @@ void AwContents::DrawGL(AwDrawGLInfo* draw_info) {
if (!hardware_renderer_) {
DCHECK(!shared_renderer_state_.IsHardwareInitialized());
if (switches::UbercompEnabled()) {
hardware_renderer_.reset(new HardwareRenderer(&shared_renderer_state_));
} else {
hardware_renderer_.reset(
new HardwareRendererLegacy(&shared_renderer_state_));
}
hardware_renderer_.reset(new HardwareRenderer(&shared_renderer_state_));
shared_renderer_state_.SetHardwareInitialized(true);
}
scoped_ptr<DrawGLResult> result(new DrawGLResult);
if (hardware_renderer_->DrawGL(state_restore.stencil_enabled(),
state_restore.framebuffer_binding_ext(),
draw_info,
result.get())) {
if (switches::UbercompEnabled()) {
browser_view_renderer_.DidDrawDelegated(result.Pass());
} else {
browser_view_renderer_.DidDrawGL(result.Pass());
}
draw_info)) {
browser_view_renderer_.DidDrawDelegated();
}
}
......
......@@ -38,7 +38,7 @@ class AwContentsContainer;
class AwContentsClientBridge;
class AwPdfExporter;
class AwWebContentsDelegate;
class HardwareRendererInterface;
class HardwareRenderer;
class PermissionRequestHandler;
// Native side of java-class of same name.
......@@ -239,7 +239,7 @@ class AwContents : public FindHelper::Listener,
scoped_ptr<AwContents> pending_contents_;
SharedRendererState shared_renderer_state_;
BrowserViewRenderer browser_view_renderer_;
scoped_ptr<HardwareRendererInterface> hardware_renderer_;
scoped_ptr<HardwareRenderer> hardware_renderer_;
scoped_ptr<AwPdfExporter> pdf_exporter_;
scoped_ptr<PermissionRequestHandler> permission_request_handler_;
......
......@@ -55,7 +55,6 @@ scoped_ptr<gpu::GLInProcessContext> CreateOffscreenContext(
}
scoped_ptr<gpu::GLInProcessContext> CreateContext(
scoped_refptr<gfx::GLSurface> surface,
scoped_refptr<gpu::InProcessCommandBuffer::Service> service,
gpu::GLInProcessContext* share_context) {
const gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu;
......@@ -64,20 +63,12 @@ scoped_ptr<gpu::GLInProcessContext> CreateContext(
GetDefaultAttribs(), &in_process_attribs);
in_process_attribs.lose_context_when_out_of_memory = 1;
bool is_offscreen = false;
gfx::Size size(1, 1);
if (surface) {
is_offscreen = surface->IsOffscreen();
size = surface->GetSize();
}
scoped_ptr<gpu::GLInProcessContext> context(
gpu::GLInProcessContext::Create(service,
surface,
is_offscreen,
NULL /* surface */,
false /* is_offscreen */,
gfx::kNullAcceleratedWidget,
size,
gfx::Size(1, 1),
share_context,
false /* share_resources */,
in_process_attribs,
......@@ -177,14 +168,13 @@ scoped_refptr<ContextProviderWebContext> SynchronousCompositorFactoryImpl::
}
scoped_refptr<cc::ContextProvider> SynchronousCompositorFactoryImpl::
CreateOnscreenContextProviderForCompositorThread(
scoped_refptr<gfx::GLSurface> surface) {
CreateOnscreenContextProviderForCompositorThread() {
DCHECK(service_);
if (!share_context_.get())
share_context_ = CreateContext(NULL, service_, NULL);
share_context_ = CreateContext(service_, NULL);
return webkit::gpu::ContextProviderInProcess::Create(
WrapContext(CreateContext(surface, service_, share_context_.get())),
WrapContext(CreateContext(service_, share_context_.get())),
"Child-Compositor");
}
......@@ -239,7 +229,7 @@ SynchronousCompositorFactoryImpl::TryCreateStreamTextureFactory() {
DCHECK(share_context_.get());
video_context_provider_ = new VideoContextProvider(
CreateContext(NULL, service_, share_context_.get()));
CreateContext(service_, share_context_.get()));
}
return video_context_provider_;
}
......
......@@ -12,10 +12,6 @@
#include "gpu/command_buffer/service/in_process_command_buffer.h"
#include "webkit/common/gpu/context_provider_web_context.h"
namespace gfx {
class GLSurface;
}
namespace gpu {
class GLInProcessContext;
}
......@@ -57,8 +53,7 @@ class SynchronousCompositorFactoryImpl : public SynchronousCompositorFactory {
void CompositorReleasedHardwareDraw();
scoped_refptr<cc::ContextProvider>
CreateOnscreenContextProviderForCompositorThread(
scoped_refptr<gfx::GLSurface> surface);
CreateOnscreenContextProviderForCompositorThread();
gpu::GLInProcessContext* GetShareContext();
private:
......
......@@ -89,13 +89,12 @@ void SynchronousCompositor::SetGpuService(
g_factory.Get().SetDeferredGpuService(service);
}
bool SynchronousCompositorImpl::InitializeHwDraw(
scoped_refptr<gfx::GLSurface> surface) {
bool SynchronousCompositorImpl::InitializeHwDraw() {
DCHECK(CalledOnValidThread());
DCHECK(output_surface_);
scoped_refptr<cc::ContextProvider> onscreen_context =
g_factory.Get().CreateOnscreenContextProviderForCompositorThread(surface);
g_factory.Get().CreateOnscreenContextProviderForCompositorThread();
bool success = output_surface_->InitializeHwDraw(onscreen_context);
......@@ -120,13 +119,12 @@ scoped_ptr<cc::CompositorFrame> SynchronousCompositorImpl::DemandDrawHw(
gfx::Size surface_size,
const gfx::Transform& transform,
gfx::Rect viewport,
gfx::Rect clip,
bool stencil_enabled) {
gfx::Rect clip) {
DCHECK(CalledOnValidThread());
DCHECK(output_surface_);
scoped_ptr<cc::CompositorFrame> frame = output_surface_->DemandDrawHw(
surface_size, transform, viewport, clip, stencil_enabled);
scoped_ptr<cc::CompositorFrame> frame =
output_surface_->DemandDrawHw(surface_size, transform, viewport, clip);
if (frame.get())
UpdateFrameMetaData(frame->metadata);
return frame.Pass();
......@@ -150,15 +148,6 @@ bool SynchronousCompositorImpl::DemandDrawSw(SkCanvas* canvas) {
void SynchronousCompositorImpl::UpdateFrameMetaData(
const cc::CompositorFrameMetadata& frame_metadata) {
if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
BrowserThread::PostTask(
BrowserThread::UI,
FROM_HERE,
base::Bind(&SynchronousCompositorImpl::UpdateFrameMetaData,
weak_ptr_factory_.GetWeakPtr(),
frame_metadata));
return;
}
RenderWidgetHostViewAndroid* rwhv = static_cast<RenderWidgetHostViewAndroid*>(
contents_->GetRenderWidgetHostView());
if (rwhv)
......
......@@ -48,16 +48,14 @@ class SynchronousCompositorImpl
// SynchronousCompositor
virtual void SetClient(SynchronousCompositorClient* compositor_client)
OVERRIDE;
virtual bool InitializeHwDraw(
scoped_refptr<gfx::GLSurface> surface) OVERRIDE;
virtual bool InitializeHwDraw() OVERRIDE;
virtual void ReleaseHwDraw() OVERRIDE;
virtual gpu::GLInProcessContext* GetShareContext() OVERRIDE;
virtual scoped_ptr<cc::CompositorFrame> DemandDrawHw(
gfx::Size surface_size,
const gfx::Transform& transform,
gfx::Rect viewport,
gfx::Rect clip,
bool stencil_enabled) OVERRIDE;
gfx::Rect clip) OVERRIDE;
virtual bool DemandDrawSw(SkCanvas* canvas) OVERRIDE;
virtual void ReturnResources(
const cc::CompositorFrameAck& frame_ack) OVERRIDE;
......
......@@ -79,10 +79,8 @@ SynchronousCompositorOutputSurface::SynchronousCompositorOutputSurface(
capabilities_.deferred_gl_initialization = true;
capabilities_.draw_and_swap_full_viewport_every_frame = true;
capabilities_.adjust_deadline_for_parent = false;
if (IsDelegatedRendererEnabled()) {
capabilities_.delegated_rendering = true;
capabilities_.max_frames_pending = 1;
}
capabilities_.delegated_rendering = true;
capabilities_.max_frames_pending = 1;
// Cannot call out to GetDelegate() here as the output surface is not
// constructed on the correct thread.
......@@ -139,10 +137,6 @@ void SynchronousCompositorOutputSurface::SetNeedsBeginFrame(bool enable) {
void SynchronousCompositorOutputSurface::SwapBuffers(
cc::CompositorFrame* frame) {
DCHECK(CalledOnValidThread());
if (!ForcedDrawToSoftwareDevice() && !IsDelegatedRendererEnabled()) {
DCHECK(context_provider_);
context_provider_->ContextGL()->ShallowFlushCHROMIUM();
}
frame_holder_.reset(new cc::CompositorFrame);
frame->AssignTo(frame_holder_.get());
......@@ -176,14 +170,12 @@ SynchronousCompositorOutputSurface::DemandDrawHw(
gfx::Size surface_size,
const gfx::Transform& transform,
gfx::Rect viewport,
gfx::Rect clip,
bool stencil_enabled) {
gfx::Rect clip) {
DCHECK(CalledOnValidThread());
DCHECK(HasClient());
DCHECK(context_provider_);
surface_size_ = surface_size;
SetExternalStencilTest(stencil_enabled);
InvokeComposite(transform, viewport, clip, true);
return frame_holder_.Pass();
......@@ -205,7 +197,6 @@ SynchronousCompositorOutputSurface::DemandDrawSw(SkCanvas* canvas) {
surface_size_ = gfx::Size(canvas->getDeviceSize().width(),
canvas->getDeviceSize().height());
SetExternalStencilTest(false);
InvokeComposite(transform, clip, clip, false);
......
......@@ -68,8 +68,7 @@ class SynchronousCompositorOutputSurface
scoped_ptr<cc::CompositorFrame> DemandDrawHw(gfx::Size surface_size,
const gfx::Transform& transform,
gfx::Rect viewport,
gfx::Rect clip,
bool stencil_enabled);
gfx::Rect clip);
void ReturnResources(const cc::CompositorFrameAck& frame_ack);
scoped_ptr<cc::CompositorFrame> DemandDrawSw(SkCanvas* canvas);
void SetMemoryPolicy(const SynchronousCompositorMemoryPolicy& policy);
......
......@@ -19,7 +19,6 @@ class CompositorFrameAck;
}
namespace gfx {
class GLSurface;
class Transform;
};
......@@ -67,9 +66,8 @@ class CONTENT_EXPORT SynchronousCompositor {
// Synchronously initialize compositor for hardware draw. Can only be called
// while compositor is in software only mode, either after compositor is
// first created or after ReleaseHwDraw is called. It is invalid to
// DemandDrawHw before this returns true. |surface| is the GLSurface that
// should be used to create the underlying hardware context.
virtual bool InitializeHwDraw(scoped_refptr<gfx::GLSurface> surface) = 0;
// DemandDrawHw before this returns true.
virtual bool InitializeHwDraw() = 0;
// Reverse of InitializeHwDraw above. Can only be called while hardware draw
// is already initialized. Brings compositor back to software only mode and
......@@ -82,14 +80,12 @@ class CONTENT_EXPORT SynchronousCompositor {
virtual gpu::GLInProcessContext* GetShareContext() = 0;
// "On demand" hardware draw. The content is first clipped to |damage_area|,
// then transformed through |transform|, and finally clipped to |view_size|
// and by the existing stencil buffer if any.
// then transformed through |transform|, and finally clipped to |view_size|.
virtual scoped_ptr<cc::CompositorFrame> DemandDrawHw(
gfx::Size surface_size,
const gfx::Transform& transform,
gfx::Rect viewport,
gfx::Rect clip,
bool stencil_enabled) = 0;
gfx::Rect clip) = 0;
// For delegated rendering, return resources from parent compositor to this.
// Note that all resources must be returned before ReleaseHwDraw.
......
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