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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/gpu/DrawingBufferTest.cpp

Issue 1817323003: Revert of Remove create/delete methods from WebGraphicsContext3D. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@complex-casts
Patch Set: Created 4 years, 9 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 /* 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
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 void GenTextures(GLsizei n, GLuint* textures) override 171 uint32_t boundTexture() const { return m_boundTexture; }
172 { 172 uint32_t boundTextureTarget() const { return m_boundTextureTarget; }
173 static GLuint id = 1; 173 uint32_t mostRecentlyWaitedSyncToken() const { return m_mostRecentlyWaitedSy ncToken; }
174 for (GLsizei i = 0; i < n; ++i) 174 uint32_t currentImageId() const { return m_currentImageId; }
175 textures[i] = id++;
176 }
177
178 GLuint boundTexture() const { return m_boundTexture; }
179 GLuint boundTextureTarget() const { return m_boundTextureTarget; }
180 GLuint mostRecentlyWaitedSyncToken() const { return m_mostRecentlyWaitedSync Token; }
181 GLuint currentImageId() const { return m_currentImageId; }
182 IntSize mostRecentlyProducedSize() const { return m_mostRecentlyProducedSize ; } 175 IntSize mostRecentlyProducedSize() const { return m_mostRecentlyProducedSize ; }
183 bool allowImageChromium() const { return m_allowImageChromium; } 176 bool allowImageChromium() const { return m_allowImageChromium; }
184 177
185 void setAllowImageChromium(bool allow) { m_allowImageChromium = allow; } 178 void setAllowImageChromium(bool allow) { m_allowImageChromium = allow; }
186 179
187 private: 180 private:
188 GLuint m_boundTexture = 0; 181 uint32_t m_boundTexture = 0;
189 GLuint m_boundTextureTarget = 0; 182 uint32_t m_boundTextureTarget = 0;
190 GLuint m_mostRecentlyWaitedSyncToken = 0; 183 uint32_t m_mostRecentlyWaitedSyncToken = 0;
191 WGC3Dbyte m_currentMailboxByte = 0; 184 WGC3Dbyte m_currentMailboxByte = 0;
192 IntSize m_mostRecentlyProducedSize; 185 IntSize m_mostRecentlyProducedSize;
193 bool m_allowImageChromium = true; 186 bool m_allowImageChromium = true;
194 GLuint m_currentImageId = 1; 187 uint32_t m_currentImageId = 1;
195 HashMap<GLuint, IntSize> m_textureSizes; 188 HashMap<uint32_t, IntSize> m_textureSizes;
196 HashMap<GLuint, IntSize> m_imageSizes; 189 HashMap<uint32_t, IntSize> m_imageSizes;
197 HashMap<GLuint, GLuint> m_imageToTextureMap; 190 HashMap<uint32_t, uint32_t> m_imageToTextureMap;
198 }; 191 };
199 192
200 class WebGraphicsContext3DForTests : public MockWebGraphicsContext3D { 193 class WebGraphicsContext3DForTests : public MockWebGraphicsContext3D {
201 public: 194 public:
202 WebGraphicsContext3DForTests(PassOwnPtr<GLES2InterfaceForTests> contextGL) 195 WebGraphicsContext3DForTests(PassOwnPtr<GLES2InterfaceForTests> contextGL)
203 : m_contextGL(std::move(contextGL)) 196 : m_contextGL(std::move(contextGL))
204 { 197 {
205 } 198 }
206 199
207 WGC3Duint mostRecentlyWaitedSyncToken() 200 WGC3Duint mostRecentlyWaitedSyncToken()
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 return; 611 return;
619 case GL_STENCIL_BITS: 612 case GL_STENCIL_BITS:
620 *value = (m_stencilAttachment || m_depthStencilAttachment) ? 8 : 0; 613 *value = (m_stencilAttachment || m_depthStencilAttachment) ? 8 : 0;
621 return; 614 return;
622 case GL_MAX_TEXTURE_SIZE: 615 case GL_MAX_TEXTURE_SIZE:
623 *value = 1024; 616 *value = 1024;
624 return; 617 return;
625 } 618 }
626 } 619 }
627 620
628 void GenRenderbuffers(GLsizei n, GLuint* renderbuffers) override 621 uint32_t stencilAttachment() const { return m_stencilAttachment; }
629 { 622 uint32_t depthAttachment() const { return m_depthAttachment; }
630 for (GLsizei i = 0; i < n; ++i) 623 uint32_t depthStencilAttachment() const { return m_depthStencilAttachment; }
631 renderbuffers[i] = m_nextGenRenderbufferId++;
632 }
633
634 GLuint stencilAttachment() const { return m_stencilAttachment; }
635 GLuint depthAttachment() const { return m_depthAttachment; }
636 GLuint depthStencilAttachment() const { return m_depthStencilAttachment; }
637 size_t numAllocatedRenderBuffer() const { return m_nextGenRenderbufferId - 1 ; }
638 624
639 private: 625 private:
640 GLuint m_nextGenRenderbufferId = 1; 626 uint32_t m_depthAttachment = 0;
641 GLuint m_depthAttachment = 0; 627 uint32_t m_stencilAttachment = 0;
642 GLuint m_stencilAttachment = 0; 628 uint32_t m_depthStencilAttachment = 0;
643 GLuint m_depthStencilAttachment = 0;
644 }; 629 };
645 630
646 class DepthStencilTrackingContext : public MockWebGraphicsContext3D { 631 class DepthStencilTrackingContext : public MockWebGraphicsContext3D {
647 public: 632 public:
633 DepthStencilTrackingContext() : m_nextRenderBufferId(1) {}
648 ~DepthStencilTrackingContext() override {} 634 ~DepthStencilTrackingContext() override {}
649 635
650 size_t numAllocatedRenderBuffer() const { return m_contextGL.numAllocatedRen derBuffer(); } 636 int numAllocatedRenderBuffer() const { return m_nextRenderBufferId - 1; }
651 WebGLId stencilAttachment() const { return m_contextGL.stencilAttachment(); } 637 WebGLId stencilAttachment() const { return m_contextGL.stencilAttachment(); }
652 WebGLId depthAttachment() const { return m_contextGL.depthAttachment(); } 638 WebGLId depthAttachment() const { return m_contextGL.depthAttachment(); }
653 WebGLId depthStencilAttachment() const { return m_contextGL.depthStencilAtta chment(); } 639 WebGLId depthStencilAttachment() const { return m_contextGL.depthStencilAtta chment(); }
654 640
655 WebString getString(WGC3Denum type) override 641 WebString getString(WGC3Denum type) override
656 { 642 {
657 if (type == GL_EXTENSIONS) { 643 if (type == GL_EXTENSIONS) {
658 return WebString::fromUTF8("GL_OES_packed_depth_stencil"); 644 return WebString::fromUTF8("GL_OES_packed_depth_stencil");
659 } 645 }
660 return WebString(); 646 return WebString();
661 } 647 }
662 648
649 WebGLId createRenderbuffer() override
650 {
651 return ++m_nextRenderBufferId;
652 }
653
663 gpu::gles2::GLES2Interface* getGLES2Interface() override { return &m_context GL; } 654 gpu::gles2::GLES2Interface* getGLES2Interface() override { return &m_context GL; }
664 655
665 private: 656 private:
657 WebGLId m_nextRenderBufferId;
666 DepthStencilTrackingGLES2Interface m_contextGL; 658 DepthStencilTrackingGLES2Interface m_contextGL;
667 }; 659 };
668 660
669 struct DepthStencilTestCase { 661 struct DepthStencilTestCase {
670 DepthStencilTestCase(bool requestStencil, bool requestDepth, int expectedRen derBuffers, const char* const testCaseName) 662 DepthStencilTestCase(bool requestStencil, bool requestDepth, int expectedRen derBuffers, const char* const testCaseName)
671 : requestStencil(requestStencil) 663 : requestStencil(requestStencil)
672 , requestDepth(requestDepth) 664 , requestDepth(requestDepth)
673 , expectedRenderBuffers(expectedRenderBuffers) 665 , expectedRenderBuffers(expectedRenderBuffers)
674 , testCaseName(testCaseName) { } 666 , testCaseName(testCaseName) { }
675 667
676 bool requestStencil; 668 bool requestStencil;
677 bool requestDepth; 669 bool requestDepth;
678 size_t expectedRenderBuffers; 670 int expectedRenderBuffers;
679 const char* const testCaseName; 671 const char* const testCaseName;
680 }; 672 };
681 673
682 // This tests that when the packed depth+stencil extension is supported DrawingB uffer always allocates 674 // This tests that when the packed depth+stencil extension is supported DrawingB uffer always allocates
683 // a single packed renderbuffer if either is requested and properly computes the actual context attributes 675 // a single packed renderbuffer if either is requested and properly computes the actual context attributes
684 // as defined by WebGL. We always allocate a packed buffer in this case since ma ny desktop OpenGL drivers 676 // as defined by WebGL. We always allocate a packed buffer in this case since ma ny desktop OpenGL drivers
685 // that support this extension do not consider a framebuffer with only a depth o r a stencil buffer attached 677 // that support this extension do not consider a framebuffer with only a depth o r a stencil buffer attached
686 // to be complete. 678 // to be complete.
687 TEST(DrawingBufferDepthStencilTest, packedDepthStencilSupported) 679 TEST(DrawingBufferDepthStencilTest, packedDepthStencilSupported)
688 { 680 {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 m_drawingBuffer->markContentsChanged(); 776 m_drawingBuffer->markContentsChanged();
785 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); 777 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0));
786 EXPECT_EQ(initialSize, webContext()->mostRecentlyProducedSize()); 778 EXPECT_EQ(initialSize, webContext()->mostRecentlyProducedSize());
787 EXPECT_FALSE(mailbox.allowOverlay); 779 EXPECT_FALSE(mailbox.allowOverlay);
788 780
789 m_drawingBuffer->mailboxReleased(mailbox, false); 781 m_drawingBuffer->mailboxReleased(mailbox, false);
790 m_drawingBuffer->beginDestruction(); 782 m_drawingBuffer->beginDestruction();
791 } 783 }
792 784
793 } // namespace blink 785 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698