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

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

Issue 1814263004: Remove create/delete methods from WebGraphicsContext3D. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@complex-casts
Patch Set: complex-create: rebase 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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 m_imageToTextureMap.remove(imageId); 163 m_imageToTextureMap.remove(imageId);
164 ReleaseTexImage2DMock(imageId); 164 ReleaseTexImage2DMock(imageId);
165 } 165 }
166 } 166 }
167 167
168 void GenSyncTokenCHROMIUM(GLuint64 fenceSync, GLbyte* syncToken) override 168 void GenSyncTokenCHROMIUM(GLuint64 fenceSync, GLbyte* syncToken) override
169 { 169 {
170 memcpy(syncToken, &fenceSync, sizeof(fenceSync)); 170 memcpy(syncToken, &fenceSync, sizeof(fenceSync));
171 } 171 }
172 172
173 uint32_t boundTexture() const { return m_boundTexture; } 173 void GenTextures(GLsizei n, GLuint* textures) override
174 uint32_t boundTextureTarget() const { return m_boundTextureTarget; } 174 {
175 uint32_t mostRecentlyWaitedSyncToken() const { return m_mostRecentlyWaitedSy ncToken; } 175 static GLuint id = 1;
176 uint32_t currentImageId() const { return m_currentImageId; } 176 for (GLsizei i = 0; i < n; ++i)
177 textures[i] = id++;
178 }
179
180 GLuint boundTexture() const { return m_boundTexture; }
181 GLuint boundTextureTarget() const { return m_boundTextureTarget; }
182 GLuint mostRecentlyWaitedSyncToken() const { return m_mostRecentlyWaitedSync Token; }
183 GLuint currentImageId() const { return m_currentImageId; }
177 IntSize mostRecentlyProducedSize() const { return m_mostRecentlyProducedSize ; } 184 IntSize mostRecentlyProducedSize() const { return m_mostRecentlyProducedSize ; }
178 bool allowImageChromium() const { return m_allowImageChromium; } 185 bool allowImageChromium() const { return m_allowImageChromium; }
179 186
180 void setAllowImageChromium(bool allow) { m_allowImageChromium = allow; } 187 void setAllowImageChromium(bool allow) { m_allowImageChromium = allow; }
181 188
182 private: 189 private:
183 uint32_t m_boundTexture = 0; 190 GLuint m_boundTexture = 0;
184 uint32_t m_boundTextureTarget = 0; 191 GLuint m_boundTextureTarget = 0;
185 uint32_t m_mostRecentlyWaitedSyncToken = 0; 192 GLuint m_mostRecentlyWaitedSyncToken = 0;
186 WGC3Dbyte m_currentMailboxByte = 0; 193 WGC3Dbyte m_currentMailboxByte = 0;
187 IntSize m_mostRecentlyProducedSize; 194 IntSize m_mostRecentlyProducedSize;
188 bool m_allowImageChromium = true; 195 bool m_allowImageChromium = true;
189 uint32_t m_currentImageId = 1; 196 GLuint m_currentImageId = 1;
190 HashMap<uint32_t, IntSize> m_textureSizes; 197 HashMap<GLuint, IntSize> m_textureSizes;
191 HashMap<uint32_t, IntSize> m_imageSizes; 198 HashMap<GLuint, IntSize> m_imageSizes;
192 HashMap<uint32_t, uint32_t> m_imageToTextureMap; 199 HashMap<GLuint, GLuint> m_imageToTextureMap;
193 }; 200 };
194 201
195 class WebGraphicsContext3DForTests : public MockWebGraphicsContext3D { 202 class WebGraphicsContext3DForTests : public MockWebGraphicsContext3D {
196 public: 203 public:
197 WebGraphicsContext3DForTests(GLES2InterfaceForTests* contextGL) 204 WebGraphicsContext3DForTests(GLES2InterfaceForTests* contextGL)
198 : m_contextGL(contextGL) 205 : m_contextGL(contextGL)
199 { 206 {
200 } 207 }
201 208
202 WGC3Duint mostRecentlyWaitedSyncToken() 209 WGC3Duint mostRecentlyWaitedSyncToken()
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 return; 639 return;
633 case GL_STENCIL_BITS: 640 case GL_STENCIL_BITS:
634 *value = (m_stencilAttachment || m_depthStencilAttachment) ? 8 : 0; 641 *value = (m_stencilAttachment || m_depthStencilAttachment) ? 8 : 0;
635 return; 642 return;
636 case GL_MAX_TEXTURE_SIZE: 643 case GL_MAX_TEXTURE_SIZE:
637 *value = 1024; 644 *value = 1024;
638 return; 645 return;
639 } 646 }
640 } 647 }
641 648
642 uint32_t stencilAttachment() const { return m_stencilAttachment; } 649 void GenRenderbuffers(GLsizei n, GLuint* renderbuffers) override
643 uint32_t depthAttachment() const { return m_depthAttachment; } 650 {
644 uint32_t depthStencilAttachment() const { return m_depthStencilAttachment; } 651 for (GLsizei i = 0; i < n; ++i)
652 renderbuffers[i] = m_nextGenRenderbufferId++;
653 }
654
655 GLuint stencilAttachment() const { return m_stencilAttachment; }
656 GLuint depthAttachment() const { return m_depthAttachment; }
657 GLuint depthStencilAttachment() const { return m_depthStencilAttachment; }
658 size_t numAllocatedRenderBuffer() const { return m_nextGenRenderbufferId - 1 ; }
645 659
646 private: 660 private:
647 uint32_t m_depthAttachment = 0; 661 GLuint m_nextGenRenderbufferId = 1;
648 uint32_t m_stencilAttachment = 0; 662 GLuint m_depthAttachment = 0;
649 uint32_t m_depthStencilAttachment = 0; 663 GLuint m_stencilAttachment = 0;
664 GLuint m_depthStencilAttachment = 0;
650 }; 665 };
651 666
652 class DepthStencilTrackingContext : public MockWebGraphicsContext3D { 667 class DepthStencilTrackingContext : public MockWebGraphicsContext3D {
653 public: 668 public:
654 DepthStencilTrackingContext(DepthStencilTrackingGLES2Interface* gl) 669 DepthStencilTrackingContext(DepthStencilTrackingGLES2Interface* gl)
655 : m_nextRenderBufferId(1) 670 : m_contextGL(gl)
656 , m_contextGL(gl)
657 { 671 {
658 } 672 }
659 ~DepthStencilTrackingContext() override {} 673 ~DepthStencilTrackingContext() override {}
660 674
661 int numAllocatedRenderBuffer() const { return m_nextRenderBufferId - 1; } 675 size_t numAllocatedRenderBuffer() const { return m_contextGL->numAllocatedRe nderBuffer(); }
662 WebGLId stencilAttachment() const { return m_contextGL->stencilAttachment(); } 676 WebGLId stencilAttachment() const { return m_contextGL->stencilAttachment(); }
663 WebGLId depthAttachment() const { return m_contextGL->depthAttachment(); } 677 WebGLId depthAttachment() const { return m_contextGL->depthAttachment(); }
664 WebGLId depthStencilAttachment() const { return m_contextGL->depthStencilAtt achment(); } 678 WebGLId depthStencilAttachment() const { return m_contextGL->depthStencilAtt achment(); }
665 679
666 WebString getString(WGC3Denum type) override 680 WebString getString(WGC3Denum type) override
667 { 681 {
668 if (type == GL_EXTENSIONS) { 682 if (type == GL_EXTENSIONS) {
669 return WebString::fromUTF8("GL_OES_packed_depth_stencil"); 683 return WebString::fromUTF8("GL_OES_packed_depth_stencil");
670 } 684 }
671 return WebString(); 685 return WebString();
672 } 686 }
673 687
674 WebGLId createRenderbuffer() override
675 {
676 return ++m_nextRenderBufferId;
677 }
678
679 gpu::gles2::GLES2Interface* getGLES2Interface() override { return m_contextG L; } 688 gpu::gles2::GLES2Interface* getGLES2Interface() override { return m_contextG L; }
680 689
681 private: 690 private:
682 WebGLId m_nextRenderBufferId;
683 DepthStencilTrackingGLES2Interface* m_contextGL; 691 DepthStencilTrackingGLES2Interface* m_contextGL;
684 }; 692 };
685 693
686 struct DepthStencilTestCase { 694 struct DepthStencilTestCase {
687 DepthStencilTestCase(bool requestStencil, bool requestDepth, int expectedRen derBuffers, const char* const testCaseName) 695 DepthStencilTestCase(bool requestStencil, bool requestDepth, int expectedRen derBuffers, const char* const testCaseName)
688 : requestStencil(requestStencil) 696 : requestStencil(requestStencil)
689 , requestDepth(requestDepth) 697 , requestDepth(requestDepth)
690 , expectedRenderBuffers(expectedRenderBuffers) 698 , expectedRenderBuffers(expectedRenderBuffers)
691 , testCaseName(testCaseName) { } 699 , testCaseName(testCaseName) { }
692 700
693 bool requestStencil; 701 bool requestStencil;
694 bool requestDepth; 702 bool requestDepth;
695 int expectedRenderBuffers; 703 size_t expectedRenderBuffers;
696 const char* const testCaseName; 704 const char* const testCaseName;
697 }; 705 };
698 706
699 // This tests that when the packed depth+stencil extension is supported DrawingB uffer always allocates 707 // This tests that when the packed depth+stencil extension is supported DrawingB uffer always allocates
700 // a single packed renderbuffer if either is requested and properly computes the actual context attributes 708 // a single packed renderbuffer if either is requested and properly computes the actual context attributes
701 // as defined by WebGL. We always allocate a packed buffer in this case since ma ny desktop OpenGL drivers 709 // as defined by WebGL. We always allocate a packed buffer in this case since ma ny desktop OpenGL drivers
702 // that support this extension do not consider a framebuffer with only a depth o r a stencil buffer attached 710 // that support this extension do not consider a framebuffer with only a depth o r a stencil buffer attached
703 // to be complete. 711 // to be complete.
704 TEST(DrawingBufferDepthStencilTest, packedDepthStencilSupported) 712 TEST(DrawingBufferDepthStencilTest, packedDepthStencilSupported)
705 { 713 {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 m_drawingBuffer->markContentsChanged(); 813 m_drawingBuffer->markContentsChanged();
806 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); 814 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0));
807 EXPECT_EQ(initialSize, webContext()->mostRecentlyProducedSize()); 815 EXPECT_EQ(initialSize, webContext()->mostRecentlyProducedSize());
808 EXPECT_FALSE(mailbox.allowOverlay); 816 EXPECT_FALSE(mailbox.allowOverlay);
809 817
810 m_drawingBuffer->mailboxReleased(mailbox, false); 818 m_drawingBuffer->mailboxReleased(mailbox, false);
811 m_drawingBuffer->beginDestruction(); 819 m_drawingBuffer->beginDestruction();
812 } 820 }
813 821
814 } // namespace blink 822 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698