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

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

Issue 2643343002: DrawingBuffer: Use gfx::GpuMemoryBuffer directly and set color space (Closed)
Patch Set: Fix buffer format Created 3 years, 11 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 14 matching lines...) Expand all
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "platform/graphics/gpu/DrawingBuffer.h" 31 #include "platform/graphics/gpu/DrawingBuffer.h"
32 32
33 #include "cc/resources/single_release_callback.h" 33 #include "cc/resources/single_release_callback.h"
34 #include "cc/resources/texture_mailbox.h" 34 #include "cc/resources/texture_mailbox.h"
35 #include "cc/test/test_gpu_memory_buffer_manager.h"
35 #include "gpu/command_buffer/client/gles2_interface_stub.h" 36 #include "gpu/command_buffer/client/gles2_interface_stub.h"
36 #include "gpu/command_buffer/common/mailbox.h" 37 #include "gpu/command_buffer/common/mailbox.h"
37 #include "gpu/command_buffer/common/sync_token.h" 38 #include "gpu/command_buffer/common/sync_token.h"
38 #include "platform/graphics/ImageBuffer.h" 39 #include "platform/graphics/ImageBuffer.h"
39 #include "platform/graphics/UnacceleratedImageBufferSurface.h" 40 #include "platform/graphics/UnacceleratedImageBufferSurface.h"
40 #include "platform/graphics/gpu/DrawingBufferTestHelpers.h" 41 #include "platform/graphics/gpu/DrawingBufferTestHelpers.h"
41 #include "public/platform/Platform.h" 42 #include "public/platform/Platform.h"
42 #include "testing/gtest/include/gtest/gtest.h" 43 #include "testing/gtest/include/gtest/gtest.h"
44 #include "third_party/WebKit/Source/platform/testing/TestingPlatformSupport.h"
43 #include "wtf/PtrUtil.h" 45 #include "wtf/PtrUtil.h"
44 #include "wtf/RefPtr.h" 46 #include "wtf/RefPtr.h"
45 #include <memory> 47 #include <memory>
46 48
47 using testing::Test; 49 using testing::Test;
48 using testing::_; 50 using testing::_;
49 51
50 namespace blink { 52 namespace blink {
51 53
54 namespace {
55
56 class FakePlatformSupport : public TestingPlatformSupport {
57 gpu::GpuMemoryBufferManager* getGpuMemoryBufferManager() override {
58 return &m_testGpuMemoryBufferManager;
59 }
60
61 private:
62 cc::TestGpuMemoryBufferManager m_testGpuMemoryBufferManager;
63 };
64
65 } // anonymous namespace
66
52 class DrawingBufferTest : public Test { 67 class DrawingBufferTest : public Test {
53 protected: 68 protected:
54 void SetUp() override { 69 void SetUp() override {
55 IntSize initialSize(InitialWidth, InitialHeight); 70 IntSize initialSize(InitialWidth, InitialHeight);
56 std::unique_ptr<GLES2InterfaceForTests> gl = 71 std::unique_ptr<GLES2InterfaceForTests> gl =
57 WTF::wrapUnique(new GLES2InterfaceForTests); 72 WTF::wrapUnique(new GLES2InterfaceForTests);
58 m_gl = gl.get(); 73 m_gl = gl.get();
59 SetAndSaveRestoreState(false); 74 SetAndSaveRestoreState(false);
60 std::unique_ptr<WebGraphicsContext3DProviderForTests> provider = 75 std::unique_ptr<WebGraphicsContext3DProviderForTests> provider =
61 WTF::wrapUnique( 76 WTF::wrapUnique(
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 waitSyncToken.GetData()); 354 waitSyncToken.GetData());
340 releaseCallback->Run(waitSyncToken, false /* lostResource */); 355 releaseCallback->Run(waitSyncToken, false /* lostResource */);
341 // m_drawingBuffer waits for the sync point because the destruction is in 356 // m_drawingBuffer waits for the sync point because the destruction is in
342 // progress. 357 // progress.
343 EXPECT_EQ(waitSyncToken, m_gl->mostRecentlyWaitedSyncToken()); 358 EXPECT_EQ(waitSyncToken, m_gl->mostRecentlyWaitedSyncToken());
344 } 359 }
345 360
346 class DrawingBufferImageChromiumTest : public DrawingBufferTest { 361 class DrawingBufferImageChromiumTest : public DrawingBufferTest {
347 protected: 362 protected:
348 void SetUp() override { 363 void SetUp() override {
364 m_platform.reset(new ScopedTestingPlatformSupport<FakePlatformSupport>);
365
349 IntSize initialSize(InitialWidth, InitialHeight); 366 IntSize initialSize(InitialWidth, InitialHeight);
350 std::unique_ptr<GLES2InterfaceForTests> gl = 367 std::unique_ptr<GLES2InterfaceForTests> gl =
351 WTF::wrapUnique(new GLES2InterfaceForTests); 368 WTF::wrapUnique(new GLES2InterfaceForTests);
352 m_gl = gl.get(); 369 m_gl = gl.get();
353 SetAndSaveRestoreState(true); 370 SetAndSaveRestoreState(true);
354 std::unique_ptr<WebGraphicsContext3DProviderForTests> provider = 371 std::unique_ptr<WebGraphicsContext3DProviderForTests> provider =
355 WTF::wrapUnique( 372 WTF::wrapUnique(
356 new WebGraphicsContext3DProviderForTests(std::move(gl))); 373 new WebGraphicsContext3DProviderForTests(std::move(gl)));
357 RuntimeEnabledFeatures::setWebGLImageChromiumEnabled(true); 374 RuntimeEnabledFeatures::setWebGLImageChromiumEnabled(true);
358 m_imageId0 = m_gl->nextImageIdToBeCreated(); 375 m_imageId0 = m_gl->nextImageIdToBeCreated();
359 EXPECT_CALL(*m_gl, BindTexImage2DMock(m_imageId0)).Times(1); 376 EXPECT_CALL(*m_gl, BindTexImage2DMock(m_imageId0)).Times(1);
360 m_drawingBuffer = DrawingBufferForTests::create( 377 m_drawingBuffer = DrawingBufferForTests::create(
361 std::move(provider), m_gl, initialSize, DrawingBuffer::Preserve); 378 std::move(provider), m_gl, initialSize, DrawingBuffer::Preserve);
362 CHECK(m_drawingBuffer); 379 CHECK(m_drawingBuffer);
363 testing::Mock::VerifyAndClearExpectations(m_gl); 380 testing::Mock::VerifyAndClearExpectations(m_gl);
364 } 381 }
365 382
366 void TearDown() override { 383 void TearDown() override {
367 RuntimeEnabledFeatures::setWebGLImageChromiumEnabled(false); 384 RuntimeEnabledFeatures::setWebGLImageChromiumEnabled(false);
385 m_platform.reset();
368 } 386 }
369 387
370 GLuint m_imageId0; 388 GLuint m_imageId0;
389 std::unique_ptr<ScopedTestingPlatformSupport<FakePlatformSupport>> m_platform;
371 }; 390 };
372 391
373 TEST_F(DrawingBufferImageChromiumTest, verifyResizingReallocatesImages) { 392 TEST_F(DrawingBufferImageChromiumTest, verifyResizingReallocatesImages) {
374 cc::TextureMailbox textureMailbox; 393 cc::TextureMailbox textureMailbox;
375 std::unique_ptr<cc::SingleReleaseCallback> releaseCallback; 394 std::unique_ptr<cc::SingleReleaseCallback> releaseCallback;
376 395
377 IntSize initialSize(InitialWidth, InitialHeight); 396 IntSize initialSize(InitialWidth, InitialHeight);
378 IntSize alternateSize(InitialWidth, AlternateHeight); 397 IntSize alternateSize(InitialWidth, AlternateHeight);
379 398
380 GLuint m_imageId1 = m_gl->nextImageIdToBeCreated(); 399 GLuint m_imageId1 = m_gl->nextImageIdToBeCreated();
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 m_drawingBuffer->setIsHidden(true); 682 m_drawingBuffer->setIsHidden(true);
664 releaseCallback->Run(waitSyncToken, false /* lostResource */); 683 releaseCallback->Run(waitSyncToken, false /* lostResource */);
665 // m_drawingBuffer deletes mailbox immediately when hidden. 684 // m_drawingBuffer deletes mailbox immediately when hidden.
666 685
667 EXPECT_EQ(waitSyncToken, m_gl->mostRecentlyWaitedSyncToken()); 686 EXPECT_EQ(waitSyncToken, m_gl->mostRecentlyWaitedSyncToken());
668 687
669 m_drawingBuffer->beginDestruction(); 688 m_drawingBuffer->beginDestruction();
670 } 689 }
671 690
672 } // namespace blink 691 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698