diff options
author | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-09 03:23:05 +0000 |
---|---|---|
committer | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-09 03:23:05 +0000 |
commit | 4c0e3d72a5ccdc72aace7e29f3d7458eaf5b7224 (patch) | |
tree | 76ad09e5752e9e0fcb1d6759b33af281b5d6502a /cc | |
parent | aa19e1206a6f005b719b3548aabd35126f361835 (diff) | |
download | chromium_src-4c0e3d72a5ccdc72aace7e29f3d7458eaf5b7224.zip chromium_src-4c0e3d72a5ccdc72aace7e29f3d7458eaf5b7224.tar.gz chromium_src-4c0e3d72a5ccdc72aace7e29f3d7458eaf5b7224.tar.bz2 |
cc: Implement DelegatingRender::drawFrame() method.
The method sends the render passes it is given to the parent compositor via
the output surface. It should include a valid frame metadata with it.
Tests:
DelegatingRendererTestDraw.runSingleThread
DelegatingRendererTestDraw.runMultiThread
DelegatingRendererTestResources.runSingleThread
DelegatingRendererTestResources.runMultiThread
R=piman
BUG=123444
Review URL: https://chromiumcodereview.appspot.com/11777025
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@175690 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
35 files changed, 359 insertions, 69 deletions
diff --git a/cc/cc_tests.gyp b/cc/cc_tests.gyp index 0fd86c2..1d4374a 100644 --- a/cc/cc_tests.gyp +++ b/cc/cc_tests.gyp @@ -12,6 +12,7 @@ 'damage_tracker_unittest.cc', 'delay_based_time_source_unittest.cc', 'delegated_renderer_layer_impl_unittest.cc', + 'delegating_renderer_unittest.cc', 'draw_quad_unittest.cc', 'float_quad_unittest.cc', 'frame_rate_controller_unittest.cc', diff --git a/cc/compositor_frame.cc b/cc/compositor_frame.cc index da66539..69119b0 100644 --- a/cc/compositor_frame.cc +++ b/cc/compositor_frame.cc @@ -10,4 +10,10 @@ CompositorFrame::CompositorFrame() {} CompositorFrame::~CompositorFrame() {} +void CompositorFrame::AssignTo(CompositorFrame* target) { + target->delegated_frame_data = delegated_frame_data.Pass(); + target->gl_frame_data = gl_frame_data.Pass(); + target->metadata = metadata; +} + } // namespace cc diff --git a/cc/compositor_frame.h b/cc/compositor_frame.h index 88ebe2f..b82f600 100644 --- a/cc/compositor_frame.h +++ b/cc/compositor_frame.h @@ -21,6 +21,8 @@ class CC_EXPORT CompositorFrame { CompositorFrameMetadata metadata; scoped_ptr<DelegatedFrameData> delegated_frame_data; scoped_ptr<GLFrameData> gl_frame_data; + + void AssignTo(CompositorFrame* target); }; } // namespace cc diff --git a/cc/delegating_renderer.cc b/cc/delegating_renderer.cc index da4bee4..1be86ea 100644 --- a/cc/delegating_renderer.cc +++ b/cc/delegating_renderer.cc @@ -12,6 +12,7 @@ #include "base/string_split.h" #include "base/string_util.h" #include "cc/checkerboard_draw_quad.h" +#include "cc/compositor_frame.h" #include "cc/compositor_frame_ack.h" #include "cc/debug_border_draw_quad.h" #include "cc/render_pass.h" @@ -28,17 +29,22 @@ using WebKit::WebGraphicsContext3D; namespace cc { scoped_ptr<DelegatingRenderer> DelegatingRenderer::Create( - RendererClient* client, ResourceProvider* resource_provider) { + RendererClient* client, + OutputSurface* output_surface, + ResourceProvider* resource_provider) { scoped_ptr<DelegatingRenderer> renderer( - new DelegatingRenderer(client, resource_provider)); + new DelegatingRenderer(client, output_surface, resource_provider)); if (!renderer->Initialize()) return scoped_ptr<DelegatingRenderer>(); return renderer.Pass(); } DelegatingRenderer::DelegatingRenderer( - RendererClient* client, ResourceProvider* resource_provider) + RendererClient* client, + OutputSurface* output_surface, + ResourceProvider* resource_provider) : Renderer(client), + output_surface_(output_surface), resource_provider_(resource_provider), visible_(true) { DCHECK(resource_provider_); @@ -128,7 +134,24 @@ const RendererCapabilities& DelegatingRenderer::capabilities() const { void DelegatingRenderer::drawFrame( RenderPassList& render_passes_in_draw_order) { TRACE_EVENT0("cc", "DelegatingRenderer::drawFrame"); - NOTIMPLEMENTED(); + + CompositorFrame out_frame; + out_frame.metadata = m_client->makeCompositorFrameMetadata(); + + out_frame.delegated_frame_data = make_scoped_ptr(new DelegatedFrameData); + DelegatedFrameData& out_data = *out_frame.delegated_frame_data; + + out_data.size = viewportSize(); + out_data.render_pass_list.swap(render_passes_in_draw_order); + + ResourceProvider::ResourceIdArray resources; + for (size_t i = 0; i < out_data.render_pass_list.size(); ++i) { + for (size_t j = 0; j < out_data.render_pass_list[i]->quad_list.size(); ++j) + out_data.render_pass_list[i]->quad_list[j]->AppendResources(&resources); + } + resource_provider_->prepareSendToParent(resources, &out_data.resource_list); + + output_surface_->SendFrameToParentCompositor(&out_frame); } bool DelegatingRenderer::swapBuffers() { diff --git a/cc/delegating_renderer.h b/cc/delegating_renderer.h index 5793079..d742dcb 100644 --- a/cc/delegating_renderer.h +++ b/cc/delegating_renderer.h @@ -12,6 +12,7 @@ namespace cc { +class OutputSurface; class ResourceProvider; class CC_EXPORT DelegatingRenderer : @@ -21,7 +22,9 @@ class CC_EXPORT DelegatingRenderer : { public: static scoped_ptr<DelegatingRenderer> Create( - RendererClient* client, ResourceProvider* resource_provider); + RendererClient* client, + OutputSurface* output_surface, + ResourceProvider* resource_provider); virtual ~DelegatingRenderer(); virtual const RendererCapabilities& capabilities() const OVERRIDE; @@ -50,9 +53,11 @@ class CC_EXPORT DelegatingRenderer : private: DelegatingRenderer(RendererClient* client, + OutputSurface* output_surface, ResourceProvider* resource_provider); bool Initialize(); + OutputSurface* output_surface_; ResourceProvider* resource_provider_; RendererCapabilities capabilities_; bool visible_; diff --git a/cc/delegating_renderer_unittest.cc b/cc/delegating_renderer_unittest.cc new file mode 100644 index 0000000..8ecfaa8 --- /dev/null +++ b/cc/delegating_renderer_unittest.cc @@ -0,0 +1,135 @@ +// Copyright 2013 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 "cc/delegating_renderer.h" + +#include "cc/test/fake_output_surface.h" +#include "cc/test/layer_tree_test_common.h" +#include "cc/test/render_pass_test_common.h" +#include "cc/test/render_pass_test_utils.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace cc { + +class DelegatingRendererTest : public ThreadedTest { + public: + DelegatingRendererTest() : ThreadedTest(), output_surface_(NULL) {} + virtual ~DelegatingRendererTest() {} + + virtual scoped_ptr<OutputSurface> createOutputSurface() OVERRIDE { + scoped_ptr<FakeWebGraphicsContext3D> context3d = + FakeWebGraphicsContext3D::Create( + WebKit::WebGraphicsContext3D::Attributes()); + context3d_ = context3d.get(); + scoped_ptr<FakeOutputSurface> output_surface = + FakeOutputSurface::CreateDelegating3d( + context3d.PassAs<WebKit::WebGraphicsContext3D>()); + output_surface_ = output_surface.get(); + return output_surface.PassAs<OutputSurface>(); + } + + protected: + FakeWebGraphicsContext3D* context3d_; + FakeOutputSurface* output_surface_; +}; + +class DelegatingRendererTestDraw : public DelegatingRendererTest { + public: + virtual void beginTest() OVERRIDE { + m_layerTreeHost->setPageScaleFactorAndLimits(1.f, 0.5f, 4.f); + postSetNeedsCommitToMainThread(); + } + + virtual void afterTest() OVERRIDE {} + + virtual bool prepareToDrawOnThread( + LayerTreeHostImpl*, LayerTreeHostImpl::FrameData& frame, bool result) + OVERRIDE { + EXPECT_EQ(0u, output_surface_->num_sent_frames()); + + CompositorFrame& last_frame = output_surface_->last_sent_frame(); + EXPECT_FALSE(last_frame.delegated_frame_data); + EXPECT_FALSE(last_frame.gl_frame_data); + EXPECT_EQ(0.f, last_frame.metadata.min_page_scale_factor); + EXPECT_EQ(0.f, last_frame.metadata.max_page_scale_factor); + return true; + } + + virtual void drawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { + EXPECT_EQ(1u, output_surface_->num_sent_frames()); + + CompositorFrame& last_frame = output_surface_->last_sent_frame(); + ASSERT_TRUE(last_frame.delegated_frame_data); + EXPECT_FALSE(last_frame.gl_frame_data); + EXPECT_EQ( + host_impl->deviceViewportSize().ToString(), + last_frame.delegated_frame_data->size.ToString()); + EXPECT_EQ(0.5f, last_frame.metadata.min_page_scale_factor); + EXPECT_EQ(4.f, last_frame.metadata.max_page_scale_factor); + + EXPECT_EQ( + 0u, last_frame.delegated_frame_data->resource_list.resources.size()); + EXPECT_EQ(1u, last_frame.delegated_frame_data->render_pass_list.size()); + + endTest(); + } +}; + +SINGLE_AND_MULTI_THREAD_TEST_F(DelegatingRendererTestDraw) + +class DelegatingRendererTestResources : public DelegatingRendererTest { + public: + virtual void beginTest() OVERRIDE { + postSetNeedsCommitToMainThread(); + } + + virtual void afterTest() OVERRIDE {} + + virtual bool prepareToDrawOnThread( + LayerTreeHostImpl* host_impl, + LayerTreeHostImpl::FrameData& frame, + bool result) OVERRIDE { + + frame.renderPasses.clear(); + frame.renderPassesById.clear(); + + TestRenderPass* child_pass = addRenderPass( + frame.renderPasses, + RenderPass::Id(2, 1), + gfx::Rect(3, 3, 10, 10), + gfx::Transform()); + child_pass->AppendOneOfEveryQuadType( + host_impl->resourceProvider(), RenderPass::Id(0, 0)); + + TestRenderPass* pass = addRenderPass( + frame.renderPasses, + RenderPass::Id(1, 1), + gfx::Rect(3, 3, 10, 10), + gfx::Transform()); + pass->AppendOneOfEveryQuadType( + host_impl->resourceProvider(), child_pass->id); + return true; + } + + virtual void drawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { + EXPECT_EQ(1u, output_surface_->num_sent_frames()); + + CompositorFrame& last_frame = output_surface_->last_sent_frame(); + ASSERT_TRUE(last_frame.delegated_frame_data); + + EXPECT_EQ(2u, last_frame.delegated_frame_data->render_pass_list.size()); + // Each render pass has 7 resources in it. And the root render pass has a + // mask resource used when drawing the child render pass. The number 7 may + // change if AppendOneOfEveryQuadType is updated, and the value here should + // be updated accordingly. + EXPECT_EQ( + 15u, last_frame.delegated_frame_data->resource_list.resources.size()); + + endTest(); + } +}; + +SINGLE_AND_MULTI_THREAD_TEST_F(DelegatingRendererTestResources) + +} // namespace cc diff --git a/cc/draw_quad.cc b/cc/draw_quad.cc index 47f9aa0..d1f2806 100644 --- a/cc/draw_quad.cc +++ b/cc/draw_quad.cc @@ -89,4 +89,6 @@ scoped_ptr<DrawQuad> DrawQuad::Copy( return copy_quad.Pass(); } +void DrawQuad::AppendResources(ResourceProvider::ResourceIdArray* resources) {} + } // namespace cc diff --git a/cc/draw_quad.h b/cc/draw_quad.h index c1982c1..bc88690 100644 --- a/cc/draw_quad.h +++ b/cc/draw_quad.h @@ -6,6 +6,7 @@ #define CC_DRAW_QUAD_H_ #include "cc/cc_export.h" +#include "cc/resource_provider.h" #include "cc/shared_quad_state.h" namespace cc { @@ -71,6 +72,8 @@ class CC_EXPORT DrawQuad { !opaque_rect.Contains(visible_rect); } + virtual void AppendResources(ResourceProvider::ResourceIdArray* resources); + protected: DrawQuad(); diff --git a/cc/gl_renderer.cc b/cc/gl_renderer.cc index 54eef96..4ae1503 100644 --- a/cc/gl_renderer.cc +++ b/cc/gl_renderer.cc @@ -1174,7 +1174,7 @@ void GLRenderer::finishDrawingFrame(DrawingFrame& frame) compositor_frame.metadata = m_client->makeCompositorFrameMetadata(); compositor_frame.gl_frame_data.reset(new GLFrameData()); // FIXME: Fill in GLFrameData when we implement swapping with it. - m_outputSurface->SendFrameToParentCompositor(compositor_frame); + m_outputSurface->SendFrameToParentCompositor(&compositor_frame); } } diff --git a/cc/gl_renderer_unittest.cc b/cc/gl_renderer_unittest.cc index 5a355dd..0f5862f 100644 --- a/cc/gl_renderer_unittest.cc +++ b/cc/gl_renderer_unittest.cc @@ -538,7 +538,7 @@ TEST(GLRendererTest2, activeTextureState) cc::RenderPass::Id id(1, 1); scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); pass->SetNew(id, gfx::Rect(0, 0, 100, 100), gfx::Rect(0, 0, 100, 100), gfx::Transform()); - pass->AppendOneOfEveryQuadType(resourceProvider.get()); + pass->AppendOneOfEveryQuadType(resourceProvider.get(), RenderPass::Id(2, 1)); // Set up expected texture filter state transitions that match the quads // created in AppendOneOfEveryQuadType(). @@ -546,7 +546,7 @@ TEST(GLRendererTest2, activeTextureState) { InSequence sequence; - // yuv_quad is drawn with the default filter. + // yuv_quad is drawn with the default linear filter. EXPECT_CALL(*context, drawElements(_, _, _, _)); // tile_quad is drawn with GL_NEAREST because it is not transformed or @@ -556,8 +556,6 @@ TEST(GLRendererTest2, activeTextureState) EXPECT_CALL(*context, drawElements(_, _, _, _)); // transformed_tile_quad uses GL_LINEAR. - EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); - EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); EXPECT_CALL(*context, drawElements(_, _, _, _)); // scaled_tile_quad also uses GL_LINEAR. diff --git a/cc/io_surface_draw_quad.cc b/cc/io_surface_draw_quad.cc index 4851df1..561a992 100644 --- a/cc/io_surface_draw_quad.cc +++ b/cc/io_surface_draw_quad.cc @@ -47,6 +47,12 @@ void IOSurfaceDrawQuad::SetAll(const SharedQuadState* shared_quad_state, this->orientation = orientation; } +void IOSurfaceDrawQuad::AppendResources( + ResourceProvider::ResourceIdArray* resources) { + // TODO(danakj): Convert to TextureDrawQuad? + NOTIMPLEMENTED(); +} + const IOSurfaceDrawQuad* IOSurfaceDrawQuad::MaterialCast( const DrawQuad* quad) { DCHECK(quad->material == DrawQuad::IO_SURFACE_CONTENT); diff --git a/cc/io_surface_draw_quad.h b/cc/io_surface_draw_quad.h index 2bce6b7..14368dc 100644 --- a/cc/io_surface_draw_quad.h +++ b/cc/io_surface_draw_quad.h @@ -41,6 +41,9 @@ class CC_EXPORT IOSurfaceDrawQuad : public DrawQuad { unsigned io_surface_texture_id; Orientation orientation; + virtual void AppendResources(ResourceProvider::ResourceIdArray* resources) + OVERRIDE; + static const IOSurfaceDrawQuad* MaterialCast(const DrawQuad*); private: IOSurfaceDrawQuad(); diff --git a/cc/layer_tree_host_impl.cc b/cc/layer_tree_host_impl.cc index 9c217b0..142839a 100644 --- a/cc/layer_tree_host_impl.cc +++ b/cc/layer_tree_host_impl.cc @@ -860,19 +860,20 @@ void LayerTreeHostImpl::OnCanDrawStateChangedForTree(LayerTreeImpl*) CompositorFrameMetadata LayerTreeHostImpl::makeCompositorFrameMetadata() const { - if (!rootScrollLayer()) - return CompositorFrameMetadata(); - CompositorFrameMetadata metadata; - metadata.root_scroll_offset = rootScrollLayer()->scrollOffset() + rootScrollLayer()->scrollDelta(); - if (!m_settings.pageScalePinchZoomEnabled) - metadata.root_scroll_offset.Scale(1 / m_pinchZoomViewport.pageScaleFactor()); metadata.page_scale_factor = m_pinchZoomViewport.totalPageScaleFactor(); metadata.viewport_size = m_pinchZoomViewport.bounds().size(); metadata.root_layer_size = contentSize(); metadata.min_page_scale_factor = m_pinchZoomViewport.minPageScaleFactor(); metadata.max_page_scale_factor = m_pinchZoomViewport.maxPageScaleFactor(); + if (!rootScrollLayer()) + return metadata; + + metadata.root_scroll_offset = rootScrollLayer()->scrollOffset() + rootScrollLayer()->scrollDelta(); + if (!m_settings.pageScalePinchZoomEnabled) + metadata.root_scroll_offset.Scale(1 / m_pinchZoomViewport.pageScaleFactor()); + return metadata; } @@ -1077,7 +1078,7 @@ bool LayerTreeHostImpl::initializeRenderer(scoped_ptr<OutputSurface> outputSurfa m_tileManager.reset(new TileManager(this, resourceProvider.get(), m_settings.numRasterThreads)); if (outputSurface->Capabilities().has_parent_compositor) - m_renderer = DelegatingRenderer::Create(this, resourceProvider.get()); + m_renderer = DelegatingRenderer::Create(this, outputSurface.get(), resourceProvider.get()); else if (outputSurface->Context3D()) m_renderer = GLRenderer::create(this, outputSurface.get(), resourceProvider.get()); else if (outputSurface->SoftwareDevice()) diff --git a/cc/layer_tree_host_unittest_animation.cc b/cc/layer_tree_host_unittest_animation.cc index 173d73e..7639e02 100644 --- a/cc/layer_tree_host_unittest_animation.cc +++ b/cc/layer_tree_host_unittest_animation.cc @@ -180,7 +180,10 @@ class LayerTreeHostAnimationTestCheckerboardDoesNotStarveDraws : endTest(); } - virtual bool prepareToDrawOnThread(LayerTreeHostImpl*) OVERRIDE { + virtual bool prepareToDrawOnThread( + LayerTreeHostImpl* host_impl, + LayerTreeHostImpl::FrameData& frame, + bool result) OVERRIDE { return false; } diff --git a/cc/layer_tree_host_unittest_context.cc b/cc/layer_tree_host_unittest_context.cc index 4e93ca8..51f5e60 100644 --- a/cc/layer_tree_host_unittest_context.cc +++ b/cc/layer_tree_host_unittest_context.cc @@ -690,7 +690,7 @@ class LayerTreeHostContextTestDontUseLostResources : gfx::Rect(0, 0, 10, 10), gfx::Rect(0, 0, 10, 10), gfx::Transform()); - pass->AppendOneOfEveryQuadType(resource_provider); + pass->AppendOneOfEveryQuadType(resource_provider, RenderPass::Id(2, 1)); ScopedPtrVector<RenderPass> pass_list; pass_list.append(pass_for_quad.PassAs<RenderPass>()); @@ -735,7 +735,10 @@ class LayerTreeHostContextTestDontUseLostResources : } } - virtual bool prepareToDrawOnThread(LayerTreeHostImpl* host_impl) { + virtual bool prepareToDrawOnThread( + LayerTreeHostImpl* host_impl, + LayerTreeHostImpl::FrameData& frame, + bool result) OVERRIDE { if (host_impl->activeTree()->source_frame_number() == 2) { // Lose the context during draw on the second commit. This will cause // a third commit to recover. diff --git a/cc/output_surface.h b/cc/output_surface.h index 3d62f18..4906ec3 100644 --- a/cc/output_surface.h +++ b/cc/output_surface.h @@ -54,8 +54,9 @@ class CC_EXPORT OutputSurface : public WebKit::WebCompositorOutputSurface { virtual SoftwareOutputDevice* SoftwareDevice() const = 0; // Sends frame data to the parent compositor. This should only be called when - // capabilities().has_parent_compositor. - virtual void SendFrameToParentCompositor(const CompositorFrame&) {} + // capabilities().has_parent_compositor. The implementation may destroy or + // steal the contents of the CompositorFrame passed in. + virtual void SendFrameToParentCompositor(CompositorFrame*) = 0; }; } // namespace cc diff --git a/cc/render_pass_draw_quad.cc b/cc/render_pass_draw_quad.cc index b46d3b7..fec3ce0 100644 --- a/cc/render_pass_draw_quad.cc +++ b/cc/render_pass_draw_quad.cc @@ -81,6 +81,11 @@ void RenderPassDrawQuad::SetAll( this->background_filters = background_filters; } +void RenderPassDrawQuad::AppendResources( + ResourceProvider::ResourceIdArray* resources) { + resources->push_back(mask_resource_id); +} + const RenderPassDrawQuad* RenderPassDrawQuad::MaterialCast( const DrawQuad* quad) { DCHECK(quad->material == DrawQuad::RENDER_PASS); diff --git a/cc/render_pass_draw_quad.h b/cc/render_pass_draw_quad.h index 27187c5..893de4d 100644 --- a/cc/render_pass_draw_quad.h +++ b/cc/render_pass_draw_quad.h @@ -65,6 +65,9 @@ class CC_EXPORT RenderPassDrawQuad : public DrawQuad { // background of the render pass, from behind it. WebKit::WebFilterOperations background_filters; + virtual void AppendResources(ResourceProvider::ResourceIdArray* resources) + OVERRIDE; + static const RenderPassDrawQuad* MaterialCast(const DrawQuad*); private: diff --git a/cc/stream_video_draw_quad.cc b/cc/stream_video_draw_quad.cc index 91cf3e2..9dd64b8 100644 --- a/cc/stream_video_draw_quad.cc +++ b/cc/stream_video_draw_quad.cc @@ -40,6 +40,12 @@ void StreamVideoDrawQuad::SetAll(const SharedQuadState* shared_quad_state, this->matrix = matrix; } +void StreamVideoDrawQuad::AppendResources( + ResourceProvider::ResourceIdArray* resources) { + // TODO(danakj): Convert to TextureDrawQuad? + NOTIMPLEMENTED(); +} + const StreamVideoDrawQuad* StreamVideoDrawQuad::MaterialCast( const DrawQuad* quad) { DCHECK(quad->material == DrawQuad::STREAM_VIDEO_CONTENT); diff --git a/cc/stream_video_draw_quad.h b/cc/stream_video_draw_quad.h index 897f45d..dfcbb3e 100644 --- a/cc/stream_video_draw_quad.h +++ b/cc/stream_video_draw_quad.h @@ -33,6 +33,9 @@ class CC_EXPORT StreamVideoDrawQuad : public DrawQuad { unsigned texture_id; gfx::Transform matrix; + virtual void AppendResources(ResourceProvider::ResourceIdArray* resources) + OVERRIDE; + static const StreamVideoDrawQuad* MaterialCast(const DrawQuad*); private: StreamVideoDrawQuad(); diff --git a/cc/test/fake_output_surface.cc b/cc/test/fake_output_surface.cc index a312041..ebbe783 100644 --- a/cc/test/fake_output_surface.cc +++ b/cc/test/fake_output_surface.cc @@ -7,13 +7,15 @@ namespace cc { FakeOutputSurface::FakeOutputSurface( - scoped_ptr<WebKit::WebGraphicsContext3D> context3d, bool has_parent) { + scoped_ptr<WebKit::WebGraphicsContext3D> context3d, bool has_parent) + : num_sent_frames_(0) { context3d_ = context3d.Pass(); capabilities_.has_parent_compositor = has_parent; } FakeOutputSurface::FakeOutputSurface( - scoped_ptr<SoftwareOutputDevice> software_device, bool has_parent) { + scoped_ptr<SoftwareOutputDevice> software_device, bool has_parent) + : num_sent_frames_(0) { software_device_ = software_device.Pass(); capabilities_.has_parent_compositor = has_parent; } @@ -43,6 +45,10 @@ SoftwareOutputDevice* FakeOutputSurface::SoftwareDevice() const { return software_device_.get(); } -void FakeOutputSurface::SendFrameToParentCompositor(const CompositorFrame&) {} +void FakeOutputSurface::SendFrameToParentCompositor( + CompositorFrame* frame) { + frame->AssignTo(&last_sent_frame_); + ++num_sent_frames_; +} } // namespace cc diff --git a/cc/test/fake_output_surface.h b/cc/test/fake_output_surface.h index d843cca..0cfb41f 100644 --- a/cc/test/fake_output_surface.h +++ b/cc/test/fake_output_surface.h @@ -7,6 +7,7 @@ #include "base/logging.h" #include "base/memory/scoped_ptr.h" +#include "cc/compositor_frame.h" #include "cc/output_surface.h" #include "cc/test/fake_software_output_device.h" #include "cc/test/fake_web_graphics_context_3d.h" @@ -47,7 +48,10 @@ class FakeOutputSurface : public OutputSurface { virtual WebKit::WebGraphicsContext3D* Context3D() const OVERRIDE; virtual SoftwareOutputDevice* SoftwareDevice() const OVERRIDE; - virtual void SendFrameToParentCompositor(const CompositorFrame&) OVERRIDE; + virtual void SendFrameToParentCompositor(CompositorFrame*) OVERRIDE; + + CompositorFrame& last_sent_frame() { return last_sent_frame_; } + size_t num_sent_frames() { return num_sent_frames_; } private: explicit FakeOutputSurface( @@ -59,6 +63,8 @@ private: scoped_ptr<SoftwareOutputDevice> software_device_; struct Capabilities capabilities_; OutputSurfaceClient* client_; + CompositorFrame last_sent_frame_; + size_t num_sent_frames_; }; static inline scoped_ptr<cc::OutputSurface> createFakeOutputSurface() diff --git a/cc/test/layer_tree_test_common.cc b/cc/test/layer_tree_test_common.cc index cfe6861..f710f4b 100644 --- a/cc/test/layer_tree_test_common.cc +++ b/cc/test/layer_tree_test_common.cc @@ -29,7 +29,7 @@ using namespace WebKit; namespace cc { -bool TestHooks::prepareToDrawOnThread(cc::LayerTreeHostImpl*) +bool TestHooks::prepareToDrawOnThread(cc::LayerTreeHostImpl*, LayerTreeHostImpl::FrameData&, bool) { return true; } @@ -64,7 +64,7 @@ void MockLayerTreeHostImpl::commitComplete() bool MockLayerTreeHostImpl::prepareToDraw(FrameData& frame) { bool result = LayerTreeHostImpl::prepareToDraw(frame); - if (!m_testHooks->prepareToDrawOnThread(this)) + if (!m_testHooks->prepareToDrawOnThread(this, frame, result)) result = false; return result; } diff --git a/cc/test/layer_tree_test_common.h b/cc/test/layer_tree_test_common.h index 3b0cfd6..682edec 100644 --- a/cc/test/layer_tree_test_common.h +++ b/cc/test/layer_tree_test_common.h @@ -24,7 +24,8 @@ class TestHooks : public WebKit::WebAnimationDelegate { public: virtual void beginCommitOnThread(LayerTreeHostImpl*) { } virtual void commitCompleteOnThread(LayerTreeHostImpl*) { } - virtual bool prepareToDrawOnThread(LayerTreeHostImpl*); + virtual bool prepareToDrawOnThread( + LayerTreeHostImpl*, LayerTreeHostImpl::FrameData&, bool result); virtual void drawLayersOnThread(LayerTreeHostImpl*) { } virtual void animateLayers(LayerTreeHostImpl*, base::TimeTicks monotonicTime, bool hasUnfinishedAnimation) { } virtual void willAnimateLayers(LayerTreeHostImpl*, base::TimeTicks monotonicTime) { } diff --git a/cc/test/pixel_test_output_surface.h b/cc/test/pixel_test_output_surface.h index b3f26c41..91d789f 100644 --- a/cc/test/pixel_test_output_surface.h +++ b/cc/test/pixel_test_output_surface.h @@ -24,7 +24,7 @@ class PixelTestOutputSurface : public OutputSurface { OVERRIDE; virtual WebKit::WebGraphicsContext3D* Context3D() const OVERRIDE; virtual SoftwareOutputDevice* SoftwareDevice() const OVERRIDE; - virtual void SendFrameToParentCompositor(const CompositorFrame&) OVERRIDE {} + virtual void SendFrameToParentCompositor(CompositorFrame*) OVERRIDE {} private: PixelTestOutputSurface(); diff --git a/cc/test/render_pass_test_common.cc b/cc/test/render_pass_test_common.cc index b66ca4f..b0b2281 100644 --- a/cc/test/render_pass_test_common.cc +++ b/cc/test/render_pass_test_common.cc @@ -20,7 +20,7 @@ namespace cc { void TestRenderPass::AppendOneOfEveryQuadType( - cc::ResourceProvider* resourceProvider) { + cc::ResourceProvider* resourceProvider, RenderPass::Id child_pass) { gfx::Rect rect(0, 0, 100, 100); gfx::Rect opaque_rect(10, 10, 80, 80); const float vertex_opacity[] = {1.0f, 1.0f, 1.0f, 1.0f}; @@ -31,6 +31,31 @@ void TestRenderPass::AppendOneOfEveryQuadType( ResourceProvider::TextureUsageAny); unsigned texture_id = ResourceProvider::ScopedReadLockGL( resourceProvider, texture_resource).textureId(); + cc::ResourceProvider::ResourceId resource1 = + resourceProvider->createResource( + gfx::Size(45, 5), + resourceProvider->bestTextureFormat(), + ResourceProvider::TextureUsageAny); + cc::ResourceProvider::ResourceId resource2 = + resourceProvider->createResource( + gfx::Size(346, 61), + resourceProvider->bestTextureFormat(), + ResourceProvider::TextureUsageAny); + cc::ResourceProvider::ResourceId resource3 = + resourceProvider->createResource( + gfx::Size(12, 134), + resourceProvider->bestTextureFormat(), + ResourceProvider::TextureUsageAny); + cc::ResourceProvider::ResourceId resource4 = + resourceProvider->createResource( + gfx::Size(56, 12), + resourceProvider->bestTextureFormat(), + ResourceProvider::TextureUsageAny); + cc::ResourceProvider::ResourceId resource5 = + resourceProvider->createResource( + gfx::Size(73, 26), + resourceProvider->bestTextureFormat(), + ResourceProvider::TextureUsageAny); scoped_ptr<cc::SharedQuadState> shared_state = cc::SharedQuadState::Create(); shared_state->SetAll(gfx::Transform(), @@ -65,19 +90,35 @@ void TestRenderPass::AppendOneOfEveryQuadType( cc::IOSurfaceDrawQuad::FLIPPED); AppendQuad(io_surface_quad.PassAs<DrawQuad>()); - scoped_ptr<cc::RenderPassDrawQuad> render_pass_quad = - cc::RenderPassDrawQuad::Create(); - render_pass_quad->SetNew(shared_state.get(), - rect, - cc::RenderPass::Id(1, 1), - false, - 0, - rect, - gfx::RectF(), - WebKit::WebFilterOperations(), - skia::RefPtr<SkImageFilter>(), - WebKit::WebFilterOperations()); - AppendQuad(render_pass_quad.PassAs<DrawQuad>()); + if (child_pass.layer_id) { + scoped_ptr<cc::RenderPassDrawQuad> render_pass_quad = + cc::RenderPassDrawQuad::Create(); + render_pass_quad->SetNew(shared_state.get(), + rect, + child_pass, + false, + resource5, + rect, + gfx::RectF(), + WebKit::WebFilterOperations(), + skia::RefPtr<SkImageFilter>(), + WebKit::WebFilterOperations()); + AppendQuad(render_pass_quad.PassAs<DrawQuad>()); + + scoped_ptr<cc::RenderPassDrawQuad> render_pass_replica_quad = + cc::RenderPassDrawQuad::Create(); + render_pass_replica_quad->SetNew(shared_state.get(), + rect, + child_pass, + true, + resource5, + rect, + gfx::RectF(), + WebKit::WebFilterOperations(), + skia::RefPtr<SkImageFilter>(), + WebKit::WebFilterOperations()); + AppendQuad(render_pass_replica_quad.PassAs<DrawQuad>()); + } scoped_ptr<cc::SolidColorDrawQuad> solid_color_quad = cc::SolidColorDrawQuad::Create(); @@ -100,7 +141,7 @@ void TestRenderPass::AppendOneOfEveryQuadType( texture_quad->SetNew(shared_state.get(), rect, opaque_rect, - texture_resource, + resource1, false, rect, vertex_opacity, @@ -110,16 +151,16 @@ void TestRenderPass::AppendOneOfEveryQuadType( scoped_ptr<cc::TileDrawQuad> scaled_tile_quad = cc::TileDrawQuad::Create(); scaled_tile_quad->SetNew(shared_state.get(), - rect, - opaque_rect, - texture_resource, - gfx::RectF(0, 0, 50, 50), - gfx::Size(50, 50), - false, - false, - false, - false, - false); + rect, + opaque_rect, + resource2, + gfx::RectF(0, 0, 50, 50), + gfx::Size(50, 50), + false, + false, + false, + false, + false); AppendQuad(scaled_tile_quad.PassAs<DrawQuad>()); scoped_ptr<cc::SharedQuadState> transformed_state = shared_state->Copy(); @@ -129,16 +170,16 @@ void TestRenderPass::AppendOneOfEveryQuadType( scoped_ptr<cc::TileDrawQuad> transformed_tile_quad = cc::TileDrawQuad::Create(); transformed_tile_quad->SetNew(transformed_state.get(), - rect, - opaque_rect, - texture_resource, - gfx::RectF(0, 0, 100, 100), - gfx::Size(100, 100), - false, - false, - false, - false, - false); + rect, + opaque_rect, + resource3, + gfx::RectF(0, 0, 100, 100), + gfx::Size(100, 100), + false, + false, + false, + false, + false); AppendQuad(transformed_tile_quad.PassAs<DrawQuad>()); scoped_ptr<cc::TileDrawQuad> tile_quad = @@ -146,7 +187,7 @@ void TestRenderPass::AppendOneOfEveryQuadType( tile_quad->SetNew(shared_state.get(), rect, opaque_rect, - texture_resource, + resource4, gfx::RectF(0, 0, 100, 100), gfx::Size(100, 100), false, diff --git a/cc/test/render_pass_test_common.h b/cc/test/render_pass_test_common.h index c565df0..b1f00de 100644 --- a/cc/test/render_pass_test_common.h +++ b/cc/test/render_pass_test_common.h @@ -26,7 +26,8 @@ class TestRenderPass : public cc::RenderPass { shared_quad_state_list.append(state.Pass()); } - void AppendOneOfEveryQuadType(cc::ResourceProvider*); + void AppendOneOfEveryQuadType( + cc::ResourceProvider*, RenderPass::Id child_pass); protected: TestRenderPass() : RenderPass() {} diff --git a/cc/test/render_pass_test_utils.cc b/cc/test/render_pass_test_utils.cc index aa0cc034..1aa97f0 100644 --- a/cc/test/render_pass_test_utils.cc +++ b/cc/test/render_pass_test_utils.cc @@ -15,7 +15,7 @@ namespace cc { -TestRenderPass* addRenderPass(ScopedPtrVector<RenderPass>& passList, +TestRenderPass* addRenderPass(RenderPassList& passList, RenderPass::Id id, const gfx::Rect& outputRect, const gfx::Transform& rootTransform) { diff --git a/cc/test/render_pass_test_utils.h b/cc/test/render_pass_test_utils.h index 140e029..b4d8dba 100644 --- a/cc/test/render_pass_test_utils.h +++ b/cc/test/render_pass_test_utils.h @@ -22,7 +22,7 @@ class TestRenderPass; // Adds a new render pass with the provided properties to the given // render pass list. TestRenderPass* addRenderPass( - ScopedPtrVector<RenderPass>& passList, + RenderPassList& passList, RenderPass::Id id, const gfx::Rect& outputRect, const gfx::Transform& rootTransform); diff --git a/cc/texture_draw_quad.cc b/cc/texture_draw_quad.cc index adce50f..c890498 100644 --- a/cc/texture_draw_quad.cc +++ b/cc/texture_draw_quad.cc @@ -56,6 +56,11 @@ void TextureDrawQuad::SetAll(const SharedQuadState* shared_quad_state, this->flipped = flipped; } +void TextureDrawQuad::AppendResources( + ResourceProvider::ResourceIdArray* resources) { + resources->push_back(resource_id); +} + const TextureDrawQuad* TextureDrawQuad::MaterialCast(const DrawQuad* quad) { DCHECK(quad->material == DrawQuad::TEXTURE_CONTENT); return static_cast<const TextureDrawQuad*>(quad); diff --git a/cc/texture_draw_quad.h b/cc/texture_draw_quad.h index 8a420fd..6ec2934 100644 --- a/cc/texture_draw_quad.h +++ b/cc/texture_draw_quad.h @@ -42,6 +42,9 @@ class CC_EXPORT TextureDrawQuad : public DrawQuad { float vertex_opacity[4]; bool flipped; + virtual void AppendResources(ResourceProvider::ResourceIdArray* resources) + OVERRIDE; + static const TextureDrawQuad* MaterialCast(const DrawQuad*); bool PerformClipping(); diff --git a/cc/tile_draw_quad.cc b/cc/tile_draw_quad.cc index 965bb03..d33feb7 100644 --- a/cc/tile_draw_quad.cc +++ b/cc/tile_draw_quad.cc @@ -75,6 +75,11 @@ void TileDrawQuad::SetAll(const SharedQuadState* shared_quad_state, this->bottom_edge_aa = bottom_edge_aa; } +void TileDrawQuad::AppendResources( + ResourceProvider::ResourceIdArray* resources) { + resources->push_back(resource_id); +} + const TileDrawQuad* TileDrawQuad::MaterialCast( const DrawQuad* quad) { DCHECK(quad->material == DrawQuad::TILED_CONTENT); diff --git a/cc/tile_draw_quad.h b/cc/tile_draw_quad.h index ae41d4ab..1bc9783 100644 --- a/cc/tile_draw_quad.h +++ b/cc/tile_draw_quad.h @@ -60,6 +60,9 @@ class CC_EXPORT TileDrawQuad : public DrawQuad { return left_edge_aa || top_edge_aa || right_edge_aa || bottom_edge_aa; } + virtual void AppendResources(ResourceProvider::ResourceIdArray* resources) + OVERRIDE; + static const TileDrawQuad* MaterialCast(const DrawQuad*); private: TileDrawQuad(); diff --git a/cc/yuv_video_draw_quad.cc b/cc/yuv_video_draw_quad.cc index dcb4369..891cf94 100644 --- a/cc/yuv_video_draw_quad.cc +++ b/cc/yuv_video_draw_quad.cc @@ -49,6 +49,13 @@ void YUVVideoDrawQuad::SetAll(const SharedQuadState* shared_quad_state, this->v_plane = v_plane; } +void YUVVideoDrawQuad::AppendResources( + ResourceProvider::ResourceIdArray* resources) { + resources->push_back(y_plane.resourceId); + resources->push_back(u_plane.resourceId); + resources->push_back(v_plane.resourceId); +} + const YUVVideoDrawQuad* YUVVideoDrawQuad::MaterialCast( const DrawQuad* quad) { DCHECK(quad->material == DrawQuad::YUV_VIDEO_CONTENT); diff --git a/cc/yuv_video_draw_quad.h b/cc/yuv_video_draw_quad.h index 9f03d99..13c24cf 100644 --- a/cc/yuv_video_draw_quad.h +++ b/cc/yuv_video_draw_quad.h @@ -42,6 +42,9 @@ class CC_EXPORT YUVVideoDrawQuad : public DrawQuad { VideoLayerImpl::FramePlane u_plane; VideoLayerImpl::FramePlane v_plane; + virtual void AppendResources(ResourceProvider::ResourceIdArray* resources) + OVERRIDE; + static const YUVVideoDrawQuad* MaterialCast(const DrawQuad*); private: YUVVideoDrawQuad(); |