Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "platform/graphics/gpu/DrawingBuffer.h" | 5 #include "platform/graphics/gpu/DrawingBuffer.h" |
| 6 | 6 |
| 7 #include "cc/resources/single_release_callback.h" | 7 #include "cc/resources/single_release_callback.h" |
| 8 #include "cc/resources/texture_mailbox.h" | 8 #include "cc/resources/texture_mailbox.h" |
| 9 #include "gpu/command_buffer/client/gles2_interface_stub.h" | 9 #include "gpu/command_buffer/client/gles2_interface_stub.h" |
| 10 #include "platform/graphics/gpu/DrawingBufferTestHelpers.h" | 10 #include "platform/graphics/gpu/DrawingBufferTestHelpers.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 private: | 42 private: |
| 43 std::unique_ptr<gpu::gles2::GLES2Interface> gl_; | 43 std::unique_ptr<gpu::gles2::GLES2Interface> gl_; |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 class DrawingBufferSoftwareRenderingTest : public Test { | 46 class DrawingBufferSoftwareRenderingTest : public Test { |
| 47 protected: | 47 protected: |
| 48 void SetUp() override { | 48 void SetUp() override { |
| 49 IntSize initial_size(kInitialWidth, kInitialHeight); | 49 IntSize initial_size(kInitialWidth, kInitialHeight); |
| 50 std::unique_ptr<GLES2InterfaceForTests> gl = | 50 std::unique_ptr<GLES2InterfaceForTests> gl = |
| 51 WTF::WrapUnique(new GLES2InterfaceForTests); | 51 WTF::WrapUnique(new GLES2InterfaceForTests); |
| 52 gl_ = gl.get(); | |
|
Zhenyao Mo
2017/05/26 22:38:34
I don't think you should cache it here. Instead, j
xinghua.cao
2017/06/01 02:26:51
Line 58, After "std::move(provider)", it seems tha
| |
| 52 std::unique_ptr<WebGraphicsContext3DProviderSoftwareRenderingForTests> | 53 std::unique_ptr<WebGraphicsContext3DProviderSoftwareRenderingForTests> |
| 53 provider = WTF::WrapUnique( | 54 provider = WTF::WrapUnique( |
| 54 new WebGraphicsContext3DProviderSoftwareRenderingForTests( | 55 new WebGraphicsContext3DProviderSoftwareRenderingForTests( |
| 55 std::move(gl))); | 56 std::move(gl))); |
| 56 drawing_buffer_ = DrawingBufferForTests::Create( | 57 drawing_buffer_ = DrawingBufferForTests::Create( |
| 57 std::move(provider), nullptr, initial_size, DrawingBuffer::kPreserve, | 58 std::move(provider), gl_, initial_size, DrawingBuffer::kPreserve, |
| 58 kDisableMultisampling); | 59 kDisableMultisampling); |
| 59 CHECK(drawing_buffer_); | 60 CHECK(drawing_buffer_); |
| 60 } | 61 } |
| 61 | 62 |
| 62 RefPtr<DrawingBufferForTests> drawing_buffer_; | 63 RefPtr<DrawingBufferForTests> drawing_buffer_; |
| 64 GLES2InterfaceForTests* gl_; | |
| 63 bool is_software_rendering_ = false; | 65 bool is_software_rendering_ = false; |
| 64 }; | 66 }; |
| 65 | 67 |
| 66 TEST_F(DrawingBufferSoftwareRenderingTest, bitmapRecycling) { | 68 TEST_F(DrawingBufferSoftwareRenderingTest, bitmapRecycling) { |
|
Zhenyao Mo
2017/05/26 22:38:34
Can you fix this name? should be BitmapRecycling.
xinghua.cao
2017/06/01 02:26:51
In webkit_unit_tests, the first letter of some cas
| |
| 67 cc::TextureMailbox texture_mailbox; | 69 cc::TextureMailbox texture_mailbox; |
| 68 std::unique_ptr<cc::SingleReleaseCallback> release_callback1; | 70 std::unique_ptr<cc::SingleReleaseCallback> release_callback1; |
| 69 std::unique_ptr<cc::SingleReleaseCallback> release_callback2; | 71 std::unique_ptr<cc::SingleReleaseCallback> release_callback2; |
| 70 std::unique_ptr<cc::SingleReleaseCallback> release_callback3; | 72 std::unique_ptr<cc::SingleReleaseCallback> release_callback3; |
| 71 IntSize initial_size(kInitialWidth, kInitialHeight); | 73 IntSize initial_size(kInitialWidth, kInitialHeight); |
| 72 IntSize alternate_size(kInitialWidth, kAlternateHeight); | 74 IntSize alternate_size(kInitialWidth, kAlternateHeight); |
| 73 | 75 |
| 74 drawing_buffer_->Resize(initial_size); | 76 drawing_buffer_->Resize(initial_size); |
| 75 drawing_buffer_->MarkContentsChanged(); | 77 drawing_buffer_->MarkContentsChanged(); |
| 76 drawing_buffer_->PrepareTextureMailbox( | 78 drawing_buffer_->PrepareTextureMailbox( |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 94 drawing_buffer_->PrepareTextureMailbox( | 96 drawing_buffer_->PrepareTextureMailbox( |
| 95 &texture_mailbox, | 97 &texture_mailbox, |
| 96 &release_callback3); // cause recycling queue to be purged due to resize | 98 &release_callback3); // cause recycling queue to be purged due to resize |
| 97 EXPECT_EQ(0, drawing_buffer_->RecycledBitmapCount()); | 99 EXPECT_EQ(0, drawing_buffer_->RecycledBitmapCount()); |
| 98 release_callback3->Run(gpu::SyncToken(), false /* lostResource */); | 100 release_callback3->Run(gpu::SyncToken(), false /* lostResource */); |
| 99 EXPECT_EQ(1, drawing_buffer_->RecycledBitmapCount()); | 101 EXPECT_EQ(1, drawing_buffer_->RecycledBitmapCount()); |
| 100 | 102 |
| 101 drawing_buffer_->BeginDestruction(); | 103 drawing_buffer_->BeginDestruction(); |
| 102 } | 104 } |
| 103 | 105 |
| 106 TEST_F(DrawingBufferSoftwareRenderingTest, framebufferBinding) { | |
|
Zhenyao Mo
2017/05/26 22:38:34
I think you can just merge this test with the abov
xinghua.cao
2017/06/01 02:26:51
Hi, Zhenyao, I think there are little relationship
| |
| 107 cc::TextureMailbox texture_mailbox; | |
| 108 std::unique_ptr<cc::SingleReleaseCallback> release_callback; | |
| 109 IntSize initial_size(kInitialWidth, kInitialHeight); | |
| 110 GLint drawBinding = 0, readBinding = 0; | |
| 111 | |
| 112 GLuint draw_framebuffer_binding = 0xbeef3; | |
| 113 GLuint read_framebuffer_binding = 0xbeef4; | |
| 114 gl_->BindFramebuffer(GL_DRAW_FRAMEBUFFER, draw_framebuffer_binding); | |
| 115 gl_->BindFramebuffer(GL_READ_FRAMEBUFFER, read_framebuffer_binding); | |
| 116 gl_->SaveState(); | |
| 117 drawing_buffer_->Resize(initial_size); | |
| 118 drawing_buffer_->MarkContentsChanged(); | |
| 119 drawing_buffer_->PrepareTextureMailbox(&texture_mailbox, &release_callback); | |
| 120 gl_->GetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &drawBinding); | |
| 121 gl_->GetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &readBinding); | |
| 122 EXPECT_EQ(static_cast<GLint>(draw_framebuffer_binding), drawBinding); | |
| 123 EXPECT_EQ(static_cast<GLint>(read_framebuffer_binding), readBinding); | |
| 124 release_callback->Run(gpu::SyncToken(), false /* lostResource */); | |
| 125 | |
| 126 drawing_buffer_->BeginDestruction(); | |
| 127 } | |
| 128 | |
| 104 } // unnamed namespace | 129 } // unnamed namespace |
| 105 } // blink | 130 } // blink |
| OLD | NEW |