| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 m_imageToTextureMap.remove(imageId); | 161 m_imageToTextureMap.remove(imageId); |
| 162 ReleaseTexImage2DMock(imageId); | 162 ReleaseTexImage2DMock(imageId); |
| 163 } | 163 } |
| 164 } | 164 } |
| 165 | 165 |
| 166 void GenSyncTokenCHROMIUM(GLuint64 fenceSync, GLbyte* syncToken) override | 166 void GenSyncTokenCHROMIUM(GLuint64 fenceSync, GLbyte* syncToken) override |
| 167 { | 167 { |
| 168 memcpy(syncToken, &fenceSync, sizeof(fenceSync)); | 168 memcpy(syncToken, &fenceSync, sizeof(fenceSync)); |
| 169 } | 169 } |
| 170 | 170 |
| 171 uint32_t boundTexture() const { return m_boundTexture; } | 171 GLuint boundTexture() const { return m_boundTexture; } |
| 172 uint32_t boundTextureTarget() const { return m_boundTextureTarget; } | 172 GLuint boundTextureTarget() const { return m_boundTextureTarget; } |
| 173 uint32_t mostRecentlyWaitedSyncToken() const { return m_mostRecentlyWaitedSy
ncToken; } | 173 GLuint mostRecentlyWaitedSyncToken() const { return m_mostRecentlyWaitedSync
Token; } |
| 174 uint32_t currentImageId() const { return m_currentImageId; } | 174 GLuint currentImageId() const { return m_currentImageId; } |
| 175 IntSize mostRecentlyProducedSize() const { return m_mostRecentlyProducedSize
; } | 175 IntSize mostRecentlyProducedSize() const { return m_mostRecentlyProducedSize
; } |
| 176 bool allowImageChromium() const { return m_allowImageChromium; } | 176 bool allowImageChromium() const { return m_allowImageChromium; } |
| 177 | 177 |
| 178 void setAllowImageChromium(bool allow) { m_allowImageChromium = allow; } | 178 void setAllowImageChromium(bool allow) { m_allowImageChromium = allow; } |
| 179 | 179 |
| 180 private: | 180 private: |
| 181 uint32_t m_boundTexture = 0; | 181 GLuint m_boundTexture = 0; |
| 182 uint32_t m_boundTextureTarget = 0; | 182 GLuint m_boundTextureTarget = 0; |
| 183 uint32_t m_mostRecentlyWaitedSyncToken = 0; | 183 GLuint m_mostRecentlyWaitedSyncToken = 0; |
| 184 WGC3Dbyte m_currentMailboxByte = 0; | 184 WGC3Dbyte m_currentMailboxByte = 0; |
| 185 IntSize m_mostRecentlyProducedSize; | 185 IntSize m_mostRecentlyProducedSize; |
| 186 bool m_allowImageChromium = true; | 186 bool m_allowImageChromium = true; |
| 187 uint32_t m_currentImageId = 1; | 187 GLuint m_currentImageId = 1; |
| 188 HashMap<uint32_t, IntSize> m_textureSizes; | 188 HashMap<GLuint, IntSize> m_textureSizes; |
| 189 HashMap<uint32_t, IntSize> m_imageSizes; | 189 HashMap<GLuint, IntSize> m_imageSizes; |
| 190 HashMap<uint32_t, uint32_t> m_imageToTextureMap; | 190 HashMap<GLuint, GLuint> m_imageToTextureMap; |
| 191 }; | 191 }; |
| 192 | 192 |
| 193 class WebGraphicsContext3DForTests : public MockWebGraphicsContext3D { | 193 class WebGraphicsContext3DForTests : public MockWebGraphicsContext3D { |
| 194 public: | 194 public: |
| 195 WebGraphicsContext3DForTests(PassOwnPtr<GLES2InterfaceForTests> contextGL) | 195 WebGraphicsContext3DForTests(PassOwnPtr<GLES2InterfaceForTests> contextGL) |
| 196 : m_contextGL(std::move(contextGL)) | 196 : m_contextGL(std::move(contextGL)) |
| 197 { | 197 { |
| 198 } | 198 } |
| 199 | 199 |
| 200 WGC3Duint mostRecentlyWaitedSyncToken() | 200 WGC3Duint mostRecentlyWaitedSyncToken() |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 return; | 611 return; |
| 612 case GL_STENCIL_BITS: | 612 case GL_STENCIL_BITS: |
| 613 *value = (m_stencilAttachment || m_depthStencilAttachment) ? 8 : 0; | 613 *value = (m_stencilAttachment || m_depthStencilAttachment) ? 8 : 0; |
| 614 return; | 614 return; |
| 615 case GL_MAX_TEXTURE_SIZE: | 615 case GL_MAX_TEXTURE_SIZE: |
| 616 *value = 1024; | 616 *value = 1024; |
| 617 return; | 617 return; |
| 618 } | 618 } |
| 619 } | 619 } |
| 620 | 620 |
| 621 uint32_t stencilAttachment() const { return m_stencilAttachment; } | 621 void GenRenderbuffers(GLsizei n, GLuint* renderbuffers) override |
| 622 uint32_t depthAttachment() const { return m_depthAttachment; } | 622 { |
| 623 uint32_t depthStencilAttachment() const { return m_depthStencilAttachment; } | 623 for (GLsizei i = 0; i < n; ++i) |
| 624 renderbuffers[i] = m_nextGenRenderbufferId++; |
| 625 } |
| 626 |
| 627 GLuint stencilAttachment() const { return m_stencilAttachment; } |
| 628 GLuint depthAttachment() const { return m_depthAttachment; } |
| 629 GLuint depthStencilAttachment() const { return m_depthStencilAttachment; } |
| 630 size_t numAllocatedRenderBuffer() const { return m_nextGenRenderbufferId - 1
; } |
| 624 | 631 |
| 625 private: | 632 private: |
| 626 uint32_t m_depthAttachment = 0; | 633 GLuint m_nextGenRenderbufferId = 1; |
| 627 uint32_t m_stencilAttachment = 0; | 634 GLuint m_depthAttachment = 0; |
| 628 uint32_t m_depthStencilAttachment = 0; | 635 GLuint m_stencilAttachment = 0; |
| 636 GLuint m_depthStencilAttachment = 0; |
| 629 }; | 637 }; |
| 630 | 638 |
| 631 class DepthStencilTrackingContext : public MockWebGraphicsContext3D { | 639 class DepthStencilTrackingContext : public MockWebGraphicsContext3D { |
| 632 public: | 640 public: |
| 633 DepthStencilTrackingContext() : m_nextRenderBufferId(1) {} | |
| 634 ~DepthStencilTrackingContext() override {} | 641 ~DepthStencilTrackingContext() override {} |
| 635 | 642 |
| 636 int numAllocatedRenderBuffer() const { return m_nextRenderBufferId - 1; } | 643 size_t numAllocatedRenderBuffer() const { return m_contextGL.numAllocatedRen
derBuffer(); } |
| 637 WebGLId stencilAttachment() const { return m_contextGL.stencilAttachment();
} | 644 WebGLId stencilAttachment() const { return m_contextGL.stencilAttachment();
} |
| 638 WebGLId depthAttachment() const { return m_contextGL.depthAttachment(); } | 645 WebGLId depthAttachment() const { return m_contextGL.depthAttachment(); } |
| 639 WebGLId depthStencilAttachment() const { return m_contextGL.depthStencilAtta
chment(); } | 646 WebGLId depthStencilAttachment() const { return m_contextGL.depthStencilAtta
chment(); } |
| 640 | 647 |
| 641 WebString getString(WGC3Denum type) override | 648 WebString getString(WGC3Denum type) override |
| 642 { | 649 { |
| 643 if (type == GL_EXTENSIONS) { | 650 if (type == GL_EXTENSIONS) { |
| 644 return WebString::fromUTF8("GL_OES_packed_depth_stencil"); | 651 return WebString::fromUTF8("GL_OES_packed_depth_stencil"); |
| 645 } | 652 } |
| 646 return WebString(); | 653 return WebString(); |
| 647 } | 654 } |
| 648 | 655 |
| 649 WebGLId createRenderbuffer() override | |
| 650 { | |
| 651 return ++m_nextRenderBufferId; | |
| 652 } | |
| 653 | |
| 654 gpu::gles2::GLES2Interface* getGLES2Interface() override { return &m_context
GL; } | 656 gpu::gles2::GLES2Interface* getGLES2Interface() override { return &m_context
GL; } |
| 655 | 657 |
| 656 private: | 658 private: |
| 657 WebGLId m_nextRenderBufferId; | |
| 658 DepthStencilTrackingGLES2Interface m_contextGL; | 659 DepthStencilTrackingGLES2Interface m_contextGL; |
| 659 }; | 660 }; |
| 660 | 661 |
| 661 struct DepthStencilTestCase { | 662 struct DepthStencilTestCase { |
| 662 DepthStencilTestCase(bool requestStencil, bool requestDepth, int expectedRen
derBuffers, const char* const testCaseName) | 663 DepthStencilTestCase(bool requestStencil, bool requestDepth, int expectedRen
derBuffers, const char* const testCaseName) |
| 663 : requestStencil(requestStencil) | 664 : requestStencil(requestStencil) |
| 664 , requestDepth(requestDepth) | 665 , requestDepth(requestDepth) |
| 665 , expectedRenderBuffers(expectedRenderBuffers) | 666 , expectedRenderBuffers(expectedRenderBuffers) |
| 666 , testCaseName(testCaseName) { } | 667 , testCaseName(testCaseName) { } |
| 667 | 668 |
| 668 bool requestStencil; | 669 bool requestStencil; |
| 669 bool requestDepth; | 670 bool requestDepth; |
| 670 int expectedRenderBuffers; | 671 size_t expectedRenderBuffers; |
| 671 const char* const testCaseName; | 672 const char* const testCaseName; |
| 672 }; | 673 }; |
| 673 | 674 |
| 674 // This tests that when the packed depth+stencil extension is supported DrawingB
uffer always allocates | 675 // This tests that when the packed depth+stencil extension is supported DrawingB
uffer always allocates |
| 675 // a single packed renderbuffer if either is requested and properly computes the
actual context attributes | 676 // a single packed renderbuffer if either is requested and properly computes the
actual context attributes |
| 676 // as defined by WebGL. We always allocate a packed buffer in this case since ma
ny desktop OpenGL drivers | 677 // as defined by WebGL. We always allocate a packed buffer in this case since ma
ny desktop OpenGL drivers |
| 677 // that support this extension do not consider a framebuffer with only a depth o
r a stencil buffer attached | 678 // that support this extension do not consider a framebuffer with only a depth o
r a stencil buffer attached |
| 678 // to be complete. | 679 // to be complete. |
| 679 TEST(DrawingBufferDepthStencilTest, packedDepthStencilSupported) | 680 TEST(DrawingBufferDepthStencilTest, packedDepthStencilSupported) |
| 680 { | 681 { |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 m_drawingBuffer->markContentsChanged(); | 777 m_drawingBuffer->markContentsChanged(); |
| 777 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); | 778 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); |
| 778 EXPECT_EQ(initialSize, webContext()->mostRecentlyProducedSize()); | 779 EXPECT_EQ(initialSize, webContext()->mostRecentlyProducedSize()); |
| 779 EXPECT_FALSE(mailbox.allowOverlay); | 780 EXPECT_FALSE(mailbox.allowOverlay); |
| 780 | 781 |
| 781 m_drawingBuffer->mailboxReleased(mailbox, false); | 782 m_drawingBuffer->mailboxReleased(mailbox, false); |
| 782 m_drawingBuffer->beginDestruction(); | 783 m_drawingBuffer->beginDestruction(); |
| 783 } | 784 } |
| 784 | 785 |
| 785 } // namespace blink | 786 } // namespace blink |
| OLD | NEW |