diff options
author | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-10 17:53:30 +0000 |
---|---|---|
committer | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-10 17:53:30 +0000 |
commit | 59fee305b4eb62b3f6b710e4d5e19487fff7993d (patch) | |
tree | f1791f2f9c8749469525217fb93fb5cb69c017cf /cc/test | |
parent | 8e62c624a2ca76440e29c3fe929120f534ea1f8a (diff) | |
download | chromium_src-59fee305b4eb62b3f6b710e4d5e19487fff7993d.zip chromium_src-59fee305b4eb62b3f6b710e4d5e19487fff7993d.tar.gz chromium_src-59fee305b4eb62b3f6b710e4d5e19487fff7993d.tar.bz2 |
cc: Remove DeviceViewport and DeviceClip from the RendererClient
Now the client only contains a method that is needed to be run on
LayerTreeHostImpl, no getters exist. Instead all values are pushed
into the renderer.
Some cleanups in GLRenderer unittests and the pixel tests has resulted.
Since gl_renderer_unittest file changed so dramatically anyway, I did a
clang-format on the whole file.
R=aelias@chromium.org, enne@chromium.org, enne
BUG=
Review URL: https://codereview.chromium.org/108653003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@239802 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/test')
-rw-r--r-- | cc/test/layer_tree_pixel_test.cc | 17 | ||||
-rw-r--r-- | cc/test/layer_tree_pixel_test.h | 1 | ||||
-rw-r--r-- | cc/test/pixel_test.cc | 81 | ||||
-rw-r--r-- | cc/test/pixel_test.h | 22 | ||||
-rw-r--r-- | cc/test/pixel_test_output_surface.cc | 7 | ||||
-rw-r--r-- | cc/test/pixel_test_output_surface.h | 8 |
6 files changed, 52 insertions, 84 deletions
diff --git a/cc/test/layer_tree_pixel_test.cc b/cc/test/layer_tree_pixel_test.cc index 3ad33dc..5388cba 100644 --- a/cc/test/layer_tree_pixel_test.cc +++ b/cc/test/layer_tree_pixel_test.cc @@ -34,7 +34,6 @@ LayerTreePixelTest::~LayerTreePixelTest() {} scoped_ptr<OutputSurface> LayerTreePixelTest::CreateOutputSurface( bool fallback) { - gfx::Vector2d viewport_offset(20, 10); gfx::Size surface_expansion_size(40, 60); scoped_ptr<PixelTestOutputSurface> output_surface; @@ -62,7 +61,6 @@ scoped_ptr<OutputSurface> LayerTreePixelTest::CreateOutputSurface( } } - output_surface->set_viewport_offset(viewport_offset); output_surface->set_surface_expansion_size(surface_expansion_size); return output_surface.PassAs<OutputSurface>(); } @@ -75,6 +73,21 @@ LayerTreePixelTest::OffscreenContextProvider() { return provider; } +void LayerTreePixelTest::CommitCompleteOnThread(LayerTreeHostImpl* impl) { + LayerTreeImpl* commit_tree = + impl->pending_tree() ? impl->pending_tree() : impl->active_tree(); + if (commit_tree->source_frame_number() != 0) + return; + + gfx::Rect viewport = impl->DeviceViewport(); + // The viewport has a 0,0 origin without external influence. + EXPECT_EQ(gfx::Point().ToString(), viewport.origin().ToString()); + // Be that influence! + viewport += gfx::Vector2d(20, 10); + impl->SetExternalDrawConstraints(gfx::Transform(), viewport, viewport, true); + EXPECT_EQ(viewport.ToString(), impl->DeviceViewport().ToString()); +} + scoped_ptr<CopyOutputRequest> LayerTreePixelTest::CreateCopyOutputRequest() { return CopyOutputRequest::CreateBitmapRequest( base::Bind(&LayerTreePixelTest::ReadbackResult, base::Unretained(this))); diff --git a/cc/test/layer_tree_pixel_test.h b/cc/test/layer_tree_pixel_test.h index d6e14c2..92d955f 100644 --- a/cc/test/layer_tree_pixel_test.h +++ b/cc/test/layer_tree_pixel_test.h @@ -31,6 +31,7 @@ class LayerTreePixelTest : public LayerTreeTest { virtual scoped_ptr<OutputSurface> CreateOutputSurface(bool fallback) OVERRIDE; virtual scoped_refptr<ContextProvider> OffscreenContextProvider() OVERRIDE; + virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE; virtual scoped_ptr<CopyOutputRequest> CreateCopyOutputRequest(); diff --git a/cc/test/pixel_test.cc b/cc/test/pixel_test.cc index 0e6b60d..414a325 100644 --- a/cc/test/pixel_test.cc +++ b/cc/test/pixel_test.cc @@ -16,6 +16,7 @@ #include "cc/output/software_renderer.h" #include "cc/resources/resource_provider.h" #include "cc/resources/texture_mailbox_deleter.h" +#include "cc/test/fake_output_surface_client.h" #include "cc/test/paths.h" #include "cc/test/pixel_test_output_surface.h" #include "cc/test/pixel_test_software_output_device.h" @@ -27,52 +28,10 @@ namespace cc { -class PixelTest::PixelTestRendererClient - : public RendererClient, public OutputSurfaceClient { - public: - explicit PixelTestRendererClient(gfx::Rect device_viewport) - : device_viewport_(device_viewport), device_clip_(device_viewport) {} - - // RendererClient implementation. - virtual gfx::Rect DeviceViewport() const OVERRIDE { - return device_viewport_; - } - virtual gfx::Rect DeviceClip() const OVERRIDE { return device_clip_; } - virtual void SetFullRootLayerDamage() OVERRIDE {} - - // OutputSurfaceClient implementation. - virtual bool DeferredInitialize( - scoped_refptr<ContextProvider> offscreen_context_provider) OVERRIDE { - return false; - } - virtual void ReleaseGL() OVERRIDE {} - virtual void SetNeedsRedrawRect(gfx::Rect damage_rect) OVERRIDE {} - virtual void BeginImplFrame(const BeginFrameArgs& args) OVERRIDE {} - virtual void DidSwapBuffers() OVERRIDE {} - virtual void OnSwapBuffersComplete() OVERRIDE {} - virtual void ReclaimResources(const CompositorFrameAck* ack) OVERRIDE {} - virtual void DidLoseOutputSurface() OVERRIDE {} - virtual void SetExternalDrawConstraints( - const gfx::Transform& transform, - gfx::Rect viewport, - gfx::Rect clip, - bool valid_for_tile_management) OVERRIDE { - device_viewport_ = viewport; - device_clip_ = clip; - } - virtual void SetMemoryPolicy(const ManagedMemoryPolicy& policy) OVERRIDE {} - virtual void SetTreeActivationCallback(const base::Closure&) OVERRIDE {} - - private: - gfx::Rect device_viewport_; - gfx::Rect device_clip_; -}; - PixelTest::PixelTest() : device_viewport_size_(gfx::Size(200, 200)), disable_picture_quad_image_filtering_(false), - fake_client_( - new PixelTestRendererClient(gfx::Rect(device_viewport_size_))) {} + output_surface_client_(new FakeOutputSurfaceClient) {} PixelTest::~PixelTest() {} @@ -112,12 +71,19 @@ bool PixelTest::RunPixelTestWithReadbackTarget( } float device_scale_factor = 1.f; + gfx::Rect device_viewport_rect = + gfx::Rect(device_viewport_size_) + external_device_viewport_offset_; + gfx::Rect device_clip_rect = external_device_clip_rect_.IsEmpty() + ? device_viewport_rect + : external_device_clip_rect_; bool allow_partial_swap = true; renderer_->DecideRenderPassAllocationsForFrame(*pass_list); renderer_->DrawFrame(pass_list, offscreen_contexts.get(), device_scale_factor, + device_viewport_rect, + device_clip_rect, allow_partial_swap, disable_picture_quad_image_filtering_); @@ -155,20 +121,19 @@ bool PixelTest::PixelsMatchReference(const base::FilePath& ref_file, } void PixelTest::SetUpGLRenderer(bool use_skia_gpu_backend) { - CHECK(fake_client_); CHECK(gfx::InitializeGLBindings(gfx::kGLImplementationOSMesaGL)); using webkit::gpu::ContextProviderInProcess; output_surface_.reset(new PixelTestOutputSurface( ContextProviderInProcess::CreateOffscreen())); - output_surface_->BindToClient(fake_client_.get()); + output_surface_->BindToClient(output_surface_client_.get()); resource_provider_ = ResourceProvider::Create(output_surface_.get(), NULL, 0, false, 1); texture_mailbox_deleter_ = make_scoped_ptr(new TextureMailboxDeleter); - renderer_ = GLRenderer::Create(fake_client_.get(), + renderer_ = GLRenderer::Create(this, &settings_, output_surface_.get(), resource_provider_.get(), @@ -176,12 +141,9 @@ void PixelTest::SetUpGLRenderer(bool use_skia_gpu_backend) { 0).PassAs<DirectRenderer>(); } -void PixelTest::ForceExpandedViewport(gfx::Size surface_expansion, - gfx::Vector2d viewport_offset) { +void PixelTest::ForceExpandedViewport(gfx::Size surface_expansion) { static_cast<PixelTestOutputSurface*>(output_surface_.get()) ->set_surface_expansion_size(surface_expansion); - static_cast<PixelTestOutputSurface*>(output_surface_.get()) - ->set_viewport_offset(viewport_offset); SoftwareOutputDevice* device = output_surface_->software_device(); if (device) { static_cast<PixelTestSoftwareOutputDevice*>(device) @@ -189,9 +151,12 @@ void PixelTest::ForceExpandedViewport(gfx::Size surface_expansion, } } +void PixelTest::ForceViewportOffset(gfx::Vector2d viewport_offset) { + external_device_viewport_offset_ = viewport_offset; +} + void PixelTest::ForceDeviceClip(gfx::Rect clip) { - static_cast<PixelTestOutputSurface*>(output_surface_.get()) - ->set_device_clip(clip); + external_device_clip_rect_ = clip; } void PixelTest::EnableExternalStencilTest() { @@ -200,18 +165,14 @@ void PixelTest::EnableExternalStencilTest() { } void PixelTest::SetUpSoftwareRenderer() { - CHECK(fake_client_); - scoped_ptr<SoftwareOutputDevice> device(new PixelTestSoftwareOutputDevice()); output_surface_.reset(new PixelTestOutputSurface(device.Pass())); - output_surface_->BindToClient(fake_client_.get()); + output_surface_->BindToClient(output_surface_client_.get()); resource_provider_ = ResourceProvider::Create(output_surface_.get(), NULL, 0, false, 1); - renderer_ = SoftwareRenderer::Create(fake_client_.get(), - &settings_, - output_surface_.get(), - resource_provider_.get()) - .PassAs<DirectRenderer>(); + renderer_ = SoftwareRenderer::Create( + this, &settings_, output_surface_.get(), resource_provider_.get()) + .PassAs<DirectRenderer>(); } } // namespace cc diff --git a/cc/test/pixel_test.h b/cc/test/pixel_test.h index 6885096..0835cdc 100644 --- a/cc/test/pixel_test.h +++ b/cc/test/pixel_test.h @@ -16,11 +16,12 @@ namespace cc { class CopyOutputResult; class DirectRenderer; -class SoftwareRenderer; +class FakeOutputSurfaceClient; class OutputSurface; class ResourceProvider; +class SoftwareRenderer; -class PixelTest : public testing::Test { +class PixelTest : public testing::Test, RendererClient { protected: PixelTest(); virtual ~PixelTest(); @@ -46,21 +47,26 @@ class PixelTest : public testing::Test { gfx::Size device_viewport_size_; bool disable_picture_quad_image_filtering_; class PixelTestRendererClient; + scoped_ptr<FakeOutputSurfaceClient> output_surface_client_; scoped_ptr<OutputSurface> output_surface_; scoped_ptr<ResourceProvider> resource_provider_; scoped_ptr<TextureMailboxDeleter> texture_mailbox_deleter_; - scoped_ptr<PixelTestRendererClient> fake_client_; scoped_ptr<DirectRenderer> renderer_; scoped_ptr<SkBitmap> result_bitmap_; + gfx::Vector2d external_device_viewport_offset_; + gfx::Rect external_device_clip_rect_; void SetUpGLRenderer(bool use_skia_gpu_backend); void SetUpSoftwareRenderer(); - void ForceExpandedViewport(gfx::Size surface_expansion, - gfx::Vector2d viewport_offset); + void ForceExpandedViewport(gfx::Size surface_expansion); + void ForceViewportOffset(gfx::Vector2d viewport_offset); void ForceDeviceClip(gfx::Rect clip); void EnableExternalStencilTest(); + // RendererClient implementation. + virtual void SetFullRootLayerDamage() OVERRIDE {} + private: void ReadbackResult(base::Closure quit_run_loop, scoped_ptr<CopyOutputResult> result); @@ -128,7 +134,8 @@ inline bool RendererPixelTest<GLRenderer>::ExpandedViewport() const { template<> inline void RendererPixelTest<GLRendererWithExpandedViewport>::SetUp() { SetUpGLRenderer(false); - ForceExpandedViewport(gfx::Size(50, 50), gfx::Vector2d(10, 20)); + ForceExpandedViewport(gfx::Size(50, 50)); + ForceViewportOffset(gfx::Vector2d(10, 20)); } template <> @@ -161,7 +168,8 @@ inline bool RendererPixelTest<SoftwareRenderer>::ExpandedViewport() const { template<> inline void RendererPixelTest<SoftwareRendererWithExpandedViewport>::SetUp() { SetUpSoftwareRenderer(); - ForceExpandedViewport(gfx::Size(50, 50), gfx::Vector2d(10, 20)); + ForceExpandedViewport(gfx::Size(50, 50)); + ForceViewportOffset(gfx::Vector2d(10, 20)); } template <> diff --git a/cc/test/pixel_test_output_surface.cc b/cc/test/pixel_test_output_surface.cc index 8306cc8..1ea89e2 100644 --- a/cc/test/pixel_test_output_surface.cc +++ b/cc/test/pixel_test_output_surface.cc @@ -21,13 +21,6 @@ void PixelTestOutputSurface::Reshape(gfx::Size size, float scale_factor) { gfx::Size expanded_size(size.width() + surface_expansion_size_.width(), size.height() + surface_expansion_size_.height()); OutputSurface::Reshape(expanded_size, scale_factor); - - gfx::Rect offset_viewport = gfx::Rect(size) + viewport_offset_; - gfx::Rect offset_clip = device_clip_.IsEmpty() - ? offset_viewport - : device_clip_ + viewport_offset_; - SetExternalDrawConstraints( - gfx::Transform(), offset_viewport, offset_clip, true); } bool PixelTestOutputSurface::HasExternalStencilTest() const { diff --git a/cc/test/pixel_test_output_surface.h b/cc/test/pixel_test_output_surface.h index 0b58ac26..2aca4f2 100644 --- a/cc/test/pixel_test_output_surface.h +++ b/cc/test/pixel_test_output_surface.h @@ -22,20 +22,12 @@ class PixelTestOutputSurface : public OutputSurface { void set_surface_expansion_size(gfx::Size surface_expansion_size) { surface_expansion_size_ = surface_expansion_size; } - void set_viewport_offset(gfx::Vector2d viewport_offset) { - viewport_offset_ = viewport_offset; - } - void set_device_clip(gfx::Rect device_clip) { - device_clip_ = device_clip; - } void set_has_external_stencil_test(bool has_test) { external_stencil_test_ = has_test; } private: gfx::Size surface_expansion_size_; - gfx::Vector2d viewport_offset_; - gfx::Rect device_clip_; bool external_stencil_test_; }; |