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

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

Issue 126973002: Decouple cc::FakeWebGraphicsContext3D from blink::WGC3D (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « cc/output/gl_renderer.cc ('k') | cc/output/output_surface_unittest.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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 using GLRenderer::IsBackbufferDiscarded; 172 using GLRenderer::IsBackbufferDiscarded;
173 using GLRenderer::DoDrawQuad; 173 using GLRenderer::DoDrawQuad;
174 using GLRenderer::BeginDrawingFrame; 174 using GLRenderer::BeginDrawingFrame;
175 using GLRenderer::FinishDrawingQuadList; 175 using GLRenderer::FinishDrawingQuadList;
176 using GLRenderer::stencil_enabled; 176 using GLRenderer::stencil_enabled;
177 }; 177 };
178 178
179 class GLRendererWithDefaultHarnessTest : public GLRendererTest { 179 class GLRendererWithDefaultHarnessTest : public GLRendererTest {
180 protected: 180 protected:
181 GLRendererWithDefaultHarnessTest() { 181 GLRendererWithDefaultHarnessTest() {
182 output_surface_ = FakeOutputSurface::Create3d( 182 output_surface_ =
183 TestWebGraphicsContext3D::Create()).Pass(); 183 FakeOutputSurface::Create3d(TestWebGraphicsContext3D::Create()).Pass();
184 CHECK(output_surface_->BindToClient(&output_surface_client_)); 184 CHECK(output_surface_->BindToClient(&output_surface_client_));
185 185
186 resource_provider_ = ResourceProvider::Create( 186 resource_provider_ = ResourceProvider::Create(
187 output_surface_.get(), NULL, 0, false, 1).Pass(); 187 output_surface_.get(), NULL, 0, false, 1).Pass();
188 renderer_ = make_scoped_ptr(new FakeRendererGL(&renderer_client_, 188 renderer_ = make_scoped_ptr(new FakeRendererGL(&renderer_client_,
189 &settings_, 189 &settings_,
190 output_surface_.get(), 190 output_surface_.get(),
191 resource_provider_.get())); 191 resource_provider_.get()));
192 } 192 }
193 193
194 void SwapBuffers() { renderer_->SwapBuffers(CompositorFrameMetadata()); } 194 void SwapBuffers() { renderer_->SwapBuffers(CompositorFrameMetadata()); }
195 195
196 LayerTreeSettings settings_; 196 LayerTreeSettings settings_;
197 FakeOutputSurfaceClient output_surface_client_; 197 FakeOutputSurfaceClient output_surface_client_;
198 scoped_ptr<FakeOutputSurface> output_surface_; 198 scoped_ptr<FakeOutputSurface> output_surface_;
199 FakeRendererClient renderer_client_; 199 FakeRendererClient renderer_client_;
200 scoped_ptr<ResourceProvider> resource_provider_; 200 scoped_ptr<ResourceProvider> resource_provider_;
201 scoped_ptr<FakeRendererGL> renderer_; 201 scoped_ptr<FakeRendererGL> renderer_;
202 }; 202 };
203 203
204 // Closing the namespace here so that GLRendererShaderTest can take advantage 204 // Closing the namespace here so that GLRendererShaderTest can take advantage
205 // of the friend relationship with GLRenderer and all of the mock classes 205 // of the friend relationship with GLRenderer and all of the mock classes
206 // declared above it. 206 // declared above it.
207 } // namespace 207 } // namespace
208 208
209 class GLRendererShaderTest : public GLRendererTest { 209 class GLRendererShaderTest : public GLRendererTest {
210 protected: 210 protected:
211 GLRendererShaderTest() { 211 GLRendererShaderTest() {
212 output_surface_ = FakeOutputSurface::Create3d().Pass(); 212 output_surface_ = FakeOutputSurface::Create3d().Pass();
213 CHECK(output_surface_->BindToClient(&output_surface_client_)); 213 CHECK(output_surface_->BindToClient(&output_surface_client_));
214 214
215 resource_provider_ = ResourceProvider::Create( 215 resource_provider_ = ResourceProvider::Create(
216 output_surface_.get(), NULL, 0, false, 1).Pass(); 216 output_surface_.get(), NULL, 0, false, 1).Pass();
217 renderer_.reset(new FakeRendererGL(&renderer_client_, 217 renderer_.reset(new FakeRendererGL(&renderer_client_,
218 &settings_, 218 &settings_,
219 output_surface_.get(), 219 output_surface_.get(),
220 resource_provider_.get())); 220 resource_provider_.get()));
221 } 221 }
222 222
223 void TestRenderPassProgram(TexCoordPrecision precision) { 223 void TestRenderPassProgram(TexCoordPrecision precision) {
224 EXPECT_PROGRAM_VALID(&renderer_->render_pass_program_[precision]); 224 EXPECT_PROGRAM_VALID(&renderer_->render_pass_program_[precision]);
225 EXPECT_EQ(renderer_->render_pass_program_[precision].program(), 225 EXPECT_EQ(renderer_->render_pass_program_[precision].program(),
226 renderer_->program_shadow_); 226 renderer_->program_shadow_);
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 false); 403 false);
404 EXPECT_TRUE(renderer_->stencil_enabled()); 404 EXPECT_TRUE(renderer_->stencil_enabled());
405 } 405 }
406 406
407 class ForbidSynchronousCallContext : public TestWebGraphicsContext3D { 407 class ForbidSynchronousCallContext : public TestWebGraphicsContext3D {
408 public: 408 public:
409 ForbidSynchronousCallContext() {} 409 ForbidSynchronousCallContext() {}
410 410
411 virtual bool getActiveAttrib(WebGLId program, 411 virtual bool getActiveAttrib(WebGLId program,
412 WGC3Duint index, 412 WGC3Duint index,
413 ActiveInfo& info) { 413 blink::WebGraphicsContext3D::ActiveInfo& info)
414 OVERRIDE {
414 ADD_FAILURE(); 415 ADD_FAILURE();
415 return false; 416 return false;
416 } 417 }
417 virtual bool getActiveUniform(WebGLId program, 418 virtual bool getActiveUniform(WebGLId program,
418 WGC3Duint index, 419 WGC3Duint index,
419 ActiveInfo& info) { 420 blink::WebGraphicsContext3D::ActiveInfo& info)
421 OVERRIDE {
420 ADD_FAILURE(); 422 ADD_FAILURE();
421 return false; 423 return false;
422 } 424 }
423 virtual void getAttachedShaders(WebGLId program, 425 virtual void getAttachedShaders(WebGLId program,
424 WGC3Dsizei max_count, 426 WGC3Dsizei max_count,
425 WGC3Dsizei* count, 427 WGC3Dsizei* count,
426 WebGLId* shaders) { 428 WebGLId* shaders) OVERRIDE {
427 ADD_FAILURE(); 429 ADD_FAILURE();
428 } 430 }
429 virtual WGC3Dint getAttribLocation(WebGLId program, const WGC3Dchar* name) { 431 virtual WGC3Dint getAttribLocation(WebGLId program,
432 const WGC3Dchar* name) OVERRIDE {
430 ADD_FAILURE(); 433 ADD_FAILURE();
431 return 0; 434 return 0;
432 } 435 }
433 virtual void getBooleanv(WGC3Denum pname, WGC3Dboolean* value) { 436 virtual void getBooleanv(WGC3Denum pname, WGC3Dboolean* value) OVERRIDE {
434 ADD_FAILURE(); 437 ADD_FAILURE();
435 } 438 }
436 virtual void getBufferParameteriv(WGC3Denum target, 439 virtual void getBufferParameteriv(WGC3Denum target,
437 WGC3Denum pname, 440 WGC3Denum pname,
438 WGC3Dint* value) { 441 WGC3Dint* value) OVERRIDE {
439 ADD_FAILURE(); 442 ADD_FAILURE();
440 } 443 }
441 virtual Attributes getContextAttributes() { 444 virtual WGC3Denum getError() OVERRIDE {
442 ADD_FAILURE();
443 return attributes_;
444 }
445 virtual WGC3Denum getError() {
446 ADD_FAILURE(); 445 ADD_FAILURE();
447 return 0; 446 return 0;
448 } 447 }
449 virtual void getFloatv(WGC3Denum pname, WGC3Dfloat* value) { ADD_FAILURE(); } 448 virtual void getFloatv(WGC3Denum pname, WGC3Dfloat* value) OVERRIDE {
449 ADD_FAILURE();
450 }
450 virtual void getFramebufferAttachmentParameteriv(WGC3Denum target, 451 virtual void getFramebufferAttachmentParameteriv(WGC3Denum target,
451 WGC3Denum attachment, 452 WGC3Denum attachment,
452 WGC3Denum pname, 453 WGC3Denum pname,
453 WGC3Dint* value) { 454 WGC3Dint* value) OVERRIDE {
454 ADD_FAILURE(); 455 ADD_FAILURE();
455 } 456 }
456 virtual void getIntegerv(WGC3Denum pname, WGC3Dint* value) { 457 virtual void getIntegerv(WGC3Denum pname, WGC3Dint* value) OVERRIDE {
457 if (pname == GL_MAX_TEXTURE_SIZE) { 458 if (pname == GL_MAX_TEXTURE_SIZE) {
458 // MAX_TEXTURE_SIZE is cached client side, so it's OK to query. 459 // MAX_TEXTURE_SIZE is cached client side, so it's OK to query.
459 *value = 1024; 460 *value = 1024;
460 } else { 461 } else {
461 ADD_FAILURE(); 462 ADD_FAILURE();
462 } 463 }
463 } 464 }
464 465
465 // We allow querying the shader compilation and program link status in debug 466 // We allow querying the shader compilation and program link status in debug
466 // mode, but not release. 467 // mode, but not release.
467 virtual void getProgramiv(WebGLId program, WGC3Denum pname, WGC3Dint* value) { 468 virtual void getProgramiv(WebGLId program,
469 WGC3Denum pname,
470 WGC3Dint* value) OVERRIDE {
468 #ifndef NDEBUG 471 #ifndef NDEBUG
469 *value = 1; 472 *value = 1;
470 #else 473 #else
471 ADD_FAILURE(); 474 ADD_FAILURE();
472 #endif 475 #endif
473 } 476 }
474 477
475 virtual void getShaderiv(WebGLId shader, WGC3Denum pname, WGC3Dint* value) { 478 virtual void getShaderiv(WebGLId shader,
479 WGC3Denum pname,
480 WGC3Dint* value) OVERRIDE {
476 #ifndef NDEBUG 481 #ifndef NDEBUG
477 *value = 1; 482 *value = 1;
478 #else 483 #else
479 ADD_FAILURE(); 484 ADD_FAILURE();
480 #endif 485 #endif
481 } 486 }
482 487
483 virtual WebString getString(WGC3Denum name) { 488 virtual WebString getString(WGC3Denum name) OVERRIDE {
484 ADD_FAILURE() << name; 489 ADD_FAILURE() << name;
485 return WebString(); 490 return WebString();
486 } 491 }
487 492
488 virtual WebString getProgramInfoLog(WebGLId program) { 493 virtual WebString getProgramInfoLog(WebGLId program) OVERRIDE {
489 ADD_FAILURE(); 494 ADD_FAILURE();
490 return WebString(); 495 return WebString();
491 } 496 }
492 virtual void getRenderbufferParameteriv(WGC3Denum target, 497 virtual void getRenderbufferParameteriv(WGC3Denum target,
493 WGC3Denum pname, 498 WGC3Denum pname,
494 WGC3Dint* value) { 499 WGC3Dint* value) OVERRIDE {
495 ADD_FAILURE(); 500 ADD_FAILURE();
496 } 501 }
497 502
498 virtual WebString getShaderInfoLog(WebGLId shader) { 503 virtual WebString getShaderInfoLog(WebGLId shader) OVERRIDE {
499 ADD_FAILURE(); 504 ADD_FAILURE();
500 return WebString(); 505 return WebString();
501 } 506 }
502 virtual void getShaderPrecisionFormat(WGC3Denum shadertype, 507 virtual void getShaderPrecisionFormat(WGC3Denum shadertype,
503 WGC3Denum precisiontype, 508 WGC3Denum precisiontype,
504 WGC3Dint* range, 509 WGC3Dint* range,
505 WGC3Dint* precision) { 510 WGC3Dint* precision) OVERRIDE {
506 ADD_FAILURE(); 511 ADD_FAILURE();
507 } 512 }
508 virtual WebString getShaderSource(WebGLId shader) { 513 virtual WebString getShaderSource(WebGLId shader) OVERRIDE {
509 ADD_FAILURE(); 514 ADD_FAILURE();
510 return WebString(); 515 return WebString();
511 } 516 }
512 virtual void getTexParameterfv(WGC3Denum target, 517 virtual void getTexParameterfv(WGC3Denum target,
513 WGC3Denum pname, 518 WGC3Denum pname,
514 WGC3Dfloat* value) { 519 WGC3Dfloat* value) OVERRIDE {
515 ADD_FAILURE(); 520 ADD_FAILURE();
516 } 521 }
517 virtual void getTexParameteriv(WGC3Denum target, 522 virtual void getTexParameteriv(WGC3Denum target,
518 WGC3Denum pname, 523 WGC3Denum pname,
519 WGC3Dint* value) { 524 WGC3Dint* value) OVERRIDE {
520 ADD_FAILURE(); 525 ADD_FAILURE();
521 } 526 }
522 virtual void getUniformfv(WebGLId program, 527 virtual void getUniformfv(WebGLId program,
523 WGC3Dint location, 528 WGC3Dint location,
524 WGC3Dfloat* value) { 529 WGC3Dfloat* value) OVERRIDE {
525 ADD_FAILURE(); 530 ADD_FAILURE();
526 } 531 }
527 virtual void getUniformiv(WebGLId program, 532 virtual void getUniformiv(WebGLId program,
528 WGC3Dint location, 533 WGC3Dint location,
529 WGC3Dint* value) { 534 WGC3Dint* value) OVERRIDE {
530 ADD_FAILURE(); 535 ADD_FAILURE();
531 } 536 }
532 virtual WGC3Dint getUniformLocation(WebGLId program, const WGC3Dchar* name) { 537 virtual WGC3Dint getUniformLocation(WebGLId program,
538 const WGC3Dchar* name) OVERRIDE {
533 ADD_FAILURE(); 539 ADD_FAILURE();
534 return 0; 540 return 0;
535 } 541 }
536 virtual void getVertexAttribfv(WGC3Duint index, 542 virtual void getVertexAttribfv(WGC3Duint index,
537 WGC3Denum pname, 543 WGC3Denum pname,
538 WGC3Dfloat* value) { 544 WGC3Dfloat* value) OVERRIDE {
539 ADD_FAILURE(); 545 ADD_FAILURE();
540 } 546 }
541 virtual void getVertexAttribiv(WGC3Duint index, 547 virtual void getVertexAttribiv(WGC3Duint index,
542 WGC3Denum pname, 548 WGC3Denum pname,
543 WGC3Dint* value) { 549 WGC3Dint* value) OVERRIDE {
544 ADD_FAILURE(); 550 ADD_FAILURE();
545 } 551 }
546 virtual WGC3Dsizeiptr getVertexAttribOffset(WGC3Duint index, 552 virtual WGC3Dsizeiptr getVertexAttribOffset(WGC3Duint index,
547 WGC3Denum pname) { 553 WGC3Denum pname) OVERRIDE {
548 ADD_FAILURE(); 554 ADD_FAILURE();
549 return 0; 555 return 0;
550 } 556 }
551 }; 557 };
552
553 TEST_F(GLRendererTest, InitializationDoesNotMakeSynchronousCalls) { 558 TEST_F(GLRendererTest, InitializationDoesNotMakeSynchronousCalls) {
554 FakeOutputSurfaceClient output_surface_client; 559 FakeOutputSurfaceClient output_surface_client;
555 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( 560 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
556 scoped_ptr<TestWebGraphicsContext3D>(new ForbidSynchronousCallContext))); 561 scoped_ptr<TestWebGraphicsContext3D>(new ForbidSynchronousCallContext)));
557 CHECK(output_surface->BindToClient(&output_surface_client)); 562 CHECK(output_surface->BindToClient(&output_surface_client));
558 563
559 scoped_ptr<ResourceProvider> resource_provider( 564 scoped_ptr<ResourceProvider> resource_provider(
560 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); 565 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1));
561 566
562 LayerTreeSettings settings; 567 LayerTreeSettings settings;
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 Mock::VerifyAndClearExpectations(context); 743 Mock::VerifyAndClearExpectations(context);
739 } 744 }
740 745
741 class VisibilityChangeIsLastCallTrackingContext 746 class VisibilityChangeIsLastCallTrackingContext
742 : public TestWebGraphicsContext3D { 747 : public TestWebGraphicsContext3D {
743 public: 748 public:
744 VisibilityChangeIsLastCallTrackingContext() 749 VisibilityChangeIsLastCallTrackingContext()
745 : last_call_was_set_visibility_(false) {} 750 : last_call_was_set_visibility_(false) {}
746 751
747 // WebGraphicsContext3D methods. 752 // WebGraphicsContext3D methods.
748 virtual void flush() { 753 virtual void flush() OVERRIDE { last_call_was_set_visibility_ = false; }
754 virtual void deleteTexture(WebGLId) OVERRIDE {
749 last_call_was_set_visibility_ = false; 755 last_call_was_set_visibility_ = false;
750 } 756 }
751 virtual void deleteTexture(WebGLId) { 757 virtual void deleteFramebuffer(WebGLId) OVERRIDE {
752 last_call_was_set_visibility_ = false; 758 last_call_was_set_visibility_ = false;
753 } 759 }
754 virtual void deleteFramebuffer(WebGLId) { 760 virtual void deleteQueryEXT(WebGLId) OVERRIDE {
755 last_call_was_set_visibility_ = false; 761 last_call_was_set_visibility_ = false;
756 } 762 }
757 virtual void deleteQueryEXT(WebGLId) { 763 virtual void deleteRenderbuffer(WebGLId) OVERRIDE {
758 last_call_was_set_visibility_ = false;
759 }
760 virtual void deleteRenderbuffer(WebGLId) {
761 last_call_was_set_visibility_ = false; 764 last_call_was_set_visibility_ = false;
762 } 765 }
763 766
764 // Methods added for test. 767 // Methods added for test.
765 void set_last_call_was_visibility(bool visible) { 768 void set_last_call_was_visibility(bool visible) {
766 DCHECK(last_call_was_set_visibility_ == false); 769 DCHECK(last_call_was_set_visibility_ == false);
767 last_call_was_set_visibility_ = true; 770 last_call_was_set_visibility_ = true;
768 } 771 }
769 bool last_call_was_set_visibility() const { 772 bool last_call_was_set_visibility() const {
770 return last_call_was_set_visibility_; 773 return last_call_was_set_visibility_;
771 } 774 }
772 775
773 private: 776 private:
774 bool last_call_was_set_visibility_; 777 bool last_call_was_set_visibility_;
775 }; 778 };
776 779
777 TEST_F(GLRendererTest, VisibilityChangeIsLastCall) { 780 TEST_F(GLRendererTest, VisibilityChangeIsLastCall) {
778 scoped_ptr<VisibilityChangeIsLastCallTrackingContext> context_owned( 781 scoped_ptr<VisibilityChangeIsLastCallTrackingContext> context_owned(
779 new VisibilityChangeIsLastCallTrackingContext); 782 new VisibilityChangeIsLastCallTrackingContext);
780 VisibilityChangeIsLastCallTrackingContext* context = context_owned.get(); 783 VisibilityChangeIsLastCallTrackingContext* context = context_owned.get();
781 784
782 scoped_refptr<TestContextProvider> provider = TestContextProvider::Create( 785 scoped_refptr<TestContextProvider> provider = TestContextProvider::Create(
783 context_owned.PassAs<TestWebGraphicsContext3D>()); 786 context_owned.PassAs<TestWebGraphicsContext3D>());
784 787
785 provider->support()->SetSurfaceVisibleCallback(base::Bind( 788 provider->support()->SetSurfaceVisibleCallback(base::Bind(
786 &VisibilityChangeIsLastCallTrackingContext::set_last_call_was_visibility, 789 &VisibilityChangeIsLastCallTrackingContext::set_last_call_was_visibility,
787 base::Unretained(context))); 790 base::Unretained(context)));
788 791
789 FakeOutputSurfaceClient output_surface_client; 792 FakeOutputSurfaceClient output_surface_client;
790 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( 793 scoped_ptr<OutputSurface> output_surface(
791 provider)); 794 FakeOutputSurface::Create3d(provider));
792 CHECK(output_surface->BindToClient(&output_surface_client)); 795 CHECK(output_surface->BindToClient(&output_surface_client));
793 796
794 scoped_ptr<ResourceProvider> resource_provider( 797 scoped_ptr<ResourceProvider> resource_provider(
795 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); 798 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1));
796 799
797 LayerTreeSettings settings; 800 LayerTreeSettings settings;
798 FakeRendererClient renderer_client; 801 FakeRendererClient renderer_client;
799 FakeRendererGL renderer(&renderer_client, 802 FakeRendererGL renderer(&renderer_client,
800 &settings, 803 &settings,
801 output_surface.get(), 804 output_surface.get(),
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 1004
1002 // In multiple render passes all but the root pass should clear the 1005 // In multiple render passes all but the root pass should clear the
1003 // framebuffer. 1006 // framebuffer.
1004 Mock::VerifyAndClearExpectations(&mock_context); 1007 Mock::VerifyAndClearExpectations(&mock_context);
1005 } 1008 }
1006 1009
1007 class ScissorTestOnClearCheckingContext : public TestWebGraphicsContext3D { 1010 class ScissorTestOnClearCheckingContext : public TestWebGraphicsContext3D {
1008 public: 1011 public:
1009 ScissorTestOnClearCheckingContext() : scissor_enabled_(false) {} 1012 ScissorTestOnClearCheckingContext() : scissor_enabled_(false) {}
1010 1013
1011 virtual void clear(WGC3Dbitfield) { EXPECT_FALSE(scissor_enabled_); } 1014 virtual void clear(WGC3Dbitfield) OVERRIDE { EXPECT_FALSE(scissor_enabled_); }
1012 1015
1013 virtual void enable(WGC3Denum cap) { 1016 virtual void enable(WGC3Denum cap) OVERRIDE {
1014 if (cap == GL_SCISSOR_TEST) 1017 if (cap == GL_SCISSOR_TEST)
1015 scissor_enabled_ = true; 1018 scissor_enabled_ = true;
1016 } 1019 }
1017 1020
1018 virtual void disable(WGC3Denum cap) { 1021 virtual void disable(WGC3Denum cap) OVERRIDE {
1019 if (cap == GL_SCISSOR_TEST) 1022 if (cap == GL_SCISSOR_TEST)
1020 scissor_enabled_ = false; 1023 scissor_enabled_ = false;
1021 } 1024 }
1022 1025
1023 private: 1026 private:
1024 bool scissor_enabled_; 1027 bool scissor_enabled_;
1025 }; 1028 };
1026 1029
1027 TEST_F(GLRendererTest, ScissorTestWhenClearing) { 1030 TEST_F(GLRendererTest, ScissorTestWhenClearing) {
1028 scoped_ptr<ScissorTestOnClearCheckingContext> context_owned( 1031 scoped_ptr<ScissorTestOnClearCheckingContext> context_owned(
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 1088
1086 class DiscardCheckingContext : public TestWebGraphicsContext3D { 1089 class DiscardCheckingContext : public TestWebGraphicsContext3D {
1087 public: 1090 public:
1088 DiscardCheckingContext() : discarded_(0) { 1091 DiscardCheckingContext() : discarded_(0) {
1089 set_have_post_sub_buffer(true); 1092 set_have_post_sub_buffer(true);
1090 set_have_discard_framebuffer(true); 1093 set_have_discard_framebuffer(true);
1091 } 1094 }
1092 1095
1093 virtual void discardFramebufferEXT(WGC3Denum target, 1096 virtual void discardFramebufferEXT(WGC3Denum target,
1094 WGC3Dsizei numAttachments, 1097 WGC3Dsizei numAttachments,
1095 const WGC3Denum* attachments) { 1098 const WGC3Denum* attachments) OVERRIDE {
1096 ++discarded_; 1099 ++discarded_;
1097 } 1100 }
1098 1101
1099 int discarded() const { return discarded_; } 1102 int discarded() const { return discarded_; }
1100 void reset() { discarded_ = 0; } 1103 void reset() { discarded_ = 0; }
1101 1104
1102 private: 1105 private:
1103 int discarded_; 1106 int discarded_;
1104 }; 1107 };
1105 1108
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1299 1302
1300 class FlippedScissorAndViewportContext : public TestWebGraphicsContext3D { 1303 class FlippedScissorAndViewportContext : public TestWebGraphicsContext3D {
1301 public: 1304 public:
1302 FlippedScissorAndViewportContext() 1305 FlippedScissorAndViewportContext()
1303 : did_call_viewport_(false), did_call_scissor_(false) {} 1306 : did_call_viewport_(false), did_call_scissor_(false) {}
1304 virtual ~FlippedScissorAndViewportContext() { 1307 virtual ~FlippedScissorAndViewportContext() {
1305 EXPECT_TRUE(did_call_viewport_); 1308 EXPECT_TRUE(did_call_viewport_);
1306 EXPECT_TRUE(did_call_scissor_); 1309 EXPECT_TRUE(did_call_scissor_);
1307 } 1310 }
1308 1311
1309 virtual void viewport(GLint x, GLint y, GLsizei width, GLsizei height) { 1312 virtual void viewport(GLint x, GLint y, GLsizei width, GLsizei height)
1313 OVERRIDE {
1310 EXPECT_EQ(10, x); 1314 EXPECT_EQ(10, x);
1311 EXPECT_EQ(390, y); 1315 EXPECT_EQ(390, y);
1312 EXPECT_EQ(100, width); 1316 EXPECT_EQ(100, width);
1313 EXPECT_EQ(100, height); 1317 EXPECT_EQ(100, height);
1314 did_call_viewport_ = true; 1318 did_call_viewport_ = true;
1315 } 1319 }
1316 1320
1317 virtual void scissor(GLint x, GLint y, GLsizei width, GLsizei height) { 1321 virtual void scissor(GLint x, GLint y, GLsizei width, GLsizei height)
1322 OVERRIDE {
1318 EXPECT_EQ(30, x); 1323 EXPECT_EQ(30, x);
1319 EXPECT_EQ(450, y); 1324 EXPECT_EQ(450, y);
1320 EXPECT_EQ(20, width); 1325 EXPECT_EQ(20, width);
1321 EXPECT_EQ(20, height); 1326 EXPECT_EQ(20, height);
1322 did_call_scissor_ = true; 1327 did_call_scissor_ = true;
1323 } 1328 }
1324 1329
1325 private: 1330 private:
1326 bool did_call_viewport_; 1331 bool did_call_viewport_;
1327 bool did_call_scissor_; 1332 bool did_call_scissor_;
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
1692 viewport_rect, 1697 viewport_rect,
1693 viewport_rect, 1698 viewport_rect,
1694 true, 1699 true,
1695 false); 1700 false);
1696 1701
1697 TestSolidColorProgramAA(); 1702 TestSolidColorProgramAA();
1698 } 1703 }
1699 1704
1700 class OutputSurfaceMockContext : public TestWebGraphicsContext3D { 1705 class OutputSurfaceMockContext : public TestWebGraphicsContext3D {
1701 public: 1706 public:
1702 OutputSurfaceMockContext() { 1707 OutputSurfaceMockContext() { test_capabilities_.post_sub_buffer = true; }
1703 test_capabilities_.post_sub_buffer = true;
1704 }
1705 1708
1706 // Specifically override methods even if they are unused (used in conjunction 1709 // Specifically override methods even if they are unused (used in conjunction
1707 // with StrictMock). We need to make sure that GLRenderer does not issue 1710 // with StrictMock). We need to make sure that GLRenderer does not issue
1708 // framebuffer-related GL calls directly. Instead these are supposed to go 1711 // framebuffer-related GL calls directly. Instead these are supposed to go
1709 // through the OutputSurface abstraction. 1712 // through the OutputSurface abstraction.
1710 MOCK_METHOD2(bindFramebuffer, void(WGC3Denum target, WebGLId framebuffer)); 1713 MOCK_METHOD2(bindFramebuffer, void(WGC3Denum target, WebGLId framebuffer));
1711 MOCK_METHOD3(reshapeWithScaleFactor, 1714 MOCK_METHOD3(reshapeWithScaleFactor,
1712 void(int width, int height, float scale_factor)); 1715 void(int width, int height, float scale_factor));
1713 MOCK_METHOD4(drawElements, 1716 MOCK_METHOD4(drawElements,
1714 void(WGC3Denum mode, 1717 void(WGC3Denum mode,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1775 NULL, 1778 NULL,
1776 device_scale_factor, 1779 device_scale_factor,
1777 device_viewport_rect, 1780 device_viewport_rect,
1778 device_viewport_rect, 1781 device_viewport_rect,
1779 true, 1782 true,
1780 false); 1783 false);
1781 } 1784 }
1782 1785
1783 OutputSurfaceMockContext* Context() { 1786 OutputSurfaceMockContext* Context() {
1784 return static_cast<OutputSurfaceMockContext*>( 1787 return static_cast<OutputSurfaceMockContext*>(
1785 output_surface_.context_provider()->Context3d()); 1788 static_cast<TestContextProvider*>(
1789 output_surface_.context_provider().get())->TestContext3d());
1786 } 1790 }
1787 1791
1788 LayerTreeSettings settings_; 1792 LayerTreeSettings settings_;
1789 FakeOutputSurfaceClient output_surface_client_; 1793 FakeOutputSurfaceClient output_surface_client_;
1790 StrictMock<MockOutputSurface> output_surface_; 1794 StrictMock<MockOutputSurface> output_surface_;
1791 scoped_ptr<ResourceProvider> resource_provider_; 1795 scoped_ptr<ResourceProvider> resource_provider_;
1792 FakeRendererClient renderer_client_; 1796 FakeRendererClient renderer_client_;
1793 scoped_ptr<FakeRendererGL> renderer_; 1797 scoped_ptr<FakeRendererGL> renderer_;
1794 }; 1798 };
1795 1799
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1895 base::MessageLoop::current()->Run(); 1899 base::MessageLoop::current()->Run();
1896 1900
1897 // The sync point should have happened. 1901 // The sync point should have happened.
1898 EXPECT_EQ(1, sync_point_callback_count); 1902 EXPECT_EQ(1, sync_point_callback_count);
1899 EXPECT_EQ(1, other_callback_count); 1903 EXPECT_EQ(1, other_callback_count);
1900 } 1904 }
1901 #endif // OS_ANDROID 1905 #endif // OS_ANDROID
1902 1906
1903 } // namespace 1907 } // namespace
1904 } // namespace cc 1908 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/gl_renderer.cc ('k') | cc/output/output_surface_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698