summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authorbacker@chromium.org <backer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-12 21:16:55 +0000
committerbacker@chromium.org <backer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-12 21:16:55 +0000
commit3191cc67fddce23a92c2a5ac2ccc95cbda392180 (patch)
treefead59fbc0a577312f5d87f5f966aa964c19a669 /cc
parent59b463158f40c1096f6b2926c628d122790650e6 (diff)
downloadchromium_src-3191cc67fddce23a92c2a5ac2ccc95cbda392180.zip
chromium_src-3191cc67fddce23a92c2a5ac2ccc95cbda392180.tar.gz
chromium_src-3191cc67fddce23a92c2a5ac2ccc95cbda392180.tar.bz2
CC: Call SwapBuffers instead of PostSubBuffer on full frame update.
This allows us to remove a driver workaround and send less information in the GLFrameData. TEST=cc_unittests Review URL: https://chromiumcodereview.appspot.com/16509008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@205932 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r--cc/output/gl_frame_data.cc5
-rw-r--r--cc/output/gl_frame_data.h1
-rw-r--r--cc/output/gl_renderer.cc2
-rw-r--r--cc/output/output_surface.cc11
-rw-r--r--cc/trees/layer_tree_host_impl_unittest.cc46
5 files changed, 42 insertions, 23 deletions
diff --git a/cc/output/gl_frame_data.cc b/cc/output/gl_frame_data.cc
index 06cf3f4..aa6cfbc 100644
--- a/cc/output/gl_frame_data.cc
+++ b/cc/output/gl_frame_data.cc
@@ -6,10 +6,7 @@
namespace cc {
-GLFrameData::GLFrameData()
- : sync_point(0),
- partial_swap_allowed(false) {
-}
+GLFrameData::GLFrameData() : sync_point(0) {}
GLFrameData::~GLFrameData() {}
diff --git a/cc/output/gl_frame_data.h b/cc/output/gl_frame_data.h
index b8ec5ec..a8132f9 100644
--- a/cc/output/gl_frame_data.h
+++ b/cc/output/gl_frame_data.h
@@ -24,7 +24,6 @@ class CC_EXPORT GLFrameData {
uint32 sync_point;
gfx::Size size;
gfx::Rect sub_buffer_rect;
- bool partial_swap_allowed;
};
} // namespace cc
diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc
index 6ae5cb2..fb5de4e 100644
--- a/cc/output/gl_renderer.cc
+++ b/cc/output/gl_renderer.cc
@@ -2029,11 +2029,9 @@ void GLRenderer::SwapBuffers() {
flipped_y_pos_of_rect_bottom,
swap_buffer_rect_.width(),
swap_buffer_rect_.height());
- compositor_frame.gl_frame_data->partial_swap_allowed = true;
} else {
compositor_frame.gl_frame_data->sub_buffer_rect =
gfx::Rect(output_surface_->SurfaceSize());
- compositor_frame.gl_frame_data->partial_swap_allowed = false;
}
output_surface_->SwapBuffers(&compositor_frame);
diff --git a/cc/output/output_surface.cc b/cc/output/output_surface.cc
index 0889b96..1a956e4 100644
--- a/cc/output/output_surface.cc
+++ b/cc/output/output_surface.cc
@@ -192,16 +192,17 @@ void OutputSurface::SwapBuffers(cc::CompositorFrame* frame) {
DCHECK(context3d_);
DCHECK(frame->gl_frame_data);
- if (frame->gl_frame_data->partial_swap_allowed) {
+ 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.
+ context3d()->prepareTexture();
+ } else {
gfx::Rect sub_buffer_rect = frame->gl_frame_data->sub_buffer_rect;
context3d()->postSubBufferCHROMIUM(sub_buffer_rect.x(),
sub_buffer_rect.y(),
sub_buffer_rect.width(),
sub_buffer_rect.height());
- } else {
- // Note that currently this has the same effect as SwapBuffers; we should
- // consider exposing a different entry point on WebGraphicsContext3D.
- context3d()->prepareTexture();
}
if (!has_swap_buffers_complete_callback_)
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc
index d643656..2439dc5 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -2813,11 +2813,19 @@ TEST_F(LayerTreeHostImplTest, ReshapeNotCalledUntilDraw) {
reshape_tracker->clear_reshape_called();
}
-class PartialSwapTrackerContext : public TestWebGraphicsContext3D {
+class SwapTrackerContext : public TestWebGraphicsContext3D {
public:
+ SwapTrackerContext() : last_update_type_(NoUpdate) {}
+
+ virtual void prepareTexture() OVERRIDE {
+ update_rect_ = gfx::Rect(width_, height_);
+ last_update_type_ = PrepareTexture;
+ }
+
virtual void postSubBufferCHROMIUM(int x, int y, int width, int height)
OVERRIDE {
- partial_swap_rect_ = gfx::Rect(x, y, width, height);
+ update_rect_ = gfx::Rect(x, y, width, height);
+ last_update_type_ = PostSubBuffer;
}
virtual WebKit::WebString getString(WebKit::WGC3Denum name) OVERRIDE {
@@ -2829,10 +2837,21 @@ class PartialSwapTrackerContext : public TestWebGraphicsContext3D {
return WebKit::WebString();
}
- gfx::Rect partial_swap_rect() const { return partial_swap_rect_; }
+ gfx::Rect update_rect() const { return update_rect_; }
+
+ enum UpdateType {
+ NoUpdate = 0,
+ PrepareTexture,
+ PostSubBuffer
+ };
+
+ UpdateType last_update_type() {
+ return last_update_type_;
+ }
private:
- gfx::Rect partial_swap_rect_;
+ gfx::Rect update_rect_;
+ UpdateType last_update_type_;
};
// Make sure damage tracking propagates all the way to the graphics context,
@@ -2840,9 +2859,9 @@ class PartialSwapTrackerContext : public TestWebGraphicsContext3D {
TEST_F(LayerTreeHostImplTest, PartialSwapReceivesDamageRect) {
scoped_ptr<OutputSurface> output_surface =
FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(
- new PartialSwapTrackerContext)).PassAs<OutputSurface>();
- PartialSwapTrackerContext* partial_swap_tracker =
- static_cast<PartialSwapTrackerContext*>(output_surface->context3d());
+ new SwapTrackerContext)).PassAs<OutputSurface>();
+ SwapTrackerContext* swap_tracker =
+ static_cast<SwapTrackerContext*>(output_surface->context3d());
// This test creates its own LayerTreeHostImpl, so
// that we can force partial swap enabled.
@@ -2879,13 +2898,14 @@ TEST_F(LayerTreeHostImplTest, PartialSwapReceivesDamageRect) {
layer_tree_host_impl->DrawLayers(&frame, base::TimeTicks::Now());
layer_tree_host_impl->DidDrawAllLayers(frame);
layer_tree_host_impl->SwapBuffers(frame);
- gfx::Rect actual_swap_rect = partial_swap_tracker->partial_swap_rect();
+ gfx::Rect actual_swap_rect = swap_tracker->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(swap_tracker->last_update_type(),
+ SwapTrackerContext::PrepareTexture);
// 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);
@@ -2896,12 +2916,14 @@ TEST_F(LayerTreeHostImplTest, PartialSwapReceivesDamageRect) {
layer_tree_host_impl->DrawLayers(&frame, base::TimeTicks::Now());
host_impl_->DidDrawAllLayers(frame);
layer_tree_host_impl->SwapBuffers(frame);
- actual_swap_rect = partial_swap_tracker->partial_swap_rect();
+ actual_swap_rect = swap_tracker->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(swap_tracker->last_update_type(),
+ SwapTrackerContext::PostSubBuffer);
// Make sure that partial swap is constrained to the viewport dimensions
// expected damage rect: gfx::Rect(500, 500);
@@ -2914,12 +2936,14 @@ TEST_F(LayerTreeHostImplTest, PartialSwapReceivesDamageRect) {
layer_tree_host_impl->DrawLayers(&frame, base::TimeTicks::Now());
host_impl_->DidDrawAllLayers(frame);
layer_tree_host_impl->SwapBuffers(frame);
- actual_swap_rect = partial_swap_tracker->partial_swap_rect();
+ actual_swap_rect = swap_tracker->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(swap_tracker->last_update_type(),
+ SwapTrackerContext::PrepareTexture);
}
TEST_F(LayerTreeHostImplTest, RootLayerDoesntCreateExtraSurface) {