summaryrefslogtreecommitdiffstats
path: root/cc/test/pixel_test.cc
diff options
context:
space:
mode:
authordanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-18 18:24:24 +0000
committerdanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-18 18:24:24 +0000
commit6389458704504692b4fdf2e5869ff4dbf1b66b5c (patch)
tree25b696fd0597fe55ad7fa2a1c1554007071761c9 /cc/test/pixel_test.cc
parentcfa8f9d79c87ea20f0162af76acedc2a7e6cb5ab (diff)
downloadchromium_src-6389458704504692b4fdf2e5869ff4dbf1b66b5c.zip
chromium_src-6389458704504692b4fdf2e5869ff4dbf1b66b5c.tar.gz
chromium_src-6389458704504692b4fdf2e5869ff4dbf1b66b5c.tar.bz2
cc: Add ability to request copy of compositor output as a texture.
This adds the ability to request the compositor's output as a texture instead of requiring a readback to a SkBitmap on the cpu. This will allow the embedder to make a request for a texture and then scale or sample it without reading back the entire full-sized texture to the cpu. To readback successive frames will require constant commits at this time, but the mechanism could be extended to allow one main thread request to result in multiple copy result callbacks. This is tested by the LayerTreeHostPixelTestReadback tests. I've added a viewport offset, and surface expansion size, to all of the LayerTreeTest based pixel tests. This exposed a bug in the math for background filters when a viewport offset/surface expansion size is present, so this is fixed as well to make the tests pass (one line in GLRenderer::ApplyBackgroundFilters). Instead of having the CopyOutputRequest return a SkBitmap directly, or return a TextureMailbox directly (sometimes backed by a software bitmap), I've added a CopyOutputResult class to return with a reply from the compositor. This reply may be a texture (via a TextureMailbox) or a bitmap (via an SkBitmap). The embedder should be able to handle either one when it makes a request, unless its request forces a software-bitmap reply. The tests verify GLRenderer+general request, GLRenderer+forced software request, and SoftwareRenderer+general request. Adding the offset/expansion to the viewport/surface causes the offaxis background blur pixel test to become off-by-one in 5 pixels, requiring a rebaseline. R=enne, jamesr, piman BUG=242571 Review URL: https://chromiumcodereview.appspot.com/17018002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207037 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/test/pixel_test.cc')
-rw-r--r--cc/test/pixel_test.cc80
1 files changed, 29 insertions, 51 deletions
diff --git a/cc/test/pixel_test.cc b/cc/test/pixel_test.cc
index 1e75156..654804b 100644
--- a/cc/test/pixel_test.cc
+++ b/cc/test/pixel_test.cc
@@ -8,11 +8,14 @@
#include "base/run_loop.h"
#include "cc/output/compositor_frame_metadata.h"
#include "cc/output/copy_output_request.h"
+#include "cc/output/copy_output_result.h"
#include "cc/output/gl_renderer.h"
-#include "cc/output/output_surface.h"
+#include "cc/output/output_surface_client.h"
#include "cc/output/software_renderer.h"
#include "cc/resources/resource_provider.h"
#include "cc/test/paths.h"
+#include "cc/test/pixel_test_output_surface.h"
+#include "cc/test/pixel_test_software_output_device.h"
#include "cc/test/pixel_test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gl/gl_implementation.h"
@@ -21,14 +24,15 @@
namespace cc {
-class PixelTest::PixelTestRendererClient : public RendererClient {
+class PixelTest::PixelTestRendererClient
+ : public RendererClient, public OutputSurfaceClient {
public:
explicit PixelTestRendererClient(gfx::Rect device_viewport)
: device_viewport_(device_viewport) {}
// RendererClient implementation.
virtual gfx::Rect DeviceViewport() const OVERRIDE {
- return device_viewport_ + test_expansion_offset_;
+ return device_viewport_;
}
virtual float DeviceScaleFactor() const OVERRIDE {
return 1.f;
@@ -51,56 +55,25 @@ class PixelTest::PixelTestRendererClient : public RendererClient {
return true;
}
- void SetTestExpansionOffset(gfx::Vector2d test_expansion_offset) {
- test_expansion_offset_ = test_expansion_offset;
+ // OutputSurfaceClient implementation.
+ virtual bool DeferredInitialize(
+ scoped_refptr<ContextProvider> offscreen_context_provider) OVERRIDE {
+ return false;
+ }
+ virtual void SetNeedsRedrawRect(gfx::Rect damage_rect) OVERRIDE {}
+ virtual void BeginFrame(base::TimeTicks frame_time) OVERRIDE {}
+ virtual void OnSwapBuffersComplete(const CompositorFrameAck* ack) OVERRIDE {}
+ virtual void DidLoseOutputSurface() OVERRIDE {}
+ virtual void SetExternalDrawConstraints(const gfx::Transform& transform,
+ gfx::Rect viewport) OVERRIDE {
+ device_viewport_ = viewport;
}
private:
gfx::Rect device_viewport_;
- gfx::Vector2d test_expansion_offset_;
LayerTreeSettings settings_;
};
-class PixelTest::PixelTestOutputSurface : public OutputSurface {
- public:
- explicit PixelTestOutputSurface(
- scoped_ptr<WebKit::WebGraphicsContext3D> context3d)
- : OutputSurface(context3d.Pass()) {}
- explicit PixelTestOutputSurface(
- scoped_ptr<cc::SoftwareOutputDevice> software_device)
- : OutputSurface(software_device.Pass()) {}
- virtual void Reshape(gfx::Size size, float scale_factor) OVERRIDE {
- OutputSurface::Reshape(
- gfx::Size(size.width() + test_expansion_size_.width(),
- size.height() + test_expansion_size_.height()),
- scale_factor);
- }
-
- void SetTestExpansionSize(gfx::Size test_expansion_size) {
- test_expansion_size_ = test_expansion_size;
- }
-
- private:
- gfx::Size test_expansion_size_;
-};
-
-class PixelTestSoftwareOutputDevice : public SoftwareOutputDevice {
- public:
- PixelTestSoftwareOutputDevice() {}
- virtual void Resize(gfx::Size size) OVERRIDE {
- SoftwareOutputDevice::Resize(
- gfx::Size(size.width() + test_expansion_size_.width(),
- size.height() + test_expansion_size_.height()));
- }
-
- void SetTestExpansionSize(gfx::Size test_expansion_size) {
- test_expansion_size_ = test_expansion_size;
- }
-
- private:
- gfx::Size test_expansion_size_;
-};
-
PixelTest::PixelTest()
: device_viewport_size_(gfx::Size(200, 200)),
fake_client_(
@@ -140,8 +113,9 @@ bool PixelTest::RunPixelTestWithReadbackTarget(
}
void PixelTest::ReadbackResult(base::Closure quit_run_loop,
- scoped_ptr<SkBitmap> bitmap) {
- result_bitmap_ = bitmap.Pass();
+ scoped_ptr<CopyOutputResult> result) {
+ ASSERT_TRUE(result->HasBitmap());
+ result_bitmap_ = result->TakeBitmap().Pass();
quit_run_loop.Run();
}
@@ -173,6 +147,8 @@ void PixelTest::SetUpGLRenderer(bool use_skia_gpu_backend) {
WebKit::WebGraphicsContext3D::Attributes()));
output_surface_.reset(new PixelTestOutputSurface(
context3d.PassAs<WebKit::WebGraphicsContext3D>()));
+ output_surface_->BindToClient(fake_client_.get());
+
resource_provider_ = ResourceProvider::Create(output_surface_.get(), 0);
renderer_ = GLRenderer::Create(fake_client_.get(),
output_surface_.get(),
@@ -189,12 +165,13 @@ void PixelTest::SetUpGLRenderer(bool use_skia_gpu_backend) {
void PixelTest::ForceExpandedViewport(gfx::Size surface_expansion,
gfx::Vector2d viewport_offset) {
static_cast<PixelTestOutputSurface*>(output_surface_.get())
- ->SetTestExpansionSize(surface_expansion);
- fake_client_->SetTestExpansionOffset(viewport_offset);
+ ->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)
- ->SetTestExpansionSize(surface_expansion);
+ ->set_surface_expansion_size(surface_expansion);
}
}
@@ -203,6 +180,7 @@ void PixelTest::SetUpSoftwareRenderer() {
scoped_ptr<SoftwareOutputDevice> device(new PixelTestSoftwareOutputDevice());
output_surface_.reset(new PixelTestOutputSurface(device.Pass()));
+ output_surface_->BindToClient(fake_client_.get());
resource_provider_ = ResourceProvider::Create(output_surface_.get(), 0);
renderer_ = SoftwareRenderer::Create(
fake_client_.get(),