diff options
author | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-20 21:46:11 +0000 |
---|---|---|
committer | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-20 21:46:11 +0000 |
commit | d4d017e13286b6d328dd5a62d324149b863189ad (patch) | |
tree | c24d576eb00a033aef3f1d7d136bfe7d248b4778 /cc/test | |
parent | 83b3c9e05dffd57392fc3877c6b3c3f4546c210d (diff) | |
download | chromium_src-d4d017e13286b6d328dd5a62d324149b863189ad.zip chromium_src-d4d017e13286b6d328dd5a62d324149b863189ad.tar.gz chromium_src-d4d017e13286b6d328dd5a62d324149b863189ad.tar.bz2 |
cc: Allow output readback/copy requests to specify a sub-rect to copy.
The CopyOutputRequest API is on cc::Layer, so the rect it is given
should be in layer space.
Also add tests for CompositeAndReadback which no longer had any pixel
test coverage in cc/ to ensure that its inputs are correctly applied
as device viewport space.
Clean up the layer tree pixel test framework by passing the test type
(GL/Software cross Bitmap/Texture) as a parameter to RunPixelTest()
instead of having tests set a pair of bools. Forces all tests to
specify the test type.
Tests:
LayerTreeHostReadbackPixelTest.ReadbackSubrect_Software
LayerTreeHostReadbackPixelTest.ReadbackSubrect_GL_Bitmap
LayerTreeHostReadbackPixelTest.ReadbackSubrect_GL
LayerTreeHostReadbackPixelTest.ReadbackNonRootLayerSubrect_Software
LayerTreeHostReadbackPixelTest.ReadbackNonRootLayerSubrect_GL_Bitmap
LayerTreeHostReadbackPixelTest.ReadbackNonRootLayerSubrect_GL
LayerTreeHostReadbackDeviceScalePixelTest.ReadbackSubrect_Software
LayerTreeHostReadbackDeviceScalePixelTest.ReadbackSubrect_GL
LayerTreeHostReadbackDeviceScalePixelTest.ReadbackNonRootLayerSubrect_Software
LayerTreeHostReadbackDeviceScalePixelTest.ReadbackNonRootLayerSubrect_GL
LayerTreeHostReadbackViaCompositeAndReadbackPixelTest.CompositeAndReadback_Software_1
LayerTreeHostReadbackViaCompositeAndReadbackPixelTest.CompositeAndReadback_Software_2
LayerTreeHostReadbackViaCompositeAndReadbackPixelTest.CompositeAndReadback_GL_1
LayerTreeHostReadbackViaCompositeAndReadbackPixelTest.CompositeAndReadback_GL_2
R=piman
BUG=251754
Merged https://codereview.chromium.org/17449014/ and
https://codereview.chromium.org/17261009/ into this CL.
Review URL: https://chromiumcodereview.appspot.com/17335011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207589 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/test')
-rw-r--r-- | cc/test/layer_tree_pixel_test.cc | 50 | ||||
-rw-r--r-- | cc/test/layer_tree_pixel_test.h | 15 | ||||
-rw-r--r-- | cc/test/solid_color_content_layer_client.cc | 29 | ||||
-rw-r--r-- | cc/test/solid_color_content_layer_client.h | 30 |
4 files changed, 103 insertions, 21 deletions
diff --git a/cc/test/layer_tree_pixel_test.cc b/cc/test/layer_tree_pixel_test.cc index 3d757ca..b948302 100644 --- a/cc/test/layer_tree_pixel_test.cc +++ b/cc/test/layer_tree_pixel_test.cc @@ -21,7 +21,8 @@ namespace cc { LayerTreePixelTest::LayerTreePixelTest() - : pixel_comparator_(new ExactPixelComparator(true)), use_gl_(true) {} + : pixel_comparator_(new ExactPixelComparator(true)), + test_type_(GL_WITH_DEFAULT) {} LayerTreePixelTest::~LayerTreePixelTest() {} @@ -30,23 +31,32 @@ scoped_ptr<OutputSurface> LayerTreePixelTest::CreateOutputSurface() { gfx::Size surface_expansion_size(40, 60); scoped_ptr<PixelTestOutputSurface> output_surface; - if (!use_gl_) { - scoped_ptr<PixelTestSoftwareOutputDevice> software_output_device( - new PixelTestSoftwareOutputDevice); - software_output_device->set_surface_expansion_size(surface_expansion_size); - output_surface = make_scoped_ptr( - new PixelTestOutputSurface( - software_output_device.PassAs<SoftwareOutputDevice>())); - } else { - CHECK(gfx::InitializeGLBindings(gfx::kGLImplementationOSMesaGL)); - - using WebKit::WebGraphicsContext3D; - using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl; - scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context3d( - WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext( - WebGraphicsContext3D::Attributes())); - output_surface = make_scoped_ptr( - new PixelTestOutputSurface(context3d.PassAs<WebGraphicsContext3D>())); + switch (test_type_) { + case SOFTWARE_WITH_DEFAULT: + case SOFTWARE_WITH_BITMAP: { + scoped_ptr<PixelTestSoftwareOutputDevice> software_output_device( + new PixelTestSoftwareOutputDevice); + software_output_device->set_surface_expansion_size( + surface_expansion_size); + output_surface = make_scoped_ptr( + new PixelTestOutputSurface( + software_output_device.PassAs<SoftwareOutputDevice>())); + break; + } + + case GL_WITH_DEFAULT: + case GL_WITH_BITMAP: { + CHECK(gfx::InitializeGLBindings(gfx::kGLImplementationOSMesaGL)); + + using WebKit::WebGraphicsContext3D; + using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl; + scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context3d( + WebGraphicsContext3DInProcessCommandBufferImpl:: + CreateOffscreenContext(WebGraphicsContext3D::Attributes())); + output_surface = make_scoped_ptr( + new PixelTestOutputSurface(context3d.PassAs<WebGraphicsContext3D>())); + break; + } } output_surface->set_viewport_offset(viewport_offset); @@ -141,8 +151,10 @@ scoped_refptr<SolidColorLayer> LayerTreePixelTest:: } void LayerTreePixelTest::RunPixelTest( + PixelTestType test_type, scoped_refptr<Layer> content_root, base::FilePath file_name) { + test_type_ = test_type; content_root_ = content_root; readback_target_ = NULL; ref_file_ = file_name; @@ -150,9 +162,11 @@ void LayerTreePixelTest::RunPixelTest( } void LayerTreePixelTest::RunPixelTestWithReadbackTarget( + PixelTestType test_type, scoped_refptr<Layer> content_root, Layer* target, base::FilePath file_name) { + test_type_ = test_type; content_root_ = content_root; readback_target_ = target; ref_file_ = file_name; diff --git a/cc/test/layer_tree_pixel_test.h b/cc/test/layer_tree_pixel_test.h index b485237..72c14d5 100644 --- a/cc/test/layer_tree_pixel_test.h +++ b/cc/test/layer_tree_pixel_test.h @@ -47,10 +47,19 @@ class LayerTreePixelTest : public LayerTreeTest { int border_width, SkColor border_color); - void RunPixelTest(scoped_refptr<Layer> content_root, + enum PixelTestType { + GL_WITH_DEFAULT, + GL_WITH_BITMAP, + SOFTWARE_WITH_DEFAULT, + SOFTWARE_WITH_BITMAP + }; + + void RunPixelTest(PixelTestType type, + scoped_refptr<Layer> content_root, base::FilePath file_name); - void RunPixelTestWithReadbackTarget(scoped_refptr<Layer> content_root, + void RunPixelTestWithReadbackTarget(PixelTestType type, + scoped_refptr<Layer> content_root, Layer* target, base::FilePath file_name); @@ -68,7 +77,7 @@ class LayerTreePixelTest : public LayerTreeTest { scoped_ptr<PixelComparator> pixel_comparator_; protected: - bool use_gl_; + PixelTestType test_type_; scoped_refptr<Layer> content_root_; Layer* readback_target_; base::FilePath ref_file_; diff --git a/cc/test/solid_color_content_layer_client.cc b/cc/test/solid_color_content_layer_client.cc new file mode 100644 index 0000000..2d84947 --- /dev/null +++ b/cc/test/solid_color_content_layer_client.cc @@ -0,0 +1,29 @@ +// 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/test/solid_color_content_layer_client.h" + +#include "third_party/skia/include/core/SkCanvas.h" +#include "third_party/skia/include/core/SkPaint.h" +#include "ui/gfx/rect.h" +#include "ui/gfx/rect_f.h" + +namespace cc { + +void SolidColorContentLayerClient::PaintContents( + SkCanvas* canvas, gfx::Rect rect, gfx::RectF* opaque_rect) { + SkPaint paint; + paint.setStyle(SkPaint::kFill_Style); + paint.setColor(color_); + + canvas->clear(SK_ColorTRANSPARENT); + canvas->drawRect( + SkRect::MakeXYWH(rect.x(), rect.y(), rect.width(), rect.height()), + paint); + + if (SkColorGetA(color_) == 255) + *opaque_rect = rect; +} + +} // namespace cc diff --git a/cc/test/solid_color_content_layer_client.h b/cc/test/solid_color_content_layer_client.h new file mode 100644 index 0000000..ad7c0f0 --- /dev/null +++ b/cc/test/solid_color_content_layer_client.h @@ -0,0 +1,30 @@ +// 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. + +#ifndef CC_TEST_SOLID_COLOR_CONTENT_LAYER_CLIENT_H_ +#define CC_TEST_SOLID_COLOR_CONTENT_LAYER_CLIENT_H_ + +#include "base/compiler_specific.h" +#include "cc/layers/content_layer_client.h" +#include "third_party/skia/include/core/SkColor.h" + +namespace cc { + +class SolidColorContentLayerClient : public cc::ContentLayerClient { + public: + explicit SolidColorContentLayerClient(SkColor color) : color_(color) {} + + // ContentLayerClient implementation. + virtual void DidChangeLayerCanUseLCDText() OVERRIDE {} + virtual void PaintContents(SkCanvas* canvas, + gfx::Rect rect, + gfx::RectF* opaque_rect) OVERRIDE; + + private: + SkColor color_; +}; + +} // namespace cc + +#endif // CC_TEST_SOLID_COLOR_CONTENT_LAYER_CLIENT_H_ |