diff options
author | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-10 07:01:59 +0000 |
---|---|---|
committer | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-10 07:01:59 +0000 |
commit | d9a54602add9699ec4d5ebd1630c5c0c580ce8e8 (patch) | |
tree | 233319a1797c5e7dde1f080b65f876baf1869501 /cc | |
parent | 5291380cf9274160c02d805b7425bacbcfb2a4f5 (diff) | |
download | chromium_src-d9a54602add9699ec4d5ebd1630c5c0c580ce8e8.zip chromium_src-d9a54602add9699ec4d5ebd1630c5c0c580ce8e8.tar.gz chromium_src-d9a54602add9699ec4d5ebd1630c5c0c580ce8e8.tar.bz2 |
Pipe SwapBuffers call{,backs} through ContextSupport
This plumbs the SwapBuffers calls and callbacks through the
gpu::ContextSupport interface instead of WGC3D. There are two production
paths for the callbacks - using Echo and using View IPCs. The former is
used everywhere except for single-threaded mac and guest plugin mode.
This implements the Echo path directly in GLES2Implementation and leaves
the implementation of the non-Echo path in WGC3DCommandBufferImpl. We'll
still have to clean that up to avoid having to allocate a WGC3D, but this
at least gets rid of the API dependencies from cc.
R=piman
BUG=181120
Review URL: https://codereview.chromium.org/59233007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@239685 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r-- | cc/output/context_provider.cc | 2 | ||||
-rw-r--r-- | cc/output/context_provider.h | 7 | ||||
-rw-r--r-- | cc/output/gl_renderer_unittest.cc | 26 | ||||
-rw-r--r-- | cc/output/output_surface.cc | 33 | ||||
-rw-r--r-- | cc/output/output_surface.h | 1 | ||||
-rw-r--r-- | cc/test/test_context_provider.cc | 43 | ||||
-rw-r--r-- | cc/test/test_context_provider.h | 12 | ||||
-rw-r--r-- | cc/test/test_context_support.cc | 34 | ||||
-rw-r--r-- | cc/test/test_context_support.h | 25 | ||||
-rw-r--r-- | cc/test/test_web_graphics_context_3d.cc | 32 | ||||
-rw-r--r-- | cc/test/test_web_graphics_context_3d.h | 11 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl_unittest.cc | 48 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_unittest.cc | 1 |
13 files changed, 94 insertions, 181 deletions
diff --git a/cc/output/context_provider.cc b/cc/output/context_provider.cc index 454d96b..11b4bc5 100644 --- a/cc/output/context_provider.cc +++ b/cc/output/context_provider.cc @@ -14,7 +14,6 @@ ContextProvider::Capabilities::Capabilities() iosurface(false), map_image(false), post_sub_buffer(false), - swapbuffers_complete_callback(false), texture_format_bgra8888(false), texture_format_etc1(false), texture_rectangle(false), @@ -30,7 +29,6 @@ ContextProvider::Capabilities::Capabilities( iosurface(gpu_capabilities.iosurface), map_image(gpu_capabilities.map_image), post_sub_buffer(gpu_capabilities.post_sub_buffer), - swapbuffers_complete_callback(false), texture_format_bgra8888(gpu_capabilities.texture_format_bgra8888), texture_format_etc1(gpu_capabilities.texture_format_etc1), texture_rectangle(gpu_capabilities.texture_rectangle), diff --git a/cc/output/context_provider.h b/cc/output/context_provider.h index ef46d09..54e75e9 100644 --- a/cc/output/context_provider.h +++ b/cc/output/context_provider.h @@ -41,7 +41,6 @@ class ContextProvider : public base::RefCountedThreadSafe<ContextProvider> { bool iosurface : 1; bool map_image : 1; bool post_sub_buffer : 1; - bool swapbuffers_complete_callback : 1; bool texture_format_bgra8888 : 1; bool texture_format_etc1 : 1; bool texture_rectangle : 1; @@ -79,12 +78,6 @@ class ContextProvider : public base::RefCountedThreadSafe<ContextProvider> { virtual void SetLostContextCallback( const LostContextCallback& lost_context_callback) = 0; - // Sets a callback to be called when swap buffers completes. This should be - // called from the same thread that the context is bound to. - typedef base::Closure SwapBuffersCompleteCallback; - virtual void SetSwapBuffersCompleteCallback( - const SwapBuffersCompleteCallback& swap_buffers_complete_callback) = 0; - // Sets a callback to be called when the memory policy changes. This should be // called from the same thread that the context is bound to. typedef base::Callback<void(const cc::ManagedMemoryPolicy& policy)> diff --git a/cc/output/gl_renderer_unittest.cc b/cc/output/gl_renderer_unittest.cc index 1760bc5..838d485 100644 --- a/cc/output/gl_renderer_unittest.cc +++ b/cc/output/gl_renderer_unittest.cc @@ -129,23 +129,6 @@ namespace { TEST_F(GLRendererShaderPixelTest, AllShadersCompile) { TestShaders(); } #endif -class FrameCountingContext : public TestWebGraphicsContext3D { - public: - FrameCountingContext() - : frame_(0) {} - - // WebGraphicsContext3D methods. - - // This method would normally do a glSwapBuffers under the hood. - virtual void prepareTexture() { frame_++; } - - // Methods added for test. - int frame_count() { return frame_; } - - private: - int frame_; -}; - class FakeRendererClient : public RendererClient { public: FakeRendererClient() @@ -218,11 +201,8 @@ class FakeRendererGL : public GLRenderer { class GLRendererTest : public testing::Test { protected: GLRendererTest() { - scoped_ptr<FrameCountingContext> context3d(new FrameCountingContext); - context3d_ = context3d.get(); - output_surface_ = FakeOutputSurface::Create3d( - context3d.PassAs<TestWebGraphicsContext3D>()).Pass(); + TestWebGraphicsContext3D::Create()).Pass(); CHECK(output_surface_->BindToClient(&output_surface_client_)); resource_provider_ = ResourceProvider::Create( @@ -236,7 +216,6 @@ class GLRendererTest : public testing::Test { void SwapBuffers() { renderer_->SwapBuffers(CompositorFrameMetadata()); } LayerTreeSettings settings_; - FrameCountingContext* context3d_; FakeOutputSurfaceClient output_surface_client_; scoped_ptr<FakeOutputSurface> output_surface_; FakeRendererClient renderer_client_; @@ -382,7 +361,7 @@ TEST_F(GLRendererTest, DiscardedBackbufferIsRecreatedForScopeDuration) { EXPECT_FALSE(renderer_->IsBackbufferDiscarded()); SwapBuffers(); - EXPECT_EQ(1, context3d_->frame_count()); + EXPECT_EQ(1u, output_surface_->num_sent_frames()); } TEST_F(GLRendererTest, FramebufferDiscardedAfterReadbackWhenNotVisible) { @@ -1589,7 +1568,6 @@ class OutputSurfaceMockContext : public TestWebGraphicsContext3D { MOCK_METHOD0(ensureBackbufferCHROMIUM, void()); MOCK_METHOD0(discardBackbufferCHROMIUM, void()); MOCK_METHOD2(bindFramebuffer, void(WGC3Denum target, WebGLId framebuffer)); - MOCK_METHOD0(prepareTexture, void()); MOCK_METHOD3(reshapeWithScaleFactor, void(int width, int height, float scale_factor)); MOCK_METHOD4(drawElements, diff --git a/cc/output/output_surface.cc b/cc/output/output_surface.cc index 7c56eea..c2f89e2 100644 --- a/cc/output/output_surface.cc +++ b/cc/output/output_surface.cc @@ -22,6 +22,7 @@ #include "cc/output/output_surface_client.h" #include "cc/scheduler/delay_based_time_source.h" #include "gpu/GLES2/gl2extchromium.h" +#include "gpu/command_buffer/client/context_support.h" #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" #include "third_party/khronos/GLES2/gl2.h" #include "third_party/khronos/GLES2/gl2ext.h" @@ -44,7 +45,6 @@ namespace cc { OutputSurface::OutputSurface(scoped_refptr<ContextProvider> context_provider) : context_provider_(context_provider), - has_swap_buffers_complete_callback_(false), device_scale_factor_(-1), max_frames_pending_(0), pending_swap_buffers_(0), @@ -59,7 +59,6 @@ OutputSurface::OutputSurface(scoped_refptr<ContextProvider> context_provider) OutputSurface::OutputSurface( scoped_ptr<cc::SoftwareOutputDevice> software_device) : software_device_(software_device.Pass()), - has_swap_buffers_complete_callback_(false), device_scale_factor_(-1), max_frames_pending_(0), pending_swap_buffers_(0), @@ -76,7 +75,6 @@ OutputSurface::OutputSurface( scoped_ptr<cc::SoftwareOutputDevice> software_device) : context_provider_(context_provider), software_device_(software_device.Pass()), - has_swap_buffers_complete_callback_(false), device_scale_factor_(-1), max_frames_pending_(0), pending_swap_buffers_(0), @@ -314,16 +312,12 @@ void OutputSurface::SetUpContext3d() { DCHECK(context_provider_); DCHECK(client_); - const ContextProvider::Capabilities& caps = - context_provider_->ContextCapabilities(); - - has_swap_buffers_complete_callback_ = caps.swapbuffers_complete_callback; - context_provider_->SetLostContextCallback( base::Bind(&OutputSurface::DidLoseOutputSurface, base::Unretained(this))); - context_provider_->SetSwapBuffersCompleteCallback(base::Bind( - &OutputSurface::OnSwapBuffersComplete, base::Unretained(this))); + context_provider_->ContextSupport()->SetSwapBuffersCompleteCallback( + base::Bind(&OutputSurface::OnSwapBuffersComplete, + base::Unretained(this))); context_provider_->SetMemoryPolicyChangedCallback( base::Bind(&OutputSurface::SetMemoryPolicy, base::Unretained(this))); @@ -343,10 +337,10 @@ void OutputSurface::ResetContext3d() { } context_provider_->SetLostContextCallback( ContextProvider::LostContextCallback()); - context_provider_->SetSwapBuffersCompleteCallback( - ContextProvider::SwapBuffersCompleteCallback()); context_provider_->SetMemoryPolicyChangedCallback( ContextProvider::MemoryPolicyChangedCallback()); + if (gpu::ContextSupport* support = context_provider_->ContextSupport()) + support->SetSwapBuffersCompleteCallback(base::Closure()); } context_provider_ = NULL; } @@ -401,21 +395,12 @@ void OutputSurface::SwapBuffers(cc::CompositorFrame* frame) { UpdateAndMeasureGpuLatency(); if (frame->gl_frame_data->sub_buffer_rect == gfx::Rect(frame->gl_frame_data->size)) { - // Note that currently this has the same effect as SwapBuffers; we should - // consider exposing a different entry point on WebGraphicsContext3D. - context_provider_->Context3d()->prepareTexture(); + context_provider_->ContextSupport()->Swap(); } else { - gfx::Rect sub_buffer_rect = frame->gl_frame_data->sub_buffer_rect; - context_provider_->Context3d()->postSubBufferCHROMIUM( - sub_buffer_rect.x(), - sub_buffer_rect.y(), - sub_buffer_rect.width(), - sub_buffer_rect.height()); + context_provider_->ContextSupport()->PartialSwapBuffers( + frame->gl_frame_data->sub_buffer_rect); } - if (!has_swap_buffers_complete_callback_) - PostSwapBuffersComplete(); - DidSwapBuffers(); } diff --git a/cc/output/output_surface.h b/cc/output/output_surface.h index d724465..2d5dda8 100644 --- a/cc/output/output_surface.h +++ b/cc/output/output_surface.h @@ -154,7 +154,6 @@ class CC_EXPORT OutputSurface : public FrameRateControllerClient { struct cc::OutputSurface::Capabilities capabilities_; scoped_refptr<ContextProvider> context_provider_; scoped_ptr<cc::SoftwareOutputDevice> software_device_; - bool has_swap_buffers_complete_callback_; gfx::Size surface_size_; float device_scale_factor_; diff --git a/cc/test/test_context_provider.cc b/cc/test/test_context_provider.cc index 3705a60..626b587 100644 --- a/cc/test/test_context_provider.cc +++ b/cc/test/test_context_provider.cc @@ -10,7 +10,6 @@ #include "base/bind.h" #include "base/callback_helpers.h" #include "base/logging.h" -#include "base/strings/string_split.h" #include "cc/test/test_gles2_interface.h" #include "cc/test/test_web_graphics_context_3d.h" @@ -36,27 +35,6 @@ class TestContextProvider::LostContextCallbackProxy TestContextProvider* provider_; }; -class TestContextProvider::SwapBuffersCompleteCallbackProxy - : public blink::WebGraphicsContext3D:: - WebGraphicsSwapBuffersCompleteCallbackCHROMIUM { - public: - explicit SwapBuffersCompleteCallbackProxy(TestContextProvider* provider) - : provider_(provider) { - provider_->context3d_->setSwapBuffersCompleteCallbackCHROMIUM(this); - } - - virtual ~SwapBuffersCompleteCallbackProxy() { - provider_->context3d_->setSwapBuffersCompleteCallbackCHROMIUM(NULL); - } - - virtual void onSwapBuffersComplete() { - provider_->OnSwapBuffersComplete(); - } - - private: - TestContextProvider* provider_; -}; - // static scoped_refptr<TestContextProvider> TestContextProvider::Create() { return Create(TestWebGraphicsContext3D::Create().Pass()); @@ -75,7 +53,8 @@ TestContextProvider::TestContextProvider( : context3d_(context.Pass()), context_gl_(new TestGLES2Interface(context3d_.get())), bound_(false), - destroyed_(false) { + destroyed_(false), + weak_ptr_factory_(this) { DCHECK(main_thread_checker_.CalledOnValidThread()); DCHECK(context3d_); context_thread_checker_.DetachFromThread(); @@ -102,8 +81,6 @@ bool TestContextProvider::BindToCurrentThread() { bound_ = true; lost_context_callback_proxy_.reset(new LostContextCallbackProxy(this)); - swap_buffers_complete_callback_proxy_.reset( - new SwapBuffersCompleteCallbackProxy(this)); return true; } @@ -131,9 +108,6 @@ gpu::gles2::GLES2Interface* TestContextProvider::ContextGL() { } gpu::ContextSupport* TestContextProvider::ContextSupport() { - DCHECK(bound_); - DCHECK(context_thread_checker_.CalledOnValidThread()); - return &support_; } @@ -183,12 +157,6 @@ void TestContextProvider::OnLostContext() { base::ResetAndReturn(&lost_context_callback_).Run(); } -void TestContextProvider::OnSwapBuffersComplete() { - DCHECK(context_thread_checker_.CalledOnValidThread()); - if (!swap_buffers_complete_callback_.is_null()) - swap_buffers_complete_callback_.Run(); -} - TestWebGraphicsContext3D* TestContextProvider::TestContext3d() { DCHECK(bound_); DCHECK(context_thread_checker_.CalledOnValidThread()); @@ -214,13 +182,6 @@ void TestContextProvider::SetLostContextCallback( lost_context_callback_ = cb; } -void TestContextProvider::SetSwapBuffersCompleteCallback( - const SwapBuffersCompleteCallback& cb) { - DCHECK(context_thread_checker_.CalledOnValidThread()); - DCHECK(swap_buffers_complete_callback_.is_null() || cb.is_null()); - swap_buffers_complete_callback_ = cb; -} - void TestContextProvider::SetMemoryPolicyChangedCallback( const MemoryPolicyChangedCallback& cb) { DCHECK(context_thread_checker_.CalledOnValidThread()); diff --git a/cc/test/test_context_provider.h b/cc/test/test_context_provider.h index 9eed424..cea9b35 100644 --- a/cc/test/test_context_provider.h +++ b/cc/test/test_context_provider.h @@ -7,6 +7,7 @@ #include "base/callback.h" #include "base/memory/scoped_ptr.h" +#include "base/memory/weak_ptr.h" #include "base/synchronization/lock.h" #include "base/threading/thread_checker.h" #include "cc/output/context_provider.h" @@ -39,8 +40,6 @@ class TestContextProvider : public cc::ContextProvider { virtual void VerifyContexts() OVERRIDE; virtual bool DestroyedOnMainThread() OVERRIDE; virtual void SetLostContextCallback(const LostContextCallback& cb) OVERRIDE; - virtual void SetSwapBuffersCompleteCallback( - const SwapBuffersCompleteCallback& cb) OVERRIDE; virtual void SetMemoryPolicyChangedCallback( const MemoryPolicyChangedCallback& cb) OVERRIDE; @@ -62,8 +61,8 @@ class TestContextProvider : public cc::ContextProvider { explicit TestContextProvider(scoped_ptr<TestWebGraphicsContext3D> context); virtual ~TestContextProvider(); + private: void OnLostContext(); - void OnSwapBuffersComplete(); TestContextSupport support_; @@ -78,15 +77,14 @@ class TestContextProvider : public cc::ContextProvider { bool destroyed_; LostContextCallback lost_context_callback_; - SwapBuffersCompleteCallback swap_buffers_complete_callback_; MemoryPolicyChangedCallback memory_policy_changed_callback_; class LostContextCallbackProxy; scoped_ptr<LostContextCallbackProxy> lost_context_callback_proxy_; - class SwapBuffersCompleteCallbackProxy; - scoped_ptr<SwapBuffersCompleteCallbackProxy> - swap_buffers_complete_callback_proxy_; + base::WeakPtrFactory<TestContextProvider> weak_ptr_factory_; + + DISALLOW_COPY_AND_ASSIGN(TestContextProvider); }; } // namespace cc diff --git a/cc/test/test_context_support.cc b/cc/test/test_context_support.cc index be0d363..ec010fc 100644 --- a/cc/test/test_context_support.cc +++ b/cc/test/test_context_support.cc @@ -4,11 +4,16 @@ #include "cc/test/test_context_support.h" +#include "base/bind.h" #include "base/message_loop/message_loop.h" namespace cc { -TestContextSupport::TestContextSupport() {} +TestContextSupport::TestContextSupport() + : last_swap_type_(NO_SWAP), + weak_ptr_factory_(this) { +} + TestContextSupport::~TestContextSupport() {} void TestContextSupport::SignalSyncPoint(uint32 sync_point, @@ -43,4 +48,31 @@ void TestContextSupport::SetSurfaceVisibleCallback( set_visible_callback_ = set_visible_callback; } +void TestContextSupport::Swap() { + last_swap_type_ = SWAP; + base::MessageLoop::current()->PostTask( + FROM_HERE, base::Bind(&TestContextSupport::OnSwapBuffersComplete, + weak_ptr_factory_.GetWeakPtr())); + CallAllSyncPointCallbacks(); +} + +void TestContextSupport::PartialSwapBuffers(gfx::Rect sub_buffer) { + last_swap_type_ = PARTIAL_SWAP; + last_partial_swap_rect_ = sub_buffer; + base::MessageLoop::current()->PostTask( + FROM_HERE, base::Bind(&TestContextSupport::OnSwapBuffersComplete, + weak_ptr_factory_.GetWeakPtr())); + CallAllSyncPointCallbacks(); +} + +void TestContextSupport::SetSwapBuffersCompleteCallback( + const base::Closure& callback) { + swap_buffers_complete_callback_ = callback; +} + +void TestContextSupport::OnSwapBuffersComplete() { + if (!swap_buffers_complete_callback_.is_null()) + swap_buffers_complete_callback_.Run(); +} + } // namespace cc diff --git a/cc/test/test_context_support.h b/cc/test/test_context_support.h index 9455e15..225ab7a 100644 --- a/cc/test/test_context_support.h +++ b/cc/test/test_context_support.h @@ -7,6 +7,7 @@ #include <vector> +#include "base/memory/weak_ptr.h" #include "gpu/command_buffer/client/context_support.h" namespace cc { @@ -24,6 +25,10 @@ class TestContextSupport : public gpu::ContextSupport { virtual void SetSurfaceVisible(bool visible) OVERRIDE; virtual void SendManagedMemoryStats(const gpu::ManagedMemoryStats& stats) OVERRIDE; + virtual void Swap() OVERRIDE; + virtual void PartialSwapBuffers(gfx::Rect sub_buffer) OVERRIDE; + virtual void SetSwapBuffersCompleteCallback( + const base::Closure& callback) OVERRIDE; void CallAllSyncPointCallbacks(); @@ -31,10 +36,30 @@ class TestContextSupport : public gpu::ContextSupport { void SetSurfaceVisibleCallback( const SurfaceVisibleCallback& set_visible_callback); + enum SwapType { + NO_SWAP, + SWAP, + PARTIAL_SWAP + }; + + SwapType last_swap_type() const { return last_swap_type_; } + gfx::Rect last_partial_swap_rect() const { + return last_partial_swap_rect_; + } + private: + void OnSwapBuffersComplete(); + std::vector<base::Closure> sync_point_callbacks_; SurfaceVisibleCallback set_visible_callback_; + base::Closure swap_buffers_complete_callback_; + + SwapType last_swap_type_; + gfx::Rect last_partial_swap_rect_; + + base::WeakPtrFactory<TestContextSupport> weak_ptr_factory_; + DISALLOW_COPY_AND_ASSIGN(TestContextSupport); }; diff --git a/cc/test/test_web_graphics_context_3d.cc b/cc/test/test_web_graphics_context_3d.cc index 7e972f7..91c8657 100644 --- a/cc/test/test_web_graphics_context_3d.cc +++ b/cc/test/test_web_graphics_context_3d.cc @@ -68,7 +68,6 @@ TestWebGraphicsContext3D::TestWebGraphicsContext3D() times_map_image_chromium_succeeds_(-1), times_map_buffer_chromium_succeeds_(-1), context_lost_callback_(NULL), - swap_buffers_callback_(NULL), next_program_id_(1000), next_shader_id_(2000), max_texture_size_(2048), @@ -84,7 +83,6 @@ TestWebGraphicsContext3D::TestWebGraphicsContext3D() peak_transfer_buffer_memory_used_bytes_(0), weak_ptr_factory_(this) { CreateNamespace(); - test_capabilities_.swapbuffers_complete_callback = true; } TestWebGraphicsContext3D::~TestWebGraphicsContext3D() { @@ -437,31 +435,6 @@ void TestWebGraphicsContext3D::loseContextCHROMIUM(WGC3Denum current, shared_contexts_.clear(); } -void TestWebGraphicsContext3D::setSwapBuffersCompleteCallbackCHROMIUM( - WebGraphicsSwapBuffersCompleteCallbackCHROMIUM* callback) { - if (test_capabilities_.swapbuffers_complete_callback) - swap_buffers_callback_ = callback; -} - -void TestWebGraphicsContext3D::prepareTexture() { - update_rect_ = gfx::Rect(width_, height_); - last_update_type_ = PrepareTexture; - - // TODO(jamesr): This should implemented as ContextSupport::SwapBuffers(). - if (swap_buffers_callback_) { - base::MessageLoop::current()->PostTask( - FROM_HERE, base::Bind(&TestWebGraphicsContext3D::SwapBuffersComplete, - weak_ptr_factory_.GetWeakPtr())); - } - test_support_->CallAllSyncPointCallbacks(); -} - -void TestWebGraphicsContext3D::postSubBufferCHROMIUM( - int x, int y, int width, int height) { - update_rect_ = gfx::Rect(x, y, width, height); - last_update_type_ = PostSubBuffer; -} - void TestWebGraphicsContext3D::finish() { test_support_->CallAllSyncPointCallbacks(); } @@ -470,11 +443,6 @@ void TestWebGraphicsContext3D::flush() { test_support_->CallAllSyncPointCallbacks(); } -void TestWebGraphicsContext3D::SwapBuffersComplete() { - if (swap_buffers_callback_) - swap_buffers_callback_->onSwapBuffersComplete(); -} - void TestWebGraphicsContext3D::bindBuffer(blink::WGC3Denum target, blink::WebGLId buffer) { bound_buffer_ = buffer; diff --git a/cc/test/test_web_graphics_context_3d.h b/cc/test/test_web_graphics_context_3d.h index 8ad285a..8ea74f3 100644 --- a/cc/test/test_web_graphics_context_3d.h +++ b/cc/test/test_web_graphics_context_3d.h @@ -125,11 +125,6 @@ class TestWebGraphicsContext3D : public FakeWebGraphicsContext3D { virtual void loseContextCHROMIUM(blink::WGC3Denum current, blink::WGC3Denum other); - virtual void setSwapBuffersCompleteCallbackCHROMIUM( - WebGraphicsSwapBuffersCompleteCallbackCHROMIUM* callback); - - virtual void prepareTexture(); - virtual void postSubBufferCHROMIUM(int x, int y, int width, int height); virtual void finish(); virtual void flush(); @@ -194,9 +189,6 @@ class TestWebGraphicsContext3D : public FakeWebGraphicsContext3D { } void ResetUsedTextures() { used_textures_.clear(); } - void set_support_swapbuffers_complete_callback(bool support) { - test_capabilities_.swapbuffers_complete_callback = support; - } void set_have_extension_io_surface(bool have) { test_capabilities_.iosurface = have; test_capabilities_.texture_rectangle = have; @@ -319,8 +311,6 @@ class TestWebGraphicsContext3D : public FakeWebGraphicsContext3D { TestWebGraphicsContext3D(); - void CallAllSyncPointCallbacks(); - void SwapBuffersComplete(); void CreateNamespace(); blink::WebGLId BoundTextureId(blink::WGC3Denum target); scoped_refptr<TestTexture> BoundTexture(blink::WGC3Denum target); @@ -336,7 +326,6 @@ class TestWebGraphicsContext3D : public FakeWebGraphicsContext3D { int times_map_image_chromium_succeeds_; int times_map_buffer_chromium_succeeds_; WebGraphicsContextLostCallback* context_lost_callback_; - WebGraphicsSwapBuffersCompleteCallbackCHROMIUM* swap_buffers_callback_; base::hash_set<unsigned> used_textures_; unsigned next_program_id_; base::hash_set<unsigned> program_set_; diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc index 59ee586..4630adc 100644 --- a/cc/trees/layer_tree_host_impl_unittest.cc +++ b/cc/trees/layer_tree_host_impl_unittest.cc @@ -3399,14 +3399,13 @@ TEST_F(LayerTreeHostImplTest, ReshapeNotCalledUntilDraw) { // Make sure damage tracking propagates all the way to the graphics context, // where it should request to swap only the sub-buffer that is damaged. TEST_F(LayerTreeHostImplTest, PartialSwapReceivesDamageRect) { - scoped_refptr<TestContextProvider> provider( + scoped_refptr<TestContextProvider> context_provider( TestContextProvider::Create()); - scoped_ptr<OutputSurface> output_surface( - FakeOutputSurface::Create3d(provider)); + context_provider->BindToCurrentThread(); + context_provider->TestContext3d()->set_have_post_sub_buffer(true); - provider->BindToCurrentThread(); - TestWebGraphicsContext3D* context = provider->TestContext3d(); - context->set_have_post_sub_buffer(true); + scoped_ptr<OutputSurface> output_surface( + FakeOutputSurface::Create3d(context_provider)); // This test creates its own LayerTreeHostImpl, so // that we can force partial swap enabled. @@ -3441,14 +3440,9 @@ TEST_F(LayerTreeHostImplTest, PartialSwapReceivesDamageRect) { layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now()); layer_tree_host_impl->DidDrawAllLayers(frame); layer_tree_host_impl->SwapBuffers(frame); - gfx::Rect actual_swap_rect = context->update_rect(); - gfx::Rect expected_swap_rect = gfx::Rect(0, 0, 500, 500); - EXPECT_EQ(expected_swap_rect.x(), actual_swap_rect.x()); - EXPECT_EQ(expected_swap_rect.y(), actual_swap_rect.y()); - EXPECT_EQ(expected_swap_rect.width(), actual_swap_rect.width()); - EXPECT_EQ(expected_swap_rect.height(), actual_swap_rect.height()); - EXPECT_EQ(context->last_update_type(), - TestWebGraphicsContext3D::PrepareTexture); + EXPECT_EQ(TestContextSupport::SWAP, + context_provider->support()->last_swap_type()); + // Second frame, only the damaged area should get swapped. Damage should be // the union of old and new child rects. // expected damage rect: gfx::Rect(26, 28); @@ -3459,18 +3453,17 @@ TEST_F(LayerTreeHostImplTest, PartialSwapReceivesDamageRect) { layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now()); host_impl_->DidDrawAllLayers(frame); layer_tree_host_impl->SwapBuffers(frame); - actual_swap_rect = context->update_rect(); - expected_swap_rect = gfx::Rect(0, 500-28, 26, 28); - EXPECT_EQ(expected_swap_rect.x(), actual_swap_rect.x()); - EXPECT_EQ(expected_swap_rect.y(), actual_swap_rect.y()); - EXPECT_EQ(expected_swap_rect.width(), actual_swap_rect.width()); - EXPECT_EQ(expected_swap_rect.height(), actual_swap_rect.height()); - EXPECT_EQ(context->last_update_type(), - TestWebGraphicsContext3D::PostSubBuffer); // Make sure that partial swap is constrained to the viewport dimensions // expected damage rect: gfx::Rect(500, 500); // expected swap rect: flipped damage rect, but also clamped to viewport + EXPECT_EQ(TestContextSupport::PARTIAL_SWAP, + context_provider->support()->last_swap_type()); + gfx::Rect expected_swap_rect(0, 500-28, 26, 28); + EXPECT_EQ(expected_swap_rect.ToString(), + context_provider->support()-> + last_partial_swap_rect().ToString()); + layer_tree_host_impl->SetViewportSize(gfx::Size(10, 10)); // This will damage everything. layer_tree_host_impl->active_tree()->root_layer()->SetBackgroundColor( @@ -3479,14 +3472,9 @@ TEST_F(LayerTreeHostImplTest, PartialSwapReceivesDamageRect) { layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now()); host_impl_->DidDrawAllLayers(frame); layer_tree_host_impl->SwapBuffers(frame); - actual_swap_rect = context->update_rect(); - expected_swap_rect = gfx::Rect(10, 10); - EXPECT_EQ(expected_swap_rect.x(), actual_swap_rect.x()); - EXPECT_EQ(expected_swap_rect.y(), actual_swap_rect.y()); - EXPECT_EQ(expected_swap_rect.width(), actual_swap_rect.width()); - EXPECT_EQ(expected_swap_rect.height(), actual_swap_rect.height()); - EXPECT_EQ(context->last_update_type(), - TestWebGraphicsContext3D::PrepareTexture); + + EXPECT_EQ(TestContextSupport::SWAP, + context_provider->support()->last_swap_type()); } TEST_F(LayerTreeHostImplTest, RootLayerDoesntCreateExtraSurface) { diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc index f6db62a..2d1357f 100644 --- a/cc/trees/layer_tree_host_unittest.cc +++ b/cc/trees/layer_tree_host_unittest.cc @@ -3025,7 +3025,6 @@ class LayerTreeHostTestDeferredInitialize : public LayerTreeHostTest { OVERRIDE { scoped_ptr<TestWebGraphicsContext3D> context3d( TestWebGraphicsContext3D::Create()); - context3d->set_support_swapbuffers_complete_callback(false); return FakeOutputSurface::CreateDeferredGL( scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice)) |