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

Unified Diff: third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridgeTest.cpp

Issue 2537003002: Fix Canvas2DLayerBridge IOSurface leak. (Closed)
Patch Set: Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridgeTest.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridgeTest.cpp b/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridgeTest.cpp
index b131652e28f0ffb893740826cf0ed604e3cff056..c36d894c7a50894cbadc70c3d9965c215f3e624b 100644
--- a/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridgeTest.cpp
+++ b/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridgeTest.cpp
@@ -27,6 +27,7 @@
#include "cc/resources/single_release_callback.h"
#include "cc/resources/texture_mailbox.h"
+#include "cc/test/test_gpu_memory_buffer_manager.h"
#include "gpu/command_buffer/client/gles2_interface.h"
#include "gpu/command_buffer/common/capabilities.h"
#include "platform/CrossThreadFunctional.h"
@@ -44,6 +45,7 @@
#include "skia/ext/texture_handle.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/WebKit/Source/platform/testing/TestingPlatformSupport.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkSurface.h"
#include "third_party/skia/include/gpu/gl/GrGLTypes.h"
@@ -90,6 +92,30 @@ class Canvas2DLayerBridgePtr {
RefPtr<Canvas2DLayerBridge> m_layerBridge;
};
+class FakeGLES2InterfaceWithImageSupport : public FakeGLES2Interface {
+ public:
+ GLuint CreateImageCHROMIUM(ClientBuffer, GLsizei, GLsizei, GLenum) override {
+ return ++m_createImageCount;
+ }
+ void DestroyImageCHROMIUM(GLuint) override { ++m_destroyImageCount; }
+
+ GLuint createImageCount() { return m_createImageCount; }
+ GLuint destroyImageCount() { return m_destroyImageCount; }
+
+ private:
+ GLuint m_createImageCount = 0;
+ GLuint m_destroyImageCount = 0;
+};
+
+class FakePlatformSupport : public TestingPlatformSupport {
+ gpu::GpuMemoryBufferManager* getGpuMemoryBufferManager() override {
+ return &m_testGpuMemoryBufferManager;
+ }
+
+ private:
+ cc::TestGpuMemoryBufferManager m_testGpuMemoryBufferManager;
+};
+
} // anonymous namespace
class Canvas2DLayerBridgeTest : public Test {
@@ -1221,4 +1247,33 @@ TEST_F(Canvas2DLayerBridgeTest, DISABLED_PrepareMailboxWhileBackgroundRendering)
postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge);
}
+#if USE_IOSURFACE_FOR_2D_CANVAS
+TEST_F(Canvas2DLayerBridgeTest, DeleteIOSurfaceAfterTeardown)
+#else
+TEST_F(Canvas2DLayerBridgeTest, DISABLED_DeleteIOSurfaceAfterTeardown)
+#endif
+{
+ FakeGLES2InterfaceWithImageSupport gl;
+ FakePlatformSupport testingPlatformSupport;
+ std::unique_ptr<FakeWebGraphicsContext3DProvider> contextProvider =
+ wrapUnique(new FakeWebGraphicsContext3DProvider(&gl));
+
+ cc::TextureMailbox textureMailbox;
+ std::unique_ptr<cc::SingleReleaseCallback> releaseCallback;
+
+ {
+ Canvas2DLayerBridgePtr bridge(adoptRef(new Canvas2DLayerBridge(
+ std::move(contextProvider), IntSize(300, 150), 0, NonOpaque,
+ Canvas2DLayerBridge::ForceAccelerationForTesting, nullptr,
+ kN32_SkColorType)));
+ bridge->PrepareTextureMailbox(&textureMailbox, &releaseCallback);
+ }
+
+ bool lostResource = false;
+ releaseCallback->Run(gpu::SyncToken(), lostResource);
+
+ EXPECT_EQ(1u, gl.createImageCount());
+ EXPECT_EQ(1u, gl.destroyImageCount());
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698