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

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: . 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 uint32_t boundTexture() const { return m_boundTexture; } 171 void GenTextures(GLsizei n, GLuint* textures) override
172 uint32_t boundTextureTarget() const { return m_boundTextureTarget; } 172 {
173 uint32_t mostRecentlyWaitedSyncToken() const { return m_mostRecentlyWaitedSy ncToken; } 173 static GLuint id = 1;
Ken Russell (switch to Gerrit) 2016/03/22 00:43:45 I think it'd be more reliable to add the most rece
danakj 2016/03/22 00:47:47 Well, the result should be roughly the same, the d
Ken Russell (switch to Gerrit) 2016/03/22 00:50:37 OK. I defer to your judgment.
174 uint32_t currentImageId() const { return m_currentImageId; } 174 for (GLsizei i = 0; i < n; ++i)
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; }
175 IntSize mostRecentlyProducedSize() const { return m_mostRecentlyProducedSize ; } 182 IntSize mostRecentlyProducedSize() const { return m_mostRecentlyProducedSize ; }
176 bool allowImageChromium() const { return m_allowImageChromium; } 183 bool allowImageChromium() const { return m_allowImageChromium; }
177 184
178 void setAllowImageChromium(bool allow) { m_allowImageChromium = allow; } 185 void setAllowImageChromium(bool allow) { m_allowImageChromium = allow; }
179 186
180 private: 187 private:
181 uint32_t m_boundTexture = 0; 188 GLuint m_boundTexture = 0;
182 uint32_t m_boundTextureTarget = 0; 189 GLuint m_boundTextureTarget = 0;
183 uint32_t m_mostRecentlyWaitedSyncToken = 0; 190 GLuint m_mostRecentlyWaitedSyncToken = 0;
184 WGC3Dbyte m_currentMailboxByte = 0; 191 WGC3Dbyte m_currentMailboxByte = 0;
185 IntSize m_mostRecentlyProducedSize; 192 IntSize m_mostRecentlyProducedSize;
186 bool m_allowImageChromium = true; 193 bool m_allowImageChromium = true;
187 uint32_t m_currentImageId = 1; 194 GLuint m_currentImageId = 1;
188 HashMap<uint32_t, IntSize> m_textureSizes; 195 HashMap<GLuint, IntSize> m_textureSizes;
189 HashMap<uint32_t, IntSize> m_imageSizes; 196 HashMap<GLuint, IntSize> m_imageSizes;
190 HashMap<uint32_t, uint32_t> m_imageToTextureMap; 197 HashMap<GLuint, GLuint> m_imageToTextureMap;
191 }; 198 };
192 199
193 class WebGraphicsContext3DForTests : public MockWebGraphicsContext3D { 200 class WebGraphicsContext3DForTests : public MockWebGraphicsContext3D {
194 public: 201 public:
195 WebGraphicsContext3DForTests(PassOwnPtr<GLES2InterfaceForTests> contextGL) 202 WebGraphicsContext3DForTests(PassOwnPtr<GLES2InterfaceForTests> contextGL)
196 : m_contextGL(std::move(contextGL)) 203 : m_contextGL(std::move(contextGL))
197 { 204 {
198 } 205 }
199 206
200 WGC3Duint mostRecentlyWaitedSyncToken() 207 WGC3Duint mostRecentlyWaitedSyncToken()
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 return; 618 return;
612 case GL_STENCIL_BITS: 619 case GL_STENCIL_BITS:
613 *value = (m_stencilAttachment || m_depthStencilAttachment) ? 8 : 0; 620 *value = (m_stencilAttachment || m_depthStencilAttachment) ? 8 : 0;
614 return; 621 return;
615 case GL_MAX_TEXTURE_SIZE: 622 case GL_MAX_TEXTURE_SIZE:
616 *value = 1024; 623 *value = 1024;
617 return; 624 return;
618 } 625 }
619 } 626 }
620 627
621 uint32_t stencilAttachment() const { return m_stencilAttachment; } 628 void GenRenderbuffers(GLsizei n, GLuint* renderbuffers) override
622 uint32_t depthAttachment() const { return m_depthAttachment; } 629 {
623 uint32_t depthStencilAttachment() const { return m_depthStencilAttachment; } 630 for (GLsizei i = 0; i < n; ++i)
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 ; }
624 638
625 private: 639 private:
626 uint32_t m_depthAttachment = 0; 640 GLuint m_nextGenRenderbufferId = 1;
627 uint32_t m_stencilAttachment = 0; 641 GLuint m_depthAttachment = 0;
628 uint32_t m_depthStencilAttachment = 0; 642 GLuint m_stencilAttachment = 0;
643 GLuint m_depthStencilAttachment = 0;
629 }; 644 };
630 645
631 class DepthStencilTrackingContext : public MockWebGraphicsContext3D { 646 class DepthStencilTrackingContext : public MockWebGraphicsContext3D {
632 public: 647 public:
633 DepthStencilTrackingContext() : m_nextRenderBufferId(1) {}
634 ~DepthStencilTrackingContext() override {} 648 ~DepthStencilTrackingContext() override {}
635 649
636 int numAllocatedRenderBuffer() const { return m_nextRenderBufferId - 1; } 650 size_t numAllocatedRenderBuffer() const { return m_contextGL.numAllocatedRen derBuffer(); }
637 WebGLId stencilAttachment() const { return m_contextGL.stencilAttachment(); } 651 WebGLId stencilAttachment() const { return m_contextGL.stencilAttachment(); }
638 WebGLId depthAttachment() const { return m_contextGL.depthAttachment(); } 652 WebGLId depthAttachment() const { return m_contextGL.depthAttachment(); }
639 WebGLId depthStencilAttachment() const { return m_contextGL.depthStencilAtta chment(); } 653 WebGLId depthStencilAttachment() const { return m_contextGL.depthStencilAtta chment(); }
640 654
641 WebString getString(WGC3Denum type) override 655 WebString getString(WGC3Denum type) override
642 { 656 {
643 if (type == GL_EXTENSIONS) { 657 if (type == GL_EXTENSIONS) {
644 return WebString::fromUTF8("GL_OES_packed_depth_stencil"); 658 return WebString::fromUTF8("GL_OES_packed_depth_stencil");
645 } 659 }
646 return WebString(); 660 return WebString();
647 } 661 }
648 662
649 WebGLId createRenderbuffer() override
650 {
651 return ++m_nextRenderBufferId;
652 }
653
654 gpu::gles2::GLES2Interface* getGLES2Interface() override { return &m_context GL; } 663 gpu::gles2::GLES2Interface* getGLES2Interface() override { return &m_context GL; }
655 664
656 private: 665 private:
657 WebGLId m_nextRenderBufferId;
658 DepthStencilTrackingGLES2Interface m_contextGL; 666 DepthStencilTrackingGLES2Interface m_contextGL;
659 }; 667 };
660 668
661 struct DepthStencilTestCase { 669 struct DepthStencilTestCase {
662 DepthStencilTestCase(bool requestStencil, bool requestDepth, int expectedRen derBuffers, const char* const testCaseName) 670 DepthStencilTestCase(bool requestStencil, bool requestDepth, int expectedRen derBuffers, const char* const testCaseName)
663 : requestStencil(requestStencil) 671 : requestStencil(requestStencil)
664 , requestDepth(requestDepth) 672 , requestDepth(requestDepth)
665 , expectedRenderBuffers(expectedRenderBuffers) 673 , expectedRenderBuffers(expectedRenderBuffers)
666 , testCaseName(testCaseName) { } 674 , testCaseName(testCaseName) { }
667 675
668 bool requestStencil; 676 bool requestStencil;
669 bool requestDepth; 677 bool requestDepth;
670 int expectedRenderBuffers; 678 size_t expectedRenderBuffers;
671 const char* const testCaseName; 679 const char* const testCaseName;
672 }; 680 };
673 681
674 // This tests that when the packed depth+stencil extension is supported DrawingB uffer always allocates 682 // 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 683 // 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 684 // 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 685 // that support this extension do not consider a framebuffer with only a depth o r a stencil buffer attached
678 // to be complete. 686 // to be complete.
679 TEST(DrawingBufferDepthStencilTest, packedDepthStencilSupported) 687 TEST(DrawingBufferDepthStencilTest, packedDepthStencilSupported)
680 { 688 {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 m_drawingBuffer->markContentsChanged(); 784 m_drawingBuffer->markContentsChanged();
777 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); 785 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0));
778 EXPECT_EQ(initialSize, webContext()->mostRecentlyProducedSize()); 786 EXPECT_EQ(initialSize, webContext()->mostRecentlyProducedSize());
779 EXPECT_FALSE(mailbox.allowOverlay); 787 EXPECT_FALSE(mailbox.allowOverlay);
780 788
781 m_drawingBuffer->mailboxReleased(mailbox, false); 789 m_drawingBuffer->mailboxReleased(mailbox, false);
782 m_drawingBuffer->beginDestruction(); 790 m_drawingBuffer->beginDestruction();
783 } 791 }
784 792
785 } // namespace blink 793 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698