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

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

Issue 683113005: Update from chromium https://crrev.com/302282 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « cc/output/gl_renderer.cc ('k') | cc/output/overlay_strategy_single_on_top.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 ASSERT_FALSE(renderer()->IsContextLost()); 107 ASSERT_FALSE(renderer()->IsContextLost());
108 } 108 }
109 109
110 void TestShadersWithTexCoordPrecision(TexCoordPrecision precision) { 110 void TestShadersWithTexCoordPrecision(TexCoordPrecision precision) {
111 for (int i = 0; i < NumBlendModes; ++i) { 111 for (int i = 0; i < NumBlendModes; ++i) {
112 BlendMode blend_mode = static_cast<BlendMode>(i); 112 BlendMode blend_mode = static_cast<BlendMode>(i);
113 EXPECT_PROGRAM_VALID( 113 EXPECT_PROGRAM_VALID(
114 renderer()->GetRenderPassProgram(precision, blend_mode)); 114 renderer()->GetRenderPassProgram(precision, blend_mode));
115 EXPECT_PROGRAM_VALID( 115 EXPECT_PROGRAM_VALID(
116 renderer()->GetRenderPassProgramAA(precision, blend_mode)); 116 renderer()->GetRenderPassProgramAA(precision, blend_mode));
117 EXPECT_PROGRAM_VALID(
118 renderer()->GetRenderPassMaskProgram(precision, blend_mode));
119 EXPECT_PROGRAM_VALID(
120 renderer()->GetRenderPassMaskProgramAA(precision, blend_mode));
121 EXPECT_PROGRAM_VALID(
122 renderer()->GetRenderPassColorMatrixProgram(precision, blend_mode));
123 EXPECT_PROGRAM_VALID(renderer()->GetRenderPassMaskColorMatrixProgramAA(
124 precision, blend_mode));
125 EXPECT_PROGRAM_VALID(
126 renderer()->GetRenderPassColorMatrixProgramAA(precision, blend_mode));
127 EXPECT_PROGRAM_VALID(renderer()->GetRenderPassMaskColorMatrixProgram(
128 precision, blend_mode));
129 } 117 }
130 EXPECT_PROGRAM_VALID(renderer()->GetTextureProgram(precision)); 118 EXPECT_PROGRAM_VALID(renderer()->GetTextureProgram(precision));
131 EXPECT_PROGRAM_VALID( 119 EXPECT_PROGRAM_VALID(
132 renderer()->GetNonPremultipliedTextureProgram(precision)); 120 renderer()->GetNonPremultipliedTextureProgram(precision));
133 EXPECT_PROGRAM_VALID(renderer()->GetTextureBackgroundProgram(precision)); 121 EXPECT_PROGRAM_VALID(renderer()->GetTextureBackgroundProgram(precision));
134 EXPECT_PROGRAM_VALID( 122 EXPECT_PROGRAM_VALID(
135 renderer()->GetNonPremultipliedTextureBackgroundProgram(precision)); 123 renderer()->GetNonPremultipliedTextureBackgroundProgram(precision));
136 EXPECT_PROGRAM_VALID(renderer()->GetTextureIOSurfaceProgram(precision)); 124 EXPECT_PROGRAM_VALID(renderer()->GetTextureIOSurfaceProgram(precision));
137 EXPECT_PROGRAM_VALID(renderer()->GetVideoYUVProgram(precision)); 125 EXPECT_PROGRAM_VALID(renderer()->GetVideoYUVProgram(precision));
138 EXPECT_PROGRAM_VALID(renderer()->GetVideoYUVAProgram(precision)); 126 EXPECT_PROGRAM_VALID(renderer()->GetVideoYUVAProgram(precision));
(...skipping 12 matching lines...) Expand all
151 void TestShadersWithSamplerType(TexCoordPrecision precision, 139 void TestShadersWithSamplerType(TexCoordPrecision precision,
152 SamplerType sampler) { 140 SamplerType sampler) {
153 EXPECT_PROGRAM_VALID(renderer()->GetTileProgram(precision, sampler)); 141 EXPECT_PROGRAM_VALID(renderer()->GetTileProgram(precision, sampler));
154 EXPECT_PROGRAM_VALID(renderer()->GetTileProgramOpaque(precision, sampler)); 142 EXPECT_PROGRAM_VALID(renderer()->GetTileProgramOpaque(precision, sampler));
155 EXPECT_PROGRAM_VALID(renderer()->GetTileProgramAA(precision, sampler)); 143 EXPECT_PROGRAM_VALID(renderer()->GetTileProgramAA(precision, sampler));
156 EXPECT_PROGRAM_VALID(renderer()->GetTileProgramSwizzle(precision, sampler)); 144 EXPECT_PROGRAM_VALID(renderer()->GetTileProgramSwizzle(precision, sampler));
157 EXPECT_PROGRAM_VALID( 145 EXPECT_PROGRAM_VALID(
158 renderer()->GetTileProgramSwizzleOpaque(precision, sampler)); 146 renderer()->GetTileProgramSwizzleOpaque(precision, sampler));
159 EXPECT_PROGRAM_VALID( 147 EXPECT_PROGRAM_VALID(
160 renderer()->GetTileProgramSwizzleAA(precision, sampler)); 148 renderer()->GetTileProgramSwizzleAA(precision, sampler));
149 for (int i = 0; i < NumBlendModes; ++i) {
150 BlendMode blend_mode = static_cast<BlendMode>(i);
151 EXPECT_PROGRAM_VALID(
152 renderer()->GetRenderPassMaskProgram(precision, sampler, blend_mode));
153 EXPECT_PROGRAM_VALID(renderer()->GetRenderPassMaskProgramAA(
154 precision, sampler, blend_mode));
155 EXPECT_PROGRAM_VALID(renderer()->GetRenderPassMaskColorMatrixProgramAA(
156 precision, sampler, blend_mode));
157 EXPECT_PROGRAM_VALID(renderer()->GetRenderPassMaskColorMatrixProgram(
158 precision, sampler, blend_mode));
159 }
161 } 160 }
162 }; 161 };
163 162
164 namespace { 163 namespace {
165 164
166 #if !defined(OS_ANDROID) 165 #if !defined(OS_ANDROID)
167 TEST_F(GLRendererShaderPixelTest, AllShadersCompile) { TestShaders(); } 166 TEST_F(GLRendererShaderPixelTest, AllShadersCompile) { TestShaders(); }
168 #endif 167 #endif
169 168
170 class FakeRendererGL : public GLRenderer { 169 class FakeRendererGL : public GLRenderer {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 BlendMode blend_mode) { 258 BlendMode blend_mode) {
260 EXPECT_PROGRAM_VALID( 259 EXPECT_PROGRAM_VALID(
261 &renderer_->render_pass_color_matrix_program_[precision][blend_mode]); 260 &renderer_->render_pass_color_matrix_program_[precision][blend_mode]);
262 EXPECT_EQ( 261 EXPECT_EQ(
263 renderer_->render_pass_color_matrix_program_[precision][blend_mode] 262 renderer_->render_pass_color_matrix_program_[precision][blend_mode]
264 .program(), 263 .program(),
265 renderer_->program_shadow_); 264 renderer_->program_shadow_);
266 } 265 }
267 266
268 void TestRenderPassMaskProgram(TexCoordPrecision precision, 267 void TestRenderPassMaskProgram(TexCoordPrecision precision,
268 SamplerType sampler,
269 BlendMode blend_mode) { 269 BlendMode blend_mode) {
270 EXPECT_PROGRAM_VALID( 270 EXPECT_PROGRAM_VALID(
271 &renderer_->render_pass_mask_program_[precision][blend_mode]); 271 &renderer_->render_pass_mask_program_[precision][sampler][blend_mode]);
272 EXPECT_EQ( 272 EXPECT_EQ(
273 renderer_->render_pass_mask_program_[precision][blend_mode].program(), 273 renderer_->render_pass_mask_program_[precision][sampler][blend_mode]
274 .program(),
274 renderer_->program_shadow_); 275 renderer_->program_shadow_);
275 } 276 }
276 277
277 void TestRenderPassMaskColorMatrixProgram(TexCoordPrecision precision, 278 void TestRenderPassMaskColorMatrixProgram(TexCoordPrecision precision,
279 SamplerType sampler,
278 BlendMode blend_mode) { 280 BlendMode blend_mode) {
279 EXPECT_PROGRAM_VALID( 281 EXPECT_PROGRAM_VALID(&renderer_->render_pass_mask_color_matrix_program_
280 &renderer_ 282 [precision][sampler][blend_mode]);
281 ->render_pass_mask_color_matrix_program_[precision][blend_mode]); 283 EXPECT_EQ(renderer_->render_pass_mask_color_matrix_program_
282 EXPECT_EQ( 284 [precision][sampler][blend_mode].program(),
283 renderer_->render_pass_mask_color_matrix_program_[precision][blend_mode] 285 renderer_->program_shadow_);
284 .program(),
285 renderer_->program_shadow_);
286 } 286 }
287 287
288 void TestRenderPassProgramAA(TexCoordPrecision precision, 288 void TestRenderPassProgramAA(TexCoordPrecision precision,
289 BlendMode blend_mode) { 289 BlendMode blend_mode) {
290 EXPECT_PROGRAM_VALID( 290 EXPECT_PROGRAM_VALID(
291 &renderer_->render_pass_program_aa_[precision][blend_mode]); 291 &renderer_->render_pass_program_aa_[precision][blend_mode]);
292 EXPECT_EQ( 292 EXPECT_EQ(
293 renderer_->render_pass_program_aa_[precision][blend_mode].program(), 293 renderer_->render_pass_program_aa_[precision][blend_mode].program(),
294 renderer_->program_shadow_); 294 renderer_->program_shadow_);
295 } 295 }
296 296
297 void TestRenderPassColorMatrixProgramAA(TexCoordPrecision precision, 297 void TestRenderPassColorMatrixProgramAA(TexCoordPrecision precision,
298 BlendMode blend_mode) { 298 BlendMode blend_mode) {
299 EXPECT_PROGRAM_VALID( 299 EXPECT_PROGRAM_VALID(
300 &renderer_ 300 &renderer_
301 ->render_pass_color_matrix_program_aa_[precision][blend_mode]); 301 ->render_pass_color_matrix_program_aa_[precision][blend_mode]);
302 EXPECT_EQ( 302 EXPECT_EQ(
303 renderer_->render_pass_color_matrix_program_aa_[precision][blend_mode] 303 renderer_->render_pass_color_matrix_program_aa_[precision][blend_mode]
304 .program(), 304 .program(),
305 renderer_->program_shadow_); 305 renderer_->program_shadow_);
306 } 306 }
307 307
308 void TestRenderPassMaskProgramAA(TexCoordPrecision precision, 308 void TestRenderPassMaskProgramAA(TexCoordPrecision precision,
309 SamplerType sampler,
309 BlendMode blend_mode) { 310 BlendMode blend_mode) {
310 EXPECT_PROGRAM_VALID( 311 EXPECT_PROGRAM_VALID(
311 &renderer_->render_pass_mask_program_aa_[precision][blend_mode]); 312 &renderer_
312 EXPECT_EQ(renderer_->render_pass_mask_program_aa_[precision][blend_mode] 313 ->render_pass_mask_program_aa_[precision][sampler][blend_mode]);
313 .program(),
314 renderer_->program_shadow_);
315 }
316
317 void TestRenderPassMaskColorMatrixProgramAA(TexCoordPrecision precision,
318 BlendMode blend_mode) {
319 EXPECT_PROGRAM_VALID(&renderer_->render_pass_mask_color_matrix_program_aa_
320 [precision][blend_mode]);
321 EXPECT_EQ( 314 EXPECT_EQ(
322 renderer_ 315 renderer_->render_pass_mask_program_aa_[precision][sampler][blend_mode]
323 ->render_pass_mask_color_matrix_program_aa_[precision][blend_mode]
324 .program(), 316 .program(),
325 renderer_->program_shadow_); 317 renderer_->program_shadow_);
326 } 318 }
327 319
320 void TestRenderPassMaskColorMatrixProgramAA(TexCoordPrecision precision,
321 SamplerType sampler,
322 BlendMode blend_mode) {
323 EXPECT_PROGRAM_VALID(&renderer_->render_pass_mask_color_matrix_program_aa_
324 [precision][sampler][blend_mode]);
325 EXPECT_EQ(renderer_->render_pass_mask_color_matrix_program_aa_
326 [precision][sampler][blend_mode].program(),
327 renderer_->program_shadow_);
328 }
329
328 void TestSolidColorProgramAA() { 330 void TestSolidColorProgramAA() {
329 EXPECT_PROGRAM_VALID(&renderer_->solid_color_program_aa_); 331 EXPECT_PROGRAM_VALID(&renderer_->solid_color_program_aa_);
330 EXPECT_EQ(renderer_->solid_color_program_aa_.program(), 332 EXPECT_EQ(renderer_->solid_color_program_aa_.program(),
331 renderer_->program_shadow_); 333 renderer_->program_shadow_);
332 } 334 }
333 335
334 LayerTreeSettings settings_; 336 LayerTreeSettings settings_;
335 FakeOutputSurfaceClient output_surface_client_; 337 FakeOutputSurfaceClient output_surface_client_;
336 scoped_ptr<FakeOutputSurface> output_surface_; 338 scoped_ptr<FakeOutputSurface> output_surface_;
337 FakeRendererClient renderer_client_; 339 FakeRendererClient renderer_client_;
(...skipping 1154 matching lines...) Expand 10 before | Expand all | Expand 10 after
1492 gfx::Transform(), 1494 gfx::Transform(),
1493 xfer_mode); 1495 xfer_mode);
1494 1496
1495 renderer_->DecideRenderPassAllocationsForFrame( 1497 renderer_->DecideRenderPassAllocationsForFrame(
1496 render_passes_in_draw_order_); 1498 render_passes_in_draw_order_);
1497 renderer_->DrawFrame(&render_passes_in_draw_order_, 1499 renderer_->DrawFrame(&render_passes_in_draw_order_,
1498 1.f, 1500 1.f,
1499 viewport_rect, 1501 viewport_rect,
1500 viewport_rect, 1502 viewport_rect,
1501 false); 1503 false);
1502 TestRenderPassMaskProgram(TexCoordPrecisionMedium, blend_mode); 1504 TestRenderPassMaskProgram(
1505 TexCoordPrecisionMedium, SamplerType2D, blend_mode);
1503 1506
1504 // RenderPassMaskColorMatrixProgram 1507 // RenderPassMaskColorMatrixProgram
1505 render_passes_in_draw_order_.clear(); 1508 render_passes_in_draw_order_.clear();
1506 1509
1507 child_pass = AddRenderPass(&render_passes_in_draw_order_, 1510 child_pass = AddRenderPass(&render_passes_in_draw_order_,
1508 child_pass_id, 1511 child_pass_id,
1509 child_rect, 1512 child_rect,
1510 gfx::Transform()); 1513 gfx::Transform());
1511 1514
1512 root_pass = AddRenderPass(&render_passes_in_draw_order_, 1515 root_pass = AddRenderPass(&render_passes_in_draw_order_,
1513 root_pass_id, 1516 root_pass_id,
1514 viewport_rect, 1517 viewport_rect,
1515 gfx::Transform()); 1518 gfx::Transform());
1516 1519
1517 AddRenderPassQuad( 1520 AddRenderPassQuad(
1518 root_pass, child_pass, mask, filters, gfx::Transform(), xfer_mode); 1521 root_pass, child_pass, mask, filters, gfx::Transform(), xfer_mode);
1519 1522
1520 renderer_->DecideRenderPassAllocationsForFrame( 1523 renderer_->DecideRenderPassAllocationsForFrame(
1521 render_passes_in_draw_order_); 1524 render_passes_in_draw_order_);
1522 renderer_->DrawFrame(&render_passes_in_draw_order_, 1525 renderer_->DrawFrame(&render_passes_in_draw_order_,
1523 1.f, 1526 1.f,
1524 viewport_rect, 1527 viewport_rect,
1525 viewport_rect, 1528 viewport_rect,
1526 false); 1529 false);
1527 TestRenderPassMaskColorMatrixProgram(TexCoordPrecisionMedium, blend_mode); 1530 TestRenderPassMaskColorMatrixProgram(
1531 TexCoordPrecisionMedium, SamplerType2D, blend_mode);
1528 1532
1529 // RenderPassProgramAA 1533 // RenderPassProgramAA
1530 render_passes_in_draw_order_.clear(); 1534 render_passes_in_draw_order_.clear();
1531 1535
1532 child_pass = AddRenderPass(&render_passes_in_draw_order_, 1536 child_pass = AddRenderPass(&render_passes_in_draw_order_,
1533 child_pass_id, 1537 child_pass_id,
1534 child_rect, 1538 child_rect,
1535 transform_causing_aa); 1539 transform_causing_aa);
1536 1540
1537 root_pass = AddRenderPass(&render_passes_in_draw_order_, 1541 root_pass = AddRenderPass(&render_passes_in_draw_order_,
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1600 transform_causing_aa, 1604 transform_causing_aa,
1601 xfer_mode); 1605 xfer_mode);
1602 1606
1603 renderer_->DecideRenderPassAllocationsForFrame( 1607 renderer_->DecideRenderPassAllocationsForFrame(
1604 render_passes_in_draw_order_); 1608 render_passes_in_draw_order_);
1605 renderer_->DrawFrame(&render_passes_in_draw_order_, 1609 renderer_->DrawFrame(&render_passes_in_draw_order_,
1606 1.f, 1610 1.f,
1607 viewport_rect, 1611 viewport_rect,
1608 viewport_rect, 1612 viewport_rect,
1609 false); 1613 false);
1610 TestRenderPassMaskProgramAA(TexCoordPrecisionMedium, blend_mode); 1614 TestRenderPassMaskProgramAA(
1615 TexCoordPrecisionMedium, SamplerType2D, blend_mode);
1611 1616
1612 // RenderPassMaskColorMatrixProgramAA 1617 // RenderPassMaskColorMatrixProgramAA
1613 render_passes_in_draw_order_.clear(); 1618 render_passes_in_draw_order_.clear();
1614 1619
1615 child_pass = AddRenderPass(&render_passes_in_draw_order_, 1620 child_pass = AddRenderPass(&render_passes_in_draw_order_,
1616 child_pass_id, 1621 child_pass_id,
1617 child_rect, 1622 child_rect,
1618 transform_causing_aa); 1623 transform_causing_aa);
1619 1624
1620 root_pass = AddRenderPass(&render_passes_in_draw_order_, 1625 root_pass = AddRenderPass(&render_passes_in_draw_order_,
1621 root_pass_id, 1626 root_pass_id,
1622 viewport_rect, 1627 viewport_rect,
1623 transform_causing_aa); 1628 transform_causing_aa);
1624 1629
1625 AddRenderPassQuad( 1630 AddRenderPassQuad(
1626 root_pass, child_pass, mask, filters, transform_causing_aa, xfer_mode); 1631 root_pass, child_pass, mask, filters, transform_causing_aa, xfer_mode);
1627 1632
1628 renderer_->DecideRenderPassAllocationsForFrame( 1633 renderer_->DecideRenderPassAllocationsForFrame(
1629 render_passes_in_draw_order_); 1634 render_passes_in_draw_order_);
1630 renderer_->DrawFrame(&render_passes_in_draw_order_, 1635 renderer_->DrawFrame(&render_passes_in_draw_order_,
1631 1.f, 1636 1.f,
1632 viewport_rect, 1637 viewport_rect,
1633 viewport_rect, 1638 viewport_rect,
1634 false); 1639 false);
1635 TestRenderPassMaskColorMatrixProgramAA(TexCoordPrecisionMedium, blend_mode); 1640 TestRenderPassMaskColorMatrixProgramAA(
1641 TexCoordPrecisionMedium, SamplerType2D, blend_mode);
1636 } 1642 }
1637 } 1643 }
1638 1644
1639 // At this time, the AA code path cannot be taken if the surface's rect would 1645 // At this time, the AA code path cannot be taken if the surface's rect would
1640 // project incorrectly by the given transform, because of w<0 clipping. 1646 // project incorrectly by the given transform, because of w<0 clipping.
1641 TEST_F(GLRendererShaderTest, DrawRenderPassQuadSkipsAAForClippingTransform) { 1647 TEST_F(GLRendererShaderTest, DrawRenderPassQuadSkipsAAForClippingTransform) {
1642 gfx::Rect child_rect(50, 50); 1648 gfx::Rect child_rect(50, 50);
1643 RenderPassId child_pass_id(2, 0); 1649 RenderPassId child_pass_id(2, 0);
1644 TestRenderPass* child_pass; 1650 TestRenderPass* child_pass;
1645 1651
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
1915 base::MessageLoop::current()->Run(); 1921 base::MessageLoop::current()->Run();
1916 1922
1917 // The sync point should have happened. 1923 // The sync point should have happened.
1918 EXPECT_EQ(1, sync_point_callback_count); 1924 EXPECT_EQ(1, sync_point_callback_count);
1919 EXPECT_EQ(1, other_callback_count); 1925 EXPECT_EQ(1, other_callback_count);
1920 } 1926 }
1921 #endif // OS_ANDROID 1927 #endif // OS_ANDROID
1922 1928
1923 } // namespace 1929 } // namespace
1924 } // namespace cc 1930 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/gl_renderer.cc ('k') | cc/output/overlay_strategy_single_on_top.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698