Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(927)

Side by Side Diff: cc/output/gl_renderer_unittest.cc

Issue 15579002: Implement transform/clip support for Android WebView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Turn on fuzzy comparator for new SoftwareRenderer tests Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/output/gl_renderer.h" 5 #include "cc/output/gl_renderer.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "cc/base/math_util.h" 9 #include "cc/base/math_util.h"
10 #include "cc/output/compositor_frame_metadata.h" 10 #include "cc/output/compositor_frame_metadata.h"
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 class FakeRendererClient : public RendererClient { 146 class FakeRendererClient : public RendererClient {
147 public: 147 public:
148 FakeRendererClient() 148 FakeRendererClient()
149 : host_impl_(&proxy_), 149 : host_impl_(&proxy_),
150 set_full_root_layer_damage_count_(0), 150 set_full_root_layer_damage_count_(0),
151 last_call_was_set_visibility_(0), 151 last_call_was_set_visibility_(0),
152 root_layer_(LayerImpl::Create(host_impl_.active_tree(), 1)), 152 root_layer_(LayerImpl::Create(host_impl_.active_tree(), 1)),
153 memory_allocation_limit_bytes_( 153 memory_allocation_limit_bytes_(
154 PrioritizedResourceManager::DefaultMemoryAllocationLimit()), 154 PrioritizedResourceManager::DefaultMemoryAllocationLimit()),
155 viewport_size_(gfx::Size(1, 1)), 155 viewport_size_(gfx::Size(1, 1)),
156 scale_factor_(1.f), 156 scale_factor_(1.f) {
157 is_viewport_changed_(true) {
158 root_layer_->CreateRenderSurface(); 157 root_layer_->CreateRenderSurface();
159 RenderPass::Id render_pass_id = 158 RenderPass::Id render_pass_id =
160 root_layer_->render_surface()->RenderPassId(); 159 root_layer_->render_surface()->RenderPassId();
161 scoped_ptr<RenderPass> root_render_pass = RenderPass::Create(); 160 scoped_ptr<RenderPass> root_render_pass = RenderPass::Create();
162 root_render_pass->SetNew( 161 root_render_pass->SetNew(
163 render_pass_id, gfx::Rect(), gfx::Rect(), gfx::Transform()); 162 render_pass_id, gfx::Rect(), gfx::Rect(), gfx::Transform());
164 render_passes_in_draw_order_.push_back(root_render_pass.Pass()); 163 render_passes_in_draw_order_.push_back(root_render_pass.Pass());
165 } 164 }
166 165
167 // RendererClient methods. 166 // RendererClient methods.
168 virtual gfx::Size DeviceViewportSize() const OVERRIDE { 167 virtual gfx::Rect DeviceViewport() const OVERRIDE {
169 static gfx::Size fake_size(1, 1); 168 static gfx::Size fake_size(1, 1);
170 return fake_size; 169 return gfx::Rect(fake_size);
171 } 170 }
172 virtual float DeviceScaleFactor() const OVERRIDE { 171 virtual float DeviceScaleFactor() const OVERRIDE {
173 return scale_factor_; 172 return scale_factor_;
174 } 173 }
175 virtual const LayerTreeSettings& Settings() const OVERRIDE { 174 virtual const LayerTreeSettings& Settings() const OVERRIDE {
176 static LayerTreeSettings fake_settings; 175 static LayerTreeSettings fake_settings;
177 return fake_settings; 176 return fake_settings;
178 } 177 }
179 virtual void SetFullRootLayerDamage() OVERRIDE { 178 virtual void SetFullRootLayerDamage() OVERRIDE {
180 set_full_root_layer_damage_count_++; 179 set_full_root_layer_damage_count_++;
(...skipping 21 matching lines...) Expand all
202 return set_full_root_layer_damage_count_; 201 return set_full_root_layer_damage_count_;
203 } 202 }
204 void set_last_call_was_set_visibility_pointer( 203 void set_last_call_was_set_visibility_pointer(
205 bool* last_call_was_set_visibility) { 204 bool* last_call_was_set_visibility) {
206 last_call_was_set_visibility_ = last_call_was_set_visibility; 205 last_call_was_set_visibility_ = last_call_was_set_visibility;
207 } 206 }
208 void set_viewport_and_scale( 207 void set_viewport_and_scale(
209 gfx::Size viewport_size, float scale_factor) { 208 gfx::Size viewport_size, float scale_factor) {
210 viewport_size_ = viewport_size; 209 viewport_size_ = viewport_size;
211 scale_factor_ = scale_factor; 210 scale_factor_ = scale_factor;
212 is_viewport_changed_ = true;
213 } 211 }
214 bool is_viewport_changed() const { return is_viewport_changed_; }
215 void clear_viewport_changed() { is_viewport_changed_ = false; }
216 212
217 RenderPass* root_render_pass() { return render_passes_in_draw_order_.back(); } 213 RenderPass* root_render_pass() { return render_passes_in_draw_order_.back(); }
218 RenderPassList* render_passes_in_draw_order() { 214 RenderPassList* render_passes_in_draw_order() {
219 return &render_passes_in_draw_order_; 215 return &render_passes_in_draw_order_;
220 } 216 }
221 217
222 size_t memory_allocation_limit_bytes() const { 218 size_t memory_allocation_limit_bytes() const {
223 return memory_allocation_limit_bytes_; 219 return memory_allocation_limit_bytes_;
224 } 220 }
225 221
226 private: 222 private:
227 FakeImplProxy proxy_; 223 FakeImplProxy proxy_;
228 FakeLayerTreeHostImpl host_impl_; 224 FakeLayerTreeHostImpl host_impl_;
229 int set_full_root_layer_damage_count_; 225 int set_full_root_layer_damage_count_;
230 bool* last_call_was_set_visibility_; 226 bool* last_call_was_set_visibility_;
231 scoped_ptr<LayerImpl> root_layer_; 227 scoped_ptr<LayerImpl> root_layer_;
232 RenderPassList render_passes_in_draw_order_; 228 RenderPassList render_passes_in_draw_order_;
233 size_t memory_allocation_limit_bytes_; 229 size_t memory_allocation_limit_bytes_;
234 gfx::Size viewport_size_; 230 gfx::Size viewport_size_;
235 float scale_factor_; 231 float scale_factor_;
236 bool is_viewport_changed_;
237 }; 232 };
238 233
239 class FakeRendererGL : public GLRenderer { 234 class FakeRendererGL : public GLRenderer {
240 public: 235 public:
241 FakeRendererGL(RendererClient* client, 236 FakeRendererGL(RendererClient* client,
242 OutputSurface* output_surface, 237 OutputSurface* output_surface,
243 ResourceProvider* resource_provider) 238 ResourceProvider* resource_provider)
244 : GLRenderer(client, output_surface, resource_provider, 0) {} 239 : GLRenderer(client, output_surface, resource_provider, 0) {}
245 240
246 // GLRenderer methods. 241 // GLRenderer methods.
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 new NoClearRootRenderPassMockContext))); 992 new NoClearRootRenderPassMockContext)));
998 NoClearRootRenderPassMockContext* mock_context = 993 NoClearRootRenderPassMockContext* mock_context =
999 static_cast<NoClearRootRenderPassMockContext*>( 994 static_cast<NoClearRootRenderPassMockContext*>(
1000 output_surface->context3d()); 995 output_surface->context3d());
1001 scoped_ptr<ResourceProvider> resource_provider( 996 scoped_ptr<ResourceProvider> resource_provider(
1002 ResourceProvider::Create(output_surface.get(), 0)); 997 ResourceProvider::Create(output_surface.get(), 0));
1003 FakeRendererGL renderer( 998 FakeRendererGL renderer(
1004 &mock_client, output_surface.get(), resource_provider.get()); 999 &mock_client, output_surface.get(), resource_provider.get());
1005 EXPECT_TRUE(renderer.Initialize()); 1000 EXPECT_TRUE(renderer.Initialize());
1006 1001
1007 gfx::Rect viewport_rect(mock_client.DeviceViewportSize()); 1002 gfx::Rect viewport_rect(mock_client.DeviceViewport());
1008 ScopedPtrVector<RenderPass>& render_passes = 1003 ScopedPtrVector<RenderPass>& render_passes =
1009 *mock_client.render_passes_in_draw_order(); 1004 *mock_client.render_passes_in_draw_order();
1010 render_passes.clear(); 1005 render_passes.clear();
1011 1006
1012 RenderPass::Id root_pass_id(1, 0); 1007 RenderPass::Id root_pass_id(1, 0);
1013 TestRenderPass* root_pass = AddRenderPass( 1008 TestRenderPass* root_pass = AddRenderPass(
1014 &render_passes, root_pass_id, viewport_rect, gfx::Transform()); 1009 &render_passes, root_pass_id, viewport_rect, gfx::Transform());
1015 AddQuad(root_pass, viewport_rect, SK_ColorGREEN); 1010 AddQuad(root_pass, viewport_rect, SK_ColorGREEN);
1016 1011
1017 RenderPass::Id child_pass_id(2, 0); 1012 RenderPass::Id child_pass_id(2, 0);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1068 scoped_ptr<OutputSurface> output_surface( 1063 scoped_ptr<OutputSurface> output_surface(
1069 FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>( 1064 FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(
1070 new ScissorTestOnClearCheckingContext))); 1065 new ScissorTestOnClearCheckingContext)));
1071 scoped_ptr<ResourceProvider> resource_provider( 1066 scoped_ptr<ResourceProvider> resource_provider(
1072 ResourceProvider::Create(output_surface.get(), 0)); 1067 ResourceProvider::Create(output_surface.get(), 0));
1073 FakeRendererGL renderer( 1068 FakeRendererGL renderer(
1074 &mock_client, output_surface.get(), resource_provider.get()); 1069 &mock_client, output_surface.get(), resource_provider.get());
1075 EXPECT_TRUE(renderer.Initialize()); 1070 EXPECT_TRUE(renderer.Initialize());
1076 EXPECT_FALSE(renderer.Capabilities().using_partial_swap); 1071 EXPECT_FALSE(renderer.Capabilities().using_partial_swap);
1077 1072
1078 gfx::Rect viewport_rect(mock_client.DeviceViewportSize()); 1073 gfx::Rect viewport_rect(mock_client.DeviceViewport());
1079 ScopedPtrVector<RenderPass>& render_passes = 1074 ScopedPtrVector<RenderPass>& render_passes =
1080 *mock_client.render_passes_in_draw_order(); 1075 *mock_client.render_passes_in_draw_order();
1081 render_passes.clear(); 1076 render_passes.clear();
1082 1077
1083 gfx::Rect grand_child_rect(25, 25); 1078 gfx::Rect grand_child_rect(25, 25);
1084 RenderPass::Id grand_child_pass_id(3, 0); 1079 RenderPass::Id grand_child_pass_id(3, 0);
1085 TestRenderPass* grand_child_pass = AddRenderPass( 1080 TestRenderPass* grand_child_pass = AddRenderPass(
1086 &render_passes, grand_child_pass_id, grand_child_rect, gfx::Transform()); 1081 &render_passes, grand_child_pass_id, grand_child_rect, gfx::Transform());
1087 AddClippedQuad(grand_child_pass, grand_child_rect, SK_ColorYELLOW); 1082 AddClippedQuad(grand_child_pass, grand_child_rect, SK_ColorYELLOW);
1088 1083
1089 gfx::Rect child_rect(50, 50); 1084 gfx::Rect child_rect(50, 50);
1090 RenderPass::Id child_pass_id(2, 0); 1085 RenderPass::Id child_pass_id(2, 0);
1091 TestRenderPass* child_pass = AddRenderPass( 1086 TestRenderPass* child_pass = AddRenderPass(
1092 &render_passes, child_pass_id, child_rect, gfx::Transform()); 1087 &render_passes, child_pass_id, child_rect, gfx::Transform());
1093 AddQuad(child_pass, child_rect, SK_ColorBLUE); 1088 AddQuad(child_pass, child_rect, SK_ColorBLUE);
1094 1089
1095 RenderPass::Id root_pass_id(1, 0); 1090 RenderPass::Id root_pass_id(1, 0);
1096 TestRenderPass* root_pass = AddRenderPass( 1091 TestRenderPass* root_pass = AddRenderPass(
1097 &render_passes, root_pass_id, viewport_rect, gfx::Transform()); 1092 &render_passes, root_pass_id, viewport_rect, gfx::Transform());
1098 AddQuad(root_pass, viewport_rect, SK_ColorGREEN); 1093 AddQuad(root_pass, viewport_rect, SK_ColorGREEN);
1099 1094
1100 AddRenderPassQuad(root_pass, child_pass); 1095 AddRenderPassQuad(root_pass, child_pass);
1101 AddRenderPassQuad(child_pass, grand_child_pass); 1096 AddRenderPassQuad(child_pass, grand_child_pass);
1102 1097
1103 renderer.DecideRenderPassAllocationsForFrame( 1098 renderer.DecideRenderPassAllocationsForFrame(
1104 *mock_client.render_passes_in_draw_order()); 1099 *mock_client.render_passes_in_draw_order());
1105 renderer.DrawFrame(mock_client.render_passes_in_draw_order()); 1100 renderer.DrawFrame(mock_client.render_passes_in_draw_order());
1106 } 1101 }
1107 1102
1103 class NonReshapableOutputSurface : public FakeOutputSurface {
1104 public:
1105 explicit NonReshapableOutputSurface(
1106 scoped_ptr<WebKit::WebGraphicsContext3D> context3d)
1107 : FakeOutputSurface(context3d.Pass(), false) {}
1108 virtual gfx::Size SurfaceSize() const OVERRIDE { return gfx::Size(500, 500); }
1109 };
1110
1111 class OffsetViewportRendererClient : public FakeRendererClient {
1112 public:
1113 virtual gfx::Rect DeviceViewport() const OVERRIDE {
1114 return gfx::Rect(10, 10, 100, 100);
1115 }
1116 };
1117
1118 class FlippedScissorAndViewportContext : public TestWebGraphicsContext3D {
1119 public:
1120 FlippedScissorAndViewportContext()
1121 : did_call_viewport_(false), did_call_scissor_(false) {}
1122 virtual ~FlippedScissorAndViewportContext() {
1123 EXPECT_TRUE(did_call_viewport_);
1124 EXPECT_TRUE(did_call_scissor_);
1125 }
1126
1127 virtual void viewport(GLint x, GLint y, GLsizei width, GLsizei height) {
1128 EXPECT_EQ(10, x);
1129 EXPECT_EQ(390, y);
1130 EXPECT_EQ(100, width);
1131 EXPECT_EQ(100, height);
1132 did_call_viewport_ = true;
1133 }
1134
1135 virtual void scissor(GLint x, GLint y, GLsizei width, GLsizei height) {
1136 EXPECT_EQ(30, x);
1137 EXPECT_EQ(450, y);
1138 EXPECT_EQ(20, width);
1139 EXPECT_EQ(20, height);
1140 did_call_scissor_ = true;
1141 }
1142
1143 private:
1144 bool did_call_viewport_;
1145 bool did_call_scissor_;
1146 };
1147
1148 TEST(GLRendererTest2, ScissorAndViewportWithinNonreshapableSurface) {
1149 // In Android WebView, the OutputSurface is unable to respect reshape() calls
1150 // and maintains a fixed size. This test verifies that glViewport and
1151 // glScissor's Y coordinate is flipped correctly in this environment, and that
1152 // the glViewport can be at a nonzero origin within the surface.
1153 OffsetViewportRendererClient mock_client;
1154 scoped_ptr<OutputSurface> output_surface(make_scoped_ptr(
1155 new NonReshapableOutputSurface(scoped_ptr<WebKit::WebGraphicsContext3D>(
1156 new FlippedScissorAndViewportContext))));
1157 scoped_ptr<ResourceProvider> resource_provider(
1158 ResourceProvider::Create(output_surface.get(), 0));
1159 FakeRendererGL renderer(
1160 &mock_client, output_surface.get(), resource_provider.get());
1161 EXPECT_TRUE(renderer.Initialize());
1162 EXPECT_FALSE(renderer.Capabilities().using_partial_swap);
1163
1164 gfx::Rect viewport_rect(mock_client.DeviceViewport().size());
1165 gfx::Rect quad_rect = gfx::Rect(20, 20, 20, 20);
1166 ScopedPtrVector<RenderPass>& render_passes =
1167 *mock_client.render_passes_in_draw_order();
1168 render_passes.clear();
1169
1170 RenderPass::Id root_pass_id(1, 0);
1171 TestRenderPass* root_pass = AddRenderPass(
1172 &render_passes, root_pass_id, viewport_rect, gfx::Transform());
1173 AddClippedQuad(root_pass, quad_rect, SK_ColorGREEN);
1174
1175 renderer.DecideRenderPassAllocationsForFrame(
1176 *mock_client.render_passes_in_draw_order());
1177 renderer.DrawFrame(mock_client.render_passes_in_draw_order());
1178 }
1179
1108 // This test was never actually working as intended. Before adding 1180 // This test was never actually working as intended. Before adding
1109 // ShaderCreatorMockGraphicsContext, all shader programs received the same 1181 // ShaderCreatorMockGraphicsContext, all shader programs received the same
1110 // program identifier from the TestWebGraphicsContext3D, so it always passed 1182 // program identifier from the TestWebGraphicsContext3D, so it always passed
1111 // when checking which shader was used. 1183 // when checking which shader was used.
1112 TEST_F(GLRendererShaderTest, DISABLED_DrawRenderPassQuadShaderPermutations) { 1184 TEST_F(GLRendererShaderTest, DISABLED_DrawRenderPassQuadShaderPermutations) {
1113 gfx::Rect viewport_rect(mock_client_.DeviceViewportSize()); 1185 gfx::Rect viewport_rect(mock_client_.DeviceViewport());
1114 ScopedPtrVector<RenderPass>* render_passes = 1186 ScopedPtrVector<RenderPass>* render_passes =
1115 mock_client_.render_passes_in_draw_order(); 1187 mock_client_.render_passes_in_draw_order();
1116 1188
1117 gfx::Rect grand_child_rect(25, 25); 1189 gfx::Rect grand_child_rect(25, 25);
1118 RenderPass::Id grand_child_pass_id(3, 0); 1190 RenderPass::Id grand_child_pass_id(3, 0);
1119 TestRenderPass* grand_child_pass; 1191 TestRenderPass* grand_child_pass;
1120 1192
1121 gfx::Rect child_rect(50, 50); 1193 gfx::Rect child_rect(50, 50);
1122 RenderPass::Id child_pass_id(2, 0); 1194 RenderPass::Id child_pass_id(2, 0);
1123 TestRenderPass* child_pass; 1195 TestRenderPass* child_pass;
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
1365 TestRenderPassMaskColorMatrixProgramAA(); 1437 TestRenderPassMaskColorMatrixProgramAA();
1366 } 1438 }
1367 1439
1368 // At this time, the AA code path cannot be taken if the surface's rect would 1440 // At this time, the AA code path cannot be taken if the surface's rect would
1369 // project incorrectly by the given transform, because of w<0 clipping. 1441 // project incorrectly by the given transform, because of w<0 clipping.
1370 TEST_F(GLRendererShaderTest, DrawRenderPassQuadSkipsAAForClippingTransform) { 1442 TEST_F(GLRendererShaderTest, DrawRenderPassQuadSkipsAAForClippingTransform) {
1371 gfx::Rect child_rect(50, 50); 1443 gfx::Rect child_rect(50, 50);
1372 RenderPass::Id child_pass_id(2, 0); 1444 RenderPass::Id child_pass_id(2, 0);
1373 TestRenderPass* child_pass; 1445 TestRenderPass* child_pass;
1374 1446
1375 gfx::Rect viewport_rect(mock_client_.DeviceViewportSize()); 1447 gfx::Rect viewport_rect(mock_client_.DeviceViewport());
1376 RenderPass::Id root_pass_id(1, 0); 1448 RenderPass::Id root_pass_id(1, 0);
1377 TestRenderPass* root_pass; 1449 TestRenderPass* root_pass;
1378 1450
1379 gfx::Transform transform_preventing_aa; 1451 gfx::Transform transform_preventing_aa;
1380 transform_preventing_aa.ApplyPerspectiveDepth(40.0); 1452 transform_preventing_aa.ApplyPerspectiveDepth(40.0);
1381 transform_preventing_aa.RotateAboutYAxis(-20.0); 1453 transform_preventing_aa.RotateAboutYAxis(-20.0);
1382 transform_preventing_aa.Scale(30.0, 1.0); 1454 transform_preventing_aa.Scale(30.0, 1.0);
1383 1455
1384 // Verify that the test transform and test rect actually do cause the clipped 1456 // Verify that the test transform and test rect actually do cause the clipped
1385 // flag to trigger. Otherwise we are not testing the intended scenario. 1457 // flag to trigger. Otherwise we are not testing the intended scenario.
(...skipping 24 matching lines...) Expand all
1410 renderer_->DecideRenderPassAllocationsForFrame( 1482 renderer_->DecideRenderPassAllocationsForFrame(
1411 *mock_client_.render_passes_in_draw_order()); 1483 *mock_client_.render_passes_in_draw_order());
1412 renderer_->DrawFrame(mock_client_.render_passes_in_draw_order()); 1484 renderer_->DrawFrame(mock_client_.render_passes_in_draw_order());
1413 1485
1414 // If use_aa incorrectly ignores clipping, it will use the 1486 // If use_aa incorrectly ignores clipping, it will use the
1415 // RenderPassProgramAA shader instead of the RenderPassProgram. 1487 // RenderPassProgramAA shader instead of the RenderPassProgram.
1416 TestRenderPassProgram(); 1488 TestRenderPassProgram();
1417 } 1489 }
1418 1490
1419 TEST_F(GLRendererShaderTest, DrawSolidColorShader) { 1491 TEST_F(GLRendererShaderTest, DrawSolidColorShader) {
1420 gfx::Rect viewport_rect(mock_client_.DeviceViewportSize()); 1492 gfx::Rect viewport_rect(mock_client_.DeviceViewport());
1421 ScopedPtrVector<RenderPass>* render_passes = 1493 ScopedPtrVector<RenderPass>* render_passes =
1422 mock_client_.render_passes_in_draw_order(); 1494 mock_client_.render_passes_in_draw_order();
1423 1495
1424 RenderPass::Id root_pass_id(1, 0); 1496 RenderPass::Id root_pass_id(1, 0);
1425 TestRenderPass* root_pass; 1497 TestRenderPass* root_pass;
1426 1498
1427 gfx::Transform pixel_aligned_transform_causing_aa; 1499 gfx::Transform pixel_aligned_transform_causing_aa;
1428 pixel_aligned_transform_causing_aa.Translate(25.5f, 25.5f); 1500 pixel_aligned_transform_causing_aa.Translate(25.5f, 25.5f);
1429 pixel_aligned_transform_causing_aa.Scale(0.5f, 0.5f); 1501 pixel_aligned_transform_causing_aa.Scale(0.5f, 0.5f);
1430 1502
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1467 return WebString( 1539 return WebString(
1468 "GL_CHROMIUM_post_sub_buffer GL_CHROMIUM_discard_backbuffer"); 1540 "GL_CHROMIUM_post_sub_buffer GL_CHROMIUM_discard_backbuffer");
1469 return WebString(); 1541 return WebString();
1470 } 1542 }
1471 }; 1543 };
1472 1544
1473 class MockOutputSurface : public OutputSurface { 1545 class MockOutputSurface : public OutputSurface {
1474 public: 1546 public:
1475 MockOutputSurface() 1547 MockOutputSurface()
1476 : OutputSurface(scoped_ptr<WebKit::WebGraphicsContext3D>( 1548 : OutputSurface(scoped_ptr<WebKit::WebGraphicsContext3D>(
1477 new StrictMock<OutputSurfaceMockContext>)) {} 1549 new StrictMock<OutputSurfaceMockContext>)) {
1550 surface_size_ = gfx::Size(100, 100);
1551 }
1478 virtual ~MockOutputSurface() {} 1552 virtual ~MockOutputSurface() {}
1479 1553
1480 MOCK_METHOD1(SendFrameToParentCompositor, void(CompositorFrame* frame)); 1554 MOCK_METHOD1(SendFrameToParentCompositor, void(CompositorFrame* frame));
1481 MOCK_METHOD0(EnsureBackbuffer, void()); 1555 MOCK_METHOD0(EnsureBackbuffer, void());
1482 MOCK_METHOD0(DiscardBackbuffer, void()); 1556 MOCK_METHOD0(DiscardBackbuffer, void());
1483 MOCK_METHOD2(Reshape, void(gfx::Size size, float scale_factor)); 1557 MOCK_METHOD2(Reshape, void(gfx::Size size, float scale_factor));
1484 MOCK_METHOD0(BindFramebuffer, void()); 1558 MOCK_METHOD0(BindFramebuffer, void());
1485 MOCK_METHOD2(PostSubBuffer, void(gfx::Rect rect, const ui::LatencyInfo&)); 1559 MOCK_METHOD2(PostSubBuffer, void(gfx::Rect rect, const ui::LatencyInfo&));
1486 MOCK_METHOD1(SwapBuffers, void(const ui::LatencyInfo&)); 1560 MOCK_METHOD1(SwapBuffers, void(const ui::LatencyInfo&));
1487 }; 1561 };
1488 1562
1489 class MockOutputSurfaceTest : public testing::Test, public FakeRendererClient { 1563 class MockOutputSurfaceTest : public testing::Test, public FakeRendererClient {
1490 protected: 1564 protected:
1491 MockOutputSurfaceTest() 1565 MockOutputSurfaceTest()
1492 : resource_provider_(ResourceProvider::Create(&output_surface_, 0)), 1566 : resource_provider_(ResourceProvider::Create(&output_surface_, 0)),
1493 renderer_(this, &output_surface_, resource_provider_.get()) {} 1567 renderer_(this, &output_surface_, resource_provider_.get()) {}
1494 1568
1495 virtual void SetUp() { EXPECT_TRUE(renderer_.Initialize()); } 1569 virtual void SetUp() { EXPECT_TRUE(renderer_.Initialize()); }
1496 1570
1497 void SwapBuffers() { renderer_.SwapBuffers(ui::LatencyInfo()); } 1571 void SwapBuffers() { renderer_.SwapBuffers(ui::LatencyInfo()); }
1498 1572
1499 void DrawFrame() { 1573 void DrawFrame() {
1500 gfx::Rect viewport_rect(DeviceViewportSize()); 1574 gfx::Rect viewport_rect(DeviceViewport());
1501 ScopedPtrVector<RenderPass>* render_passes = render_passes_in_draw_order(); 1575 ScopedPtrVector<RenderPass>* render_passes = render_passes_in_draw_order();
1502 render_passes->clear(); 1576 render_passes->clear();
1503 1577
1504 RenderPass::Id render_pass_id(1, 0); 1578 RenderPass::Id render_pass_id(1, 0);
1505 TestRenderPass* render_pass = AddRenderPass( 1579 TestRenderPass* render_pass = AddRenderPass(
1506 render_passes, render_pass_id, viewport_rect, gfx::Transform()); 1580 render_passes, render_pass_id, viewport_rect, gfx::Transform());
1507 AddQuad(render_pass, viewport_rect, SK_ColorGREEN); 1581 AddQuad(render_pass, viewport_rect, SK_ColorGREEN);
1508 1582
1509 EXPECT_CALL(output_surface_, EnsureBackbuffer()).WillRepeatedly(Return()); 1583 EXPECT_CALL(output_surface_, EnsureBackbuffer()).WillRepeatedly(Return());
1510 1584
1511 if (is_viewport_changed()) { 1585 EXPECT_CALL(output_surface_,
1512 EXPECT_CALL(output_surface_, 1586 Reshape(DeviceViewport().size(), DeviceScaleFactor())).Times(1);
1513 Reshape(DeviceViewportSize(), DeviceScaleFactor())).Times(1);
1514 clear_viewport_changed();
1515 }
1516 1587
1517 EXPECT_CALL(output_surface_, BindFramebuffer()).Times(1); 1588 EXPECT_CALL(output_surface_, BindFramebuffer()).Times(1);
1518 1589
1519 EXPECT_CALL(*Context(), drawElements(_, _, _, _)).Times(1); 1590 EXPECT_CALL(*Context(), drawElements(_, _, _, _)).Times(1);
1520 1591
1521 renderer_.DecideRenderPassAllocationsForFrame( 1592 renderer_.DecideRenderPassAllocationsForFrame(
1522 *render_passes_in_draw_order()); 1593 *render_passes_in_draw_order());
1523 renderer_.DrawFrame(render_passes_in_draw_order()); 1594 renderer_.DrawFrame(render_passes_in_draw_order());
1524 } 1595 }
1525 1596
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1659 base::MessageLoop::current()->Run(); 1730 base::MessageLoop::current()->Run();
1660 1731
1661 // The sync point should have happened. 1732 // The sync point should have happened.
1662 EXPECT_EQ(1, sync_point_callback_count); 1733 EXPECT_EQ(1, sync_point_callback_count);
1663 EXPECT_EQ(1, other_callback_count); 1734 EXPECT_EQ(1, other_callback_count);
1664 } 1735 }
1665 #endif // OS_ANDROID 1736 #endif // OS_ANDROID
1666 1737
1667 } // namespace 1738 } // namespace
1668 } // namespace cc 1739 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698