diff options
23 files changed, 101 insertions, 606 deletions
diff --git a/android_webview/android_webview.gyp b/android_webview/android_webview.gyp index 88cab24..2d7c31f 100644 --- a/android_webview/android_webview.gyp +++ b/android_webview/android_webview.gyp @@ -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', diff --git a/android_webview/browser/aw_browser_main_parts.cc b/android_webview/browser/aw_browser_main_parts.cc index 4f3ccc1..29e9003 100644 --- a/android_webview/browser/aw_browser_main_parts.cc +++ b/android_webview/browser/aw_browser_main_parts.cc @@ -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" diff --git a/android_webview/browser/browser_view_renderer.cc b/android_webview/browser/browser_view_renderer.cc index 3c1ceb4..7ac57f2 100644 --- a/android_webview/browser/browser_view_renderer.cc +++ b/android_webview/browser/browser_view_renderer.cc @@ -6,7 +6,6 @@ #include "android_webview/browser/browser_view_renderer_client.h" #include "android_webview/browser/shared_renderer_state.h" -#include "android_webview/common/aw_switches.h" #include "android_webview/public/browser/draw_gl.h" #include "base/android/jni_android.h" #include "base/auto_reset.h" @@ -17,7 +16,6 @@ #include "base/strings/string_number_conversions.h" #include "base/strings/stringprintf.h" #include "cc/output/compositor_frame.h" -#include "content/public/browser/android/synchronous_compositor.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/web_contents.h" #include "content/public/common/content_switches.h" @@ -51,31 +49,6 @@ const size_t kTileAllocationStep = 20; // See AwMainDelegate::BasicStartupComplete. size_t g_tile_area; -class AutoResetWithLock { - public: - AutoResetWithLock(gfx::Vector2dF* scoped_variable, - gfx::Vector2dF new_value, - base::Lock& lock) - : scoped_variable_(scoped_variable), - original_value_(*scoped_variable), - lock_(lock) { - base::AutoLock auto_lock(lock_); - *scoped_variable_ = new_value; - } - - ~AutoResetWithLock() { - base::AutoLock auto_lock(lock_); - *scoped_variable_ = original_value_; - } - - private: - gfx::Vector2dF* scoped_variable_; - gfx::Vector2dF original_value_; - base::Lock& lock_; - - DISALLOW_COPY_AND_ASSIGN(AutoResetWithLock); -}; - class TracedValue : public base::debug::ConvertableToTraceFormat { public: explicit TracedValue(base::Value* value) : value_(value) {} @@ -126,7 +99,7 @@ BrowserViewRenderer::BrowserViewRenderer( weak_factory_on_ui_thread_(this), ui_thread_weak_ptr_(weak_factory_on_ui_thread_.GetWeakPtr()), ui_task_runner_(ui_task_runner), - has_compositor_(false), + compositor_(NULL), is_paused_(false), view_visible_(false), window_visible_(false), @@ -145,8 +118,8 @@ BrowserViewRenderer::BrowserViewRenderer( CHECK(web_contents_); content::SynchronousCompositor::SetClientForWebContents(web_contents_, this); - // Currently the logic in this class relies on |has_compositor_| remaining - // false until the DidInitializeCompositor() call, hence it is not set here. + // Currently the logic in this class relies on |compositor_| remaining + // NULL until the DidInitializeCompositor() call, hence it is not set here. } BrowserViewRenderer::~BrowserViewRenderer() { @@ -179,7 +152,7 @@ void BrowserViewRenderer::TrimMemory(const int level, const bool visible) { // Just set the memory limit to 0 and drop all tiles. This will be reset to // normal levels in the next DrawGL call. SynchronousCompositorMemoryPolicy zero_policy; - if (shared_renderer_state_->GetMemoryPolicy() == zero_policy) + if (memory_policy_ == zero_policy) return; TRACE_EVENT0("android_webview", "BrowserViewRenderer::TrimMemory"); @@ -225,24 +198,21 @@ void BrowserViewRenderer::SetNumTiles(size_t num_tiles, return; num_tiles_ = num_tiles; - SynchronousCompositorMemoryPolicy new_policy; - new_policy.num_resources_limit = num_tiles_; - new_policy.bytes_limit = num_bytes_; - shared_renderer_state_->SetMemoryPolicy(new_policy); + memory_policy_.num_resources_limit = num_tiles_; + memory_policy_.bytes_limit = num_bytes_; if (effective_immediately) - EnforceMemoryPolicyImmediately(new_policy); + EnforceMemoryPolicyImmediately(memory_policy_); } void BrowserViewRenderer::EnforceMemoryPolicyImmediately( SynchronousCompositorMemoryPolicy new_policy) { - shared_renderer_state_->GetCompositor()->SetMemoryPolicy(new_policy); + compositor_->SetMemoryPolicy(new_policy); ForceFakeCompositeSW(); - shared_renderer_state_->SetMemoryPolicyDirty(false); } size_t BrowserViewRenderer::GetNumTiles() const { - return shared_renderer_state_->GetMemoryPolicy().num_resources_limit; + return memory_policy_.num_resources_limit; } bool BrowserViewRenderer::OnDraw(jobject java_canvas, @@ -256,57 +226,20 @@ bool BrowserViewRenderer::OnDraw(jobject java_canvas, if (clear_view_) return false; - if (is_hardware_canvas && attached_to_window_) { - if (switches::UbercompEnabled()) { - return OnDrawHardware(java_canvas); - } else { - return OnDrawHardwareLegacy(java_canvas); - } - } + if (is_hardware_canvas && attached_to_window_) + return OnDrawHardware(java_canvas); // Perform a software draw return DrawSWInternal(java_canvas, clip); } -bool BrowserViewRenderer::OnDrawHardwareLegacy(jobject java_canvas) { - scoped_ptr<DrawGLInput> draw_gl_input(new DrawGLInput); - draw_gl_input->scroll_offset = last_on_draw_scroll_offset_; - draw_gl_input->global_visible_rect = last_on_draw_global_visible_rect_; - draw_gl_input->width = width_; - draw_gl_input->height = height_; - - SynchronousCompositorMemoryPolicy old_policy = - shared_renderer_state_->GetMemoryPolicy(); - SynchronousCompositorMemoryPolicy new_policy = CalculateDesiredMemoryPolicy(); - RequestMemoryPolicy(new_policy); - // We should be performing a hardware draw here. If we don't have the - // compositor yet or if RequestDrawGL fails, it means we failed this draw - // and thus return false here to clear to background color for this draw. - bool did_draw_gl = - has_compositor_ && client_->RequestDrawGL(java_canvas, false); - if (did_draw_gl) { - GlobalTileManager::GetInstance()->DidUse(tile_manager_key_); - shared_renderer_state_->SetDrawGLInput(draw_gl_input.Pass()); - } else { - RequestMemoryPolicy(old_policy); - } - - return did_draw_gl; -} - -void BrowserViewRenderer::DidDrawGL(scoped_ptr<DrawGLResult> result) { - DidComposite(!result->clip_contains_visible_rect); -} - bool BrowserViewRenderer::OnDrawHardware(jobject java_canvas) { - if (!has_compositor_) + if (!compositor_) return false; if (!hardware_enabled_) { - hardware_enabled_ = - shared_renderer_state_->GetCompositor()->InitializeHwDraw(NULL); + hardware_enabled_ = compositor_->InitializeHwDraw(); if (hardware_enabled_) { - gpu::GLInProcessContext* share_context = - shared_renderer_state_->GetCompositor()->GetShareContext(); + gpu::GLInProcessContext* share_context = compositor_->GetShareContext(); DCHECK(share_context); shared_renderer_state_->SetSharedContext(share_context); } @@ -317,12 +250,10 @@ bool BrowserViewRenderer::OnDrawHardware(jobject java_canvas) { ReturnResources(); SynchronousCompositorMemoryPolicy new_policy = CalculateDesiredMemoryPolicy(); RequestMemoryPolicy(new_policy); - shared_renderer_state_->GetCompositor()->SetMemoryPolicy( - shared_renderer_state_->GetMemoryPolicy()); + compositor_->SetMemoryPolicy(memory_policy_); scoped_ptr<DrawGLInput> draw_gl_input(new DrawGLInput); draw_gl_input->scroll_offset = last_on_draw_scroll_offset_; - draw_gl_input->global_visible_rect = last_on_draw_global_visible_rect_; draw_gl_input->width = width_; draw_gl_input->height = height_; @@ -332,10 +263,8 @@ bool BrowserViewRenderer::OnDrawHardware(jobject java_canvas) { // TODO(boliu): Should really be |last_on_draw_global_visible_rect_|. // See crbug.com/372073. gfx::Rect clip = viewport; - bool stencil_enabled = false; - scoped_ptr<cc::CompositorFrame> frame = - shared_renderer_state_->GetCompositor()->DemandDrawHw( - surface_size, transform, viewport, clip, stencil_enabled); + scoped_ptr<cc::CompositorFrame> frame = compositor_->DemandDrawHw( + surface_size, transform, viewport, clip); if (!frame.get()) return false; @@ -349,7 +278,7 @@ bool BrowserViewRenderer::OnDrawHardware(jobject java_canvas) { } shared_renderer_state_->SetDrawGLInput(draw_gl_input.Pass()); - DidComposite(false); + DidComposite(); bool did_request = client_->RequestDrawGL(java_canvas, false); if (did_request) return true; @@ -358,13 +287,14 @@ bool BrowserViewRenderer::OnDrawHardware(jobject java_canvas) { return false; } -void BrowserViewRenderer::DidDrawDelegated(scoped_ptr<DrawGLResult> result) { +void BrowserViewRenderer::DidDrawDelegated() { if (!ui_task_runner_->BelongsToCurrentThread()) { // TODO(boliu): This should be a cancelable callback. + // TODO(boliu): Do this PostTask in AwContents instead so every method in + // this class is called by UI thread. ui_task_runner_->PostTask(FROM_HERE, base::Bind(&BrowserViewRenderer::DidDrawDelegated, - ui_thread_weak_ptr_, - base::Passed(&result))); + ui_thread_weak_ptr_)); return; } ReturnResources(); @@ -374,7 +304,7 @@ void BrowserViewRenderer::ReturnResources() { cc::CompositorFrameAck frame_ack; shared_renderer_state_->SwapReturnedResources(&frame_ack.resources); if (!frame_ack.resources.empty()) { - shared_renderer_state_->GetCompositor()->ReturnResources(frame_ack); + compositor_->ReturnResources(frame_ack); } } @@ -386,7 +316,7 @@ bool BrowserViewRenderer::DrawSWInternal(jobject java_canvas, return true; } - if (!has_compositor_) { + if (!compositor_) { TRACE_EVENT_INSTANT0( "android_webview", "EarlyOut_NoCompositor", TRACE_EVENT_SCOPE_THREAD); return false; @@ -412,12 +342,12 @@ skia::RefPtr<SkPicture> BrowserViewRenderer::CapturePicture(int width, // Reset scroll back to the origin, will go back to the old // value when scroll_reset is out of scope. - AutoResetWithLock scroll_reset( - &scroll_offset_dip_, gfx::Vector2dF(), render_thread_lock_); + base::AutoReset<gfx::Vector2dF> scroll_reset(&scroll_offset_dip_, + gfx::Vector2dF()); SkPictureRecorder recorder; SkCanvas* rec_canvas = recorder.beginRecording(width, height, NULL, 0); - if (has_compositor_) + if (compositor_) CompositeSW(rec_canvas); return skia::AdoptRef(recorder.endRecording()); } @@ -504,8 +434,7 @@ void BrowserViewRenderer::OnDetachedFromWindow() { ReturnResources(); DCHECK(shared_renderer_state_->ReturnedResourcesEmpty()); - if (switches::UbercompEnabled()) - shared_renderer_state_->GetCompositor()->ReleaseHwDraw(); + compositor_->ReleaseHwDraw(); shared_renderer_state_->SetSharedContext(NULL); hardware_enabled_ = false; } @@ -535,46 +464,31 @@ void BrowserViewRenderer::DidInitializeCompositor( TRACE_EVENT0("android_webview", "BrowserViewRenderer::DidInitializeCompositor"); DCHECK(compositor); - DCHECK(!has_compositor_); - DCHECK(ui_task_runner_->BelongsToCurrentThread()); - has_compositor_ = true; - shared_renderer_state_->SetCompositorOnUiThread(compositor); + DCHECK(!compositor_); + compositor_ = compositor; } void BrowserViewRenderer::DidDestroyCompositor( content::SynchronousCompositor* compositor) { TRACE_EVENT0("android_webview", "BrowserViewRenderer::DidDestroyCompositor"); - DCHECK(has_compositor_); - DCHECK(ui_task_runner_->BelongsToCurrentThread()); - has_compositor_ = false; - shared_renderer_state_->SetCompositorOnUiThread(NULL); + DCHECK(compositor_); + compositor_ = NULL; SynchronousCompositorMemoryPolicy zero_policy; - DCHECK(shared_renderer_state_->GetMemoryPolicy() == zero_policy); + DCHECK(memory_policy_ == zero_policy); } void BrowserViewRenderer::SetContinuousInvalidate(bool invalidate) { - { - base::AutoLock lock(render_thread_lock_); - if (compositor_needs_continuous_invalidate_ == invalidate) - return; - - TRACE_EVENT_INSTANT1("android_webview", - "BrowserViewRenderer::SetContinuousInvalidate", - TRACE_EVENT_SCOPE_THREAD, - "invalidate", - invalidate); - compositor_needs_continuous_invalidate_ = invalidate; - } - - if (ui_task_runner_->BelongsToCurrentThread()) { - EnsureContinuousInvalidation(false); + if (compositor_needs_continuous_invalidate_ == invalidate) return; - } - ui_task_runner_->PostTask( - FROM_HERE, - base::Bind(&BrowserViewRenderer::EnsureContinuousInvalidation, - ui_thread_weak_ptr_, - false)); + + TRACE_EVENT_INSTANT1("android_webview", + "BrowserViewRenderer::SetContinuousInvalidate", + TRACE_EVENT_SCOPE_THREAD, + "invalidate", + invalidate); + compositor_needs_continuous_invalidate_ = invalidate; + + EnsureContinuousInvalidation(false); } void BrowserViewRenderer::SetDipScale(float dip_scale) { @@ -609,13 +523,10 @@ void BrowserViewRenderer::ScrollTo(gfx::Vector2d scroll_offset) { DCHECK_LE(scroll_offset_dip.x(), max_scroll_offset_dip_.x()); DCHECK_LE(scroll_offset_dip.y(), max_scroll_offset_dip_.y()); - { - base::AutoLock lock(render_thread_lock_); - if (scroll_offset_dip_ == scroll_offset_dip) - return; + if (scroll_offset_dip_ == scroll_offset_dip) + return; - scroll_offset_dip_ = scroll_offset_dip; - } + scroll_offset_dip_ = scroll_offset_dip; TRACE_EVENT_INSTANT2("android_webview", "BrowserViewRenderer::ScrollTo", @@ -625,18 +536,11 @@ void BrowserViewRenderer::ScrollTo(gfx::Vector2d scroll_offset) { "y", scroll_offset_dip.y()); - if (has_compositor_) - shared_renderer_state_->GetCompositor()-> - DidChangeRootLayerScrollOffset(); + if (compositor_) + compositor_->DidChangeRootLayerScrollOffset(); } void BrowserViewRenderer::DidUpdateContent() { - if (!ui_task_runner_->BelongsToCurrentThread()) { - ui_task_runner_->PostTask(FROM_HERE, - base::Bind(&BrowserViewRenderer::DidUpdateContent, - ui_thread_weak_ptr_)); - return; - } TRACE_EVENT_INSTANT0("android_webview", "BrowserViewRenderer::DidUpdateContent", TRACE_EVENT_SCOPE_THREAD); @@ -647,16 +551,12 @@ void BrowserViewRenderer::DidUpdateContent() { void BrowserViewRenderer::SetTotalRootLayerScrollOffset( gfx::Vector2dF scroll_offset_dip) { + // TOOD(mkosiba): Add a DCHECK to say that this does _not_ get called during + // DrawGl when http://crbug.com/249972 is fixed. + if (scroll_offset_dip_ == scroll_offset_dip) + return; - { - base::AutoLock lock(render_thread_lock_); - // TOOD(mkosiba): Add a DCHECK to say that this does _not_ get called during - // DrawGl when http://crbug.com/249972 is fixed. - if (scroll_offset_dip_ == scroll_offset_dip) - return; - - scroll_offset_dip_ = scroll_offset_dip; - } + scroll_offset_dip_ = scroll_offset_dip; gfx::Vector2d max_offset = max_scroll_offset(); gfx::Vector2d scroll_offset; @@ -681,16 +581,10 @@ void BrowserViewRenderer::SetTotalRootLayerScrollOffset( } gfx::Vector2dF BrowserViewRenderer::GetTotalRootLayerScrollOffset() { - base::AutoLock lock(render_thread_lock_); return scroll_offset_dip_; } bool BrowserViewRenderer::IsExternalFlingActive() const { - if (!ui_task_runner_->BelongsToCurrentThread()) { - // TODO(boliu): This is short term hack since we cannot call into - // view system on non-UI thread. - return false; - } return client_->IsFlingActive(); } @@ -701,19 +595,6 @@ void BrowserViewRenderer::UpdateRootLayerState( float page_scale_factor, float min_page_scale_factor, float max_page_scale_factor) { - if (!ui_task_runner_->BelongsToCurrentThread()) { - ui_task_runner_->PostTask( - FROM_HERE, - base::Bind(&BrowserViewRenderer::UpdateRootLayerState, - ui_thread_weak_ptr_, - total_scroll_offset_dip, - max_scroll_offset_dip, - scrollable_size_dip, - page_scale_factor, - min_page_scale_factor, - max_page_scale_factor)); - return; - } TRACE_EVENT_INSTANT1( "android_webview", "BrowserViewRenderer::UpdateRootLayerState", @@ -761,16 +642,6 @@ scoped_ptr<base::Value> BrowserViewRenderer::RootLayerStateAsValue( void BrowserViewRenderer::DidOverscroll(gfx::Vector2dF accumulated_overscroll, gfx::Vector2dF latest_overscroll_delta, gfx::Vector2dF current_fling_velocity) { - if (!ui_task_runner_->BelongsToCurrentThread()) { - ui_task_runner_->PostTask( - FROM_HERE, - base::Bind(&BrowserViewRenderer::DidOverscroll, - ui_thread_weak_ptr_, - accumulated_overscroll, - latest_overscroll_delta, - current_fling_velocity)); - return; - } const float physical_pixel_scale = dip_scale_ * page_scale_factor_; if (accumulated_overscroll == latest_overscroll_delta) overscroll_rounding_error_ = gfx::Vector2dF(); @@ -805,10 +676,7 @@ void BrowserViewRenderer::EnsureContinuousInvalidation(bool force_invalidate) { if (throttle_fallback_tick) return; - { - base::AutoLock lock(render_thread_lock_); - block_invalidates_ = compositor_needs_continuous_invalidate_; - } + block_invalidates_ = compositor_needs_continuous_invalidate_; // Unretained here is safe because the callback is cancelled when // |fallback_tick_| is destroyed. @@ -835,12 +703,12 @@ void BrowserViewRenderer::FallbackTickFired() { // This should only be called if OnDraw or DrawGL did not come in time, which // means block_invalidates_ must still be true. DCHECK(block_invalidates_); - if (compositor_needs_continuous_invalidate_ && has_compositor_) + if (compositor_needs_continuous_invalidate_ && compositor_) ForceFakeCompositeSW(); } void BrowserViewRenderer::ForceFakeCompositeSW() { - DCHECK(has_compositor_); + DCHECK(compositor_); SkBitmap bitmap; bitmap.allocN32Pixels(1, 1); bitmap.eraseColor(0); @@ -849,30 +717,16 @@ void BrowserViewRenderer::ForceFakeCompositeSW() { } bool BrowserViewRenderer::CompositeSW(SkCanvas* canvas) { - DCHECK(has_compositor_); - bool result = shared_renderer_state_->GetCompositor()-> - DemandDrawSw(canvas); - DidComposite(false); + DCHECK(compositor_); + bool result = compositor_->DemandDrawSw(canvas); + DidComposite(); return result; } -void BrowserViewRenderer::DidComposite(bool force_invalidate) { - { - base::AutoLock lock(render_thread_lock_); - block_invalidates_ = false; - } - - if (!ui_task_runner_->BelongsToCurrentThread()) { - ui_task_runner_->PostTask( - FROM_HERE, - base::Bind(&BrowserViewRenderer::EnsureContinuousInvalidation, - ui_thread_weak_ptr_, - force_invalidate)); - return; - } - +void BrowserViewRenderer::DidComposite() { + block_invalidates_ = false; fallback_tick_.Cancel(); - EnsureContinuousInvalidation(force_invalidate); + EnsureContinuousInvalidation(false); } std::string BrowserViewRenderer::ToString(AwDrawGLInfo* draw_info) const { diff --git a/android_webview/browser/browser_view_renderer.h b/android_webview/browser/browser_view_renderer.h index 7195ad3..e8a1ebe 100644 --- a/android_webview/browser/browser_view_renderer.h +++ b/android_webview/browser/browser_view_renderer.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); }; diff --git a/android_webview/browser/hardware_renderer.cc b/android_webview/browser/hardware_renderer.cc index 096911df..6966a2c 100644 --- a/android_webview/browser/hardware_renderer.cc +++ b/android_webview/browser/hardware_renderer.cc @@ -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 diff --git a/android_webview/browser/hardware_renderer.h b/android_webview/browser/hardware_renderer.h index dfddcfa..8f56a2f 100644 --- a/android_webview/browser/hardware_renderer.h +++ b/android_webview/browser/hardware_renderer.h @@ -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 {} diff --git a/android_webview/browser/hardware_renderer_interface.h b/android_webview/browser/hardware_renderer_interface.h deleted file mode 100644 index c827243..0000000 --- a/android_webview/browser/hardware_renderer_interface.h +++ /dev/null @@ -1,26 +0,0 @@ -// 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_ diff --git a/android_webview/browser/hardware_renderer_legacy.cc b/android_webview/browser/hardware_renderer_legacy.cc deleted file mode 100644 index ade6be9..0000000 --- a/android_webview/browser/hardware_renderer_legacy.cc +++ /dev/null @@ -1,106 +0,0 @@ -// 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 diff --git a/android_webview/browser/hardware_renderer_legacy.h b/android_webview/browser/hardware_renderer_legacy.h deleted file mode 100644 index a92fe9b..0000000 --- a/android_webview/browser/hardware_renderer_legacy.h +++ /dev/null @@ -1,46 +0,0 @@ -// 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_ diff --git a/android_webview/browser/shared_renderer_state.cc b/android_webview/browser/shared_renderer_state.cc index 42a4245..aa09ef9 100644 --- a/android_webview/browser/shared_renderer_state.cc +++ b/android_webview/browser/shared_renderer_state.cc @@ -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_); diff --git a/android_webview/browser/shared_renderer_state.h b/android_webview/browser/shared_renderer_state.h index 8350c9d..dacde38 100644 --- a/android_webview/browser/shared_renderer_state.h +++ b/android_webview/browser/shared_renderer_state.h @@ -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_; diff --git a/android_webview/common/aw_switches.cc b/android_webview/common/aw_switches.cc deleted file mode 100644 index 7b3f686..0000000 --- a/android_webview/common/aw_switches.cc +++ /dev/null @@ -1,19 +0,0 @@ -// 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 diff --git a/android_webview/common/aw_switches.h b/android_webview/common/aw_switches.h deleted file mode 100644 index 3e9c378..0000000 --- a/android_webview/common/aw_switches.h +++ /dev/null @@ -1,16 +0,0 @@ -// 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_ diff --git a/android_webview/lib/main/aw_main_delegate.cc b/android_webview/lib/main/aw_main_delegate.cc index e940d23..8dd0648 100644 --- a/android_webview/lib/main/aw_main_delegate.cc +++ b/android_webview/lib/main/aw_main_delegate.cc @@ -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); diff --git a/android_webview/native/aw_contents.cc b/android_webview/native/aw_contents.cc index b96cde5..9ae3a21 100644 --- a/android_webview/native/aw_contents.cc +++ b/android_webview/native/aw_contents.cc @@ -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(); } } diff --git a/android_webview/native/aw_contents.h b/android_webview/native/aw_contents.h index 102dfaa..da49a8e 100644 --- a/android_webview/native/aw_contents.h +++ b/android_webview/native/aw_contents.h @@ -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_; 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 c4fdb62..7c5646e 100644 --- a/content/browser/android/in_process/synchronous_compositor_factory_impl.cc +++ b/content/browser/android/in_process/synchronous_compositor_factory_impl.cc @@ -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_; } 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 c7f1a3b..7fdc910 100644 --- a/content/browser/android/in_process/synchronous_compositor_factory_impl.h +++ b/content/browser/android/in_process/synchronous_compositor_factory_impl.h @@ -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: diff --git a/content/browser/android/in_process/synchronous_compositor_impl.cc b/content/browser/android/in_process/synchronous_compositor_impl.cc index 0a0be1c..d7b3eb7 100644 --- a/content/browser/android/in_process/synchronous_compositor_impl.cc +++ b/content/browser/android/in_process/synchronous_compositor_impl.cc @@ -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) diff --git a/content/browser/android/in_process/synchronous_compositor_impl.h b/content/browser/android/in_process/synchronous_compositor_impl.h index 544a533..6ac80cb 100644 --- a/content/browser/android/in_process/synchronous_compositor_impl.h +++ b/content/browser/android/in_process/synchronous_compositor_impl.h @@ -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; diff --git a/content/browser/android/in_process/synchronous_compositor_output_surface.cc b/content/browser/android/in_process/synchronous_compositor_output_surface.cc index 4590ed3..041de4d 100644 --- a/content/browser/android/in_process/synchronous_compositor_output_surface.cc +++ b/content/browser/android/in_process/synchronous_compositor_output_surface.cc @@ -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); diff --git a/content/browser/android/in_process/synchronous_compositor_output_surface.h b/content/browser/android/in_process/synchronous_compositor_output_surface.h index cc1f3be..3a456a4 100644 --- a/content/browser/android/in_process/synchronous_compositor_output_surface.h +++ b/content/browser/android/in_process/synchronous_compositor_output_surface.h @@ -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); diff --git a/content/public/browser/android/synchronous_compositor.h b/content/public/browser/android/synchronous_compositor.h index 5cd659f..6aaa213 100644 --- a/content/public/browser/android/synchronous_compositor.h +++ b/content/public/browser/android/synchronous_compositor.h @@ -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. |