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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/gpu/DrawingBufferTestHelpers.h

Issue 2905633002: Bind framebuffer to fbo_ object before readPixels, rather than multisample_fbo_ (Closed)
Patch Set: rebase code Created 3 years, 6 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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "gpu/command_buffer/common/capabilities.h" 5 #include "gpu/command_buffer/common/capabilities.h"
6 #include "platform/RuntimeEnabledFeatures.h" 6 #include "platform/RuntimeEnabledFeatures.h"
7 #include "platform/graphics/CanvasColorParams.h" 7 #include "platform/graphics/CanvasColorParams.h"
8 #include "platform/graphics/gpu/DrawingBuffer.h" 8 #include "platform/graphics/gpu/DrawingBuffer.h"
9 #include "platform/graphics/gpu/Extensions3DUtil.h" 9 #include "platform/graphics/gpu/Extensions3DUtil.h"
10 #include "public/platform/WebGraphicsContext3DProvider.h" 10 #include "public/platform/WebGraphicsContext3DProvider.h"
11 #include "testing/gmock/include/gmock/gmock.h" 11 #include "testing/gmock/include/gmock/gmock.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 namespace blink { 14 namespace blink {
15 15
16 enum { 16 enum {
17 kInitialWidth = 100, 17 kInitialWidth = 100,
18 kInitialHeight = 100, 18 kInitialHeight = 100,
19 kAlternateHeight = 50, 19 kAlternateHeight = 50,
20 }; 20 };
21 21
22 enum UseMultisampling { 22 enum UseMultisampling {
23 kDisableMultisampling, 23 kDisableMultisampling,
24 kEnableMultisampling, 24 kEnableMultisampling,
25 }; 25 };
26 26
27 class DrawingBufferForTests : public DrawingBuffer {
28 public:
29 static PassRefPtr<DrawingBufferForTests> Create(
30 std::unique_ptr<WebGraphicsContext3DProvider> context_provider,
31 DrawingBuffer::Client* client,
32 const IntSize& size,
33 PreserveDrawingBuffer preserve,
34 UseMultisampling use_multisampling) {
35 std::unique_ptr<Extensions3DUtil> extensions_util =
36 Extensions3DUtil::Create(context_provider->ContextGL());
37 RefPtr<DrawingBufferForTests> drawing_buffer =
38 AdoptRef(new DrawingBufferForTests(std::move(context_provider),
39 std::move(extensions_util), client,
40 preserve));
41 if (!drawing_buffer->Initialize(
42 size, use_multisampling != kDisableMultisampling)) {
43 drawing_buffer->BeginDestruction();
44 return nullptr;
45 }
46 return drawing_buffer.Release();
47 }
48
49 DrawingBufferForTests(
50 std::unique_ptr<WebGraphicsContext3DProvider> context_provider,
51 std::unique_ptr<Extensions3DUtil> extensions_util,
52 DrawingBuffer::Client* client,
53 PreserveDrawingBuffer preserve)
54 : DrawingBuffer(
55 std::move(context_provider),
56 std::move(extensions_util),
57 client,
58 false /* discardFramebufferSupported */,
59 true /* wantAlphaChannel */,
60 false /* premultipliedAlpha */,
61 preserve,
62 kWebGL1,
63 false /* wantDepth */,
64 false /* wantStencil */,
65 DrawingBuffer::kAllowChromiumImage /* ChromiumImageUsage */,
66 CanvasColorParams()),
67 live_(0) {}
68
69 ~DrawingBufferForTests() override {
70 if (live_)
71 *live_ = false;
72 }
73
74 bool* live_;
75
76 int RecycledBitmapCount() { return recycled_bitmaps_.size(); }
77 };
78
79 class WebGraphicsContext3DProviderForTests 27 class WebGraphicsContext3DProviderForTests
80 : public WebGraphicsContext3DProvider { 28 : public WebGraphicsContext3DProvider {
81 public: 29 public:
82 WebGraphicsContext3DProviderForTests( 30 WebGraphicsContext3DProviderForTests(
83 std::unique_ptr<gpu::gles2::GLES2Interface> gl) 31 std::unique_ptr<gpu::gles2::GLES2Interface> gl)
84 : gl_(std::move(gl)) {} 32 : gl_(std::move(gl)) {}
85 33
86 gpu::gles2::GLES2Interface* ContextGL() override { return gl_.get(); } 34 gpu::gles2::GLES2Interface* ContextGL() override { return gl_.get(); }
87 bool IsSoftwareRendering() const override { return false; } 35 bool IsSoftwareRendering() const override { return false; }
88 36
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 void WaitSyncTokenCHROMIUM(const GLbyte* sync_token) override { 155 void WaitSyncTokenCHROMIUM(const GLbyte* sync_token) override {
208 memcpy(&most_recently_waited_sync_token_, sync_token, 156 memcpy(&most_recently_waited_sync_token_, sync_token,
209 sizeof(most_recently_waited_sync_token_)); 157 sizeof(most_recently_waited_sync_token_));
210 } 158 }
211 159
212 GLenum CheckFramebufferStatus(GLenum target) override { 160 GLenum CheckFramebufferStatus(GLenum target) override {
213 return GL_FRAMEBUFFER_COMPLETE; 161 return GL_FRAMEBUFFER_COMPLETE;
214 } 162 }
215 163
216 void GetIntegerv(GLenum pname, GLint* value) override { 164 void GetIntegerv(GLenum pname, GLint* value) override {
217 if (pname == GL_MAX_TEXTURE_SIZE) 165 switch (pname) {
218 *value = 1024; 166 case GL_DRAW_FRAMEBUFFER_BINDING:
167 *value = state_.draw_framebuffer_binding;
168 break;
169 case GL_READ_FRAMEBUFFER_BINDING:
170 *value = state_.read_framebuffer_binding;
171 break;
172 case GL_MAX_TEXTURE_SIZE:
173 *value = 1024;
174 default:
175 break;
176 }
219 } 177 }
220 178
221 void GenMailboxCHROMIUM(GLbyte* mailbox) override { 179 void GenMailboxCHROMIUM(GLbyte* mailbox) override {
222 ++current_mailbox_byte_; 180 ++current_mailbox_byte_;
223 memset(mailbox, current_mailbox_byte_, GL_MAILBOX_SIZE_CHROMIUM); 181 memset(mailbox, current_mailbox_byte_, GL_MAILBOX_SIZE_CHROMIUM);
224 } 182 }
225 183
226 void ProduceTextureDirectCHROMIUM(GLuint texture, 184 void ProduceTextureDirectCHROMIUM(GLuint texture,
227 GLenum target, 185 GLenum target,
228 const GLbyte* mailbox) override { 186 const GLbyte* mailbox) override {
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 gpu::SyncToken most_recently_waited_sync_token_; 359 gpu::SyncToken most_recently_waited_sync_token_;
402 GLbyte current_mailbox_byte_ = 0; 360 GLbyte current_mailbox_byte_ = 0;
403 IntSize most_recently_produced_size_; 361 IntSize most_recently_produced_size_;
404 bool create_image_chromium_fail_ = false; 362 bool create_image_chromium_fail_ = false;
405 GLuint current_image_id_ = 1; 363 GLuint current_image_id_ = 1;
406 HashMap<GLuint, IntSize> texture_sizes_; 364 HashMap<GLuint, IntSize> texture_sizes_;
407 HashMap<GLuint, IntSize> image_sizes_; 365 HashMap<GLuint, IntSize> image_sizes_;
408 HashMap<GLuint, GLuint> image_to_texture_map_; 366 HashMap<GLuint, GLuint> image_to_texture_map_;
409 }; 367 };
410 368
369 class DrawingBufferForTests : public DrawingBuffer {
370 public:
371 static PassRefPtr<DrawingBufferForTests> Create(
372 std::unique_ptr<WebGraphicsContext3DProvider> context_provider,
373 DrawingBuffer::Client* client,
374 const IntSize& size,
375 PreserveDrawingBuffer preserve,
376 UseMultisampling use_multisampling) {
377 std::unique_ptr<Extensions3DUtil> extensions_util =
378 Extensions3DUtil::Create(context_provider->ContextGL());
379 RefPtr<DrawingBufferForTests> drawing_buffer =
380 AdoptRef(new DrawingBufferForTests(std::move(context_provider),
381 std::move(extensions_util), client,
382 preserve));
383 if (!drawing_buffer->Initialize(
384 size, use_multisampling != kDisableMultisampling)) {
385 drawing_buffer->BeginDestruction();
386 return nullptr;
387 }
388 return drawing_buffer.Release();
389 }
390
391 DrawingBufferForTests(
392 std::unique_ptr<WebGraphicsContext3DProvider> context_provider,
393 std::unique_ptr<Extensions3DUtil> extensions_util,
394 DrawingBuffer::Client* client,
395 PreserveDrawingBuffer preserve)
396 : DrawingBuffer(
397 std::move(context_provider),
398 std::move(extensions_util),
399 client,
400 false /* discardFramebufferSupported */,
401 true /* wantAlphaChannel */,
402 false /* premultipliedAlpha */,
403 preserve,
404 kWebGL1,
405 false /* wantDepth */,
406 false /* wantStencil */,
407 DrawingBuffer::kAllowChromiumImage /* ChromiumImageUsage */,
408 CanvasColorParams()),
409 live_(0) {}
410
411 ~DrawingBufferForTests() override {
412 if (live_)
413 *live_ = false;
414 }
415
416 GLES2InterfaceForTests* ContextGLForTests() {
417 return static_cast<GLES2InterfaceForTests*>(ContextGL());
xinghua.cao 2017/06/02 16:06:29 It seems that GLES2InterfaceForTests should be dec
Ken Russell (switch to Gerrit) 2017/06/02 21:52:50 Sounds good. This avoids any forward declarations.
418 }
419
420 bool* live_;
421
422 int RecycledBitmapCount() { return recycled_bitmaps_.size(); }
423 };
424
411 } // blink 425 } // blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698