OLD | NEW |
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/gl_renderer.h" | 5 #include "cc/gl_renderer.h" |
6 | 6 |
7 #include "cc/draw_quad.h" | 7 #include "cc/draw_quad.h" |
8 #include "cc/prioritized_resource_manager.h" | 8 #include "cc/prioritized_resource_manager.h" |
9 #include "cc/resource_provider.h" | 9 #include "cc/resource_provider.h" |
10 #include "cc/settings.h" | 10 #include "cc/settings.h" |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 // them both a pointer to a variable on the stack. | 478 // them both a pointer to a variable on the stack. |
479 context->setLastCallWasSetVisibilityPointer(&lastCallWasSetVisiblity); | 479 context->setLastCallWasSetVisibilityPointer(&lastCallWasSetVisiblity); |
480 mockClient.setLastCallWasSetVisibilityPointer(&lastCallWasSetVisiblity); | 480 mockClient.setLastCallWasSetVisibilityPointer(&lastCallWasSetVisiblity); |
481 renderer.setVisible(true); | 481 renderer.setVisible(true); |
482 renderer.drawFrame(mockClient.renderPassesInDrawOrder(), mockClient.renderPa
sses()); | 482 renderer.drawFrame(mockClient.renderPassesInDrawOrder(), mockClient.renderPa
sses()); |
483 renderer.setVisible(false); | 483 renderer.setVisible(false); |
484 EXPECT_TRUE(lastCallWasSetVisiblity); | 484 EXPECT_TRUE(lastCallWasSetVisiblity); |
485 } | 485 } |
486 | 486 |
487 | 487 |
488 class ActiveTextureTrackingContext : public FakeWebGraphicsContext3D { | 488 class TextureStateTrackingContext : public FakeWebGraphicsContext3D { |
489 public: | 489 public: |
490 ActiveTextureTrackingContext() | 490 TextureStateTrackingContext() |
491 : m_activeTexture(GL_INVALID_ENUM) | 491 : m_activeTexture(GL_INVALID_ENUM) |
| 492 , m_inDraw(false) |
492 { | 493 { |
493 } | 494 } |
494 | 495 |
495 virtual WebString getString(WGC3Denum name) | 496 virtual WebString getString(WGC3Denum name) |
496 { | 497 { |
497 if (name == GL_EXTENSIONS) | 498 if (name == GL_EXTENSIONS) |
498 return WebString("GL_OES_EGL_image_external"); | 499 return WebString("GL_OES_EGL_image_external"); |
499 return WebString(); | 500 return WebString(); |
500 } | 501 } |
501 | 502 |
| 503 // We shouldn't set any texture parameters during the draw sequence, althoug
h |
| 504 // we might when creating the quads. |
| 505 void setInDraw() { m_inDraw = true; } |
| 506 |
| 507 virtual void texParameteri(WGC3Denum target, WGC3Denum pname, WGC3Dint param
) |
| 508 { |
| 509 if (m_inDraw) |
| 510 ADD_FAILURE(); |
| 511 } |
| 512 |
502 virtual void activeTexture(WGC3Denum texture) | 513 virtual void activeTexture(WGC3Denum texture) |
503 { | 514 { |
504 EXPECT_NE(texture, m_activeTexture); | 515 EXPECT_NE(texture, m_activeTexture); |
505 m_activeTexture = texture; | 516 m_activeTexture = texture; |
506 } | 517 } |
507 | 518 |
508 WGC3Denum activeTexture() const { return m_activeTexture; } | 519 WGC3Denum activeTexture() const { return m_activeTexture; } |
509 | 520 |
510 private: | 521 private: |
| 522 bool m_inDraw; |
511 WGC3Denum m_activeTexture; | 523 WGC3Denum m_activeTexture; |
512 }; | 524 }; |
513 | 525 |
514 TEST(GLRendererTest2, activeTextureState) | 526 TEST(GLRendererTest2, activeTextureState) |
515 { | 527 { |
516 FakeRendererClient fakeClient; | 528 FakeRendererClient fakeClient; |
517 scoped_ptr<GraphicsContext> outputSurface(FakeWebCompositorOutputSurface::cr
eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new ActiveTextureTrackingContext))
); | 529 scoped_ptr<GraphicsContext> outputSurface(FakeWebCompositorOutputSurface::cr
eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new TextureStateTrackingContext)))
; |
518 ActiveTextureTrackingContext* context = static_cast<ActiveTextureTrackingCon
text*>(outputSurface->context3D()); | 530 TextureStateTrackingContext* context = static_cast<TextureStateTrackingConte
xt*>(outputSurface->context3D()); |
519 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); | 531 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); |
520 FakeRendererGL renderer(&fakeClient, resourceProvider.get()); | 532 FakeRendererGL renderer(&fakeClient, resourceProvider.get()); |
521 | 533 |
522 EXPECT_TRUE(renderer.initialize()); | 534 EXPECT_TRUE(renderer.initialize()); |
523 | 535 |
524 cc::RenderPass::Id id(1, 1); | 536 cc::RenderPass::Id id(1, 1); |
525 scoped_ptr<TestRenderPass> pass = TestRenderPass::create(id, gfx::Rect(0, 0,
100, 100), WebTransformationMatrix()); | 537 scoped_ptr<TestRenderPass> pass = TestRenderPass::create(id, gfx::Rect(0, 0,
100, 100), WebTransformationMatrix()); |
526 pass->appendOneOfEveryQuadType(resourceProvider.get()); | 538 pass->appendOneOfEveryQuadType(resourceProvider.get()); |
527 | 539 |
| 540 context->setInDraw(); |
| 541 |
528 cc::DirectRenderer::DrawingFrame drawingFrame; | 542 cc::DirectRenderer::DrawingFrame drawingFrame; |
529 renderer.beginDrawingFrame(drawingFrame); | 543 renderer.beginDrawingFrame(drawingFrame); |
530 EXPECT_EQ(context->activeTexture(), GL_TEXTURE0); | 544 EXPECT_EQ(context->activeTexture(), GL_TEXTURE0); |
531 | 545 |
532 for (cc::QuadList::backToFrontIterator it = pass->quadList().backToFrontBegi
n(); | 546 for (cc::QuadList::backToFrontIterator it = pass->quadList().backToFrontBegi
n(); |
533 it != pass->quadList().backToFrontEnd(); ++it) { | 547 it != pass->quadList().backToFrontEnd(); ++it) { |
534 renderer.drawQuad(drawingFrame, *it); | 548 renderer.drawQuad(drawingFrame, *it); |
535 } | 549 } |
536 EXPECT_EQ(context->activeTexture(), GL_TEXTURE0); | 550 EXPECT_EQ(context->activeTexture(), GL_TEXTURE0); |
537 } | 551 } |
538 | 552 |
539 } // namespace | 553 } // namespace |
540 } // namespace cc | 554 } // namespace cc |
OLD | NEW |