[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
jamesr at google.com
jamesr at google.com
Wed Dec 22 13:23:15 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit c1eaae0232deb0ff26508afec99ffcbb1b5a08b8
Author: jamesr at google.com <jamesr at google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Mon Sep 13 21:39:32 2010 +0000
2010-09-13 James Robinson <jamesr at chromium.org>
Reviewed by Kenneth Russell.
SharedGraphicsContext3D's texture cache holds on to images after free
https://bugs.webkit.org/show_bug.cgi?id=45706
Each SharedGraphicsContext3D keeps a cache of uploaded textures keyed by NativeImagePtrs.
Whenever the backing native image is deleted it needs to let the SharedGraphicsContext3D know
so that the cache entry and associated texture can also be removed.
* platform/graphics/gpu/SharedGraphicsContext3D.cpp:
(WebCore::SharedGraphicsContext3D::SharedGraphicsContext3D):
(WebCore::SharedGraphicsContext3D::~SharedGraphicsContext3D):
(WebCore::SharedGraphicsContext3D::removeTextureFor):
(WebCore::SharedGraphicsContext3D::removeTexturesFor):
(WebCore::SharedGraphicsContext3D::allContexts):
* platform/graphics/gpu/SharedGraphicsContext3D.h:
* platform/graphics/skia/NativeImageSkia.cpp:
(WebCore::NativeImageSkia::~NativeImageSkia):
* platform/graphics/skia/NativeImageSkia.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@67412 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index e8cbad0..0707329 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,25 @@
+2010-09-13 James Robinson <jamesr at chromium.org>
+
+ Reviewed by Kenneth Russell.
+
+ SharedGraphicsContext3D's texture cache holds on to images after free
+ https://bugs.webkit.org/show_bug.cgi?id=45706
+
+ Each SharedGraphicsContext3D keeps a cache of uploaded textures keyed by NativeImagePtrs.
+ Whenever the backing native image is deleted it needs to let the SharedGraphicsContext3D know
+ so that the cache entry and associated texture can also be removed.
+
+ * platform/graphics/gpu/SharedGraphicsContext3D.cpp:
+ (WebCore::SharedGraphicsContext3D::SharedGraphicsContext3D):
+ (WebCore::SharedGraphicsContext3D::~SharedGraphicsContext3D):
+ (WebCore::SharedGraphicsContext3D::removeTextureFor):
+ (WebCore::SharedGraphicsContext3D::removeTexturesFor):
+ (WebCore::SharedGraphicsContext3D::allContexts):
+ * platform/graphics/gpu/SharedGraphicsContext3D.h:
+ * platform/graphics/skia/NativeImageSkia.cpp:
+ (WebCore::NativeImageSkia::~NativeImageSkia):
+ * platform/graphics/skia/NativeImageSkia.h:
+
2010-09-13 Chris Fleizach <cfleizach at apple.com>
Reviewed by David Kilzer.
diff --git a/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.cpp b/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.cpp
index 6424293..f4ab79e 100644
--- a/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.cpp
+++ b/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.cpp
@@ -58,11 +58,13 @@ SharedGraphicsContext3D::SharedGraphicsContext3D(PassOwnPtr<GraphicsContext3D> c
, m_solidFillShader(SolidFillShader::create(m_context.get()))
, m_texShader(TexShader::create(m_context.get()))
{
+ allContexts()->add(this);
}
SharedGraphicsContext3D::~SharedGraphicsContext3D()
{
m_context->deleteBuffer(m_quadVertices);
+ allContexts()->remove(this);
}
void SharedGraphicsContext3D::makeContextCurrent()
@@ -180,6 +182,28 @@ Texture* SharedGraphicsContext3D::getTexture(NativeImagePtr ptr)
return texture ? texture.get() : 0;
}
+void SharedGraphicsContext3D::removeTextureFor(NativeImagePtr ptr)
+{
+ TextureHashMap::iterator it = m_textures.find(ptr);
+ if (it != m_textures.end())
+ m_textures.remove(it);
+}
+
+// static
+void SharedGraphicsContext3D::removeTexturesFor(NativeImagePtr ptr)
+{
+ for (HashSet<SharedGraphicsContext3D*>::iterator it = allContexts()->begin(); it != allContexts()->end(); ++it)
+ (*it)->removeTextureFor(ptr);
+}
+
+// static
+HashSet<SharedGraphicsContext3D*>* SharedGraphicsContext3D::allContexts()
+{
+ static OwnPtr<HashSet<SharedGraphicsContext3D*> > set(new HashSet<SharedGraphicsContext3D*>);
+ return set.get();
+}
+
+
PassRefPtr<Texture> SharedGraphicsContext3D::createTexture(Texture::Format format, int width, int height)
{
return Texture::create(m_context.get(), format, width, height);
diff --git a/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.h b/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.h
index 1baa0f6..fcacb9e 100644
--- a/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.h
+++ b/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.h
@@ -36,6 +36,7 @@
#include "Texture.h"
#include <wtf/HashMap.h>
+#include <wtf/HashSet.h>
#include <wtf/OwnPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
@@ -102,12 +103,21 @@ public:
Texture* createTexture(NativeImagePtr, Texture::Format, int width, int height);
Texture* getTexture(NativeImagePtr);
+ // Multiple SharedGraphicsContext3D can exist in a single process (one per compositing context) and the same
+ // NativeImagePtr may be uploaded as a texture into all of them. This function removes uploaded textures
+ // for a given NativeImagePtr in all contexts.
+ static void removeTexturesFor(NativeImagePtr);
+
// Creates a texture that is not associated with any image. The caller takes ownership of
// the texture.
PassRefPtr<Texture> createTexture(Texture::Format, int width, int height);
private:
- SharedGraphicsContext3D(PassOwnPtr<GraphicsContext3D> context);
+ explicit SharedGraphicsContext3D(PassOwnPtr<GraphicsContext3D> context);
+
+ // Used to implement removeTexturesFor(), see the comment above.
+ static HashSet<SharedGraphicsContext3D*>* allContexts();
+ void removeTextureFor(NativeImagePtr);
OwnPtr<GraphicsContext3D> m_context;
diff --git a/WebCore/platform/graphics/skia/NativeImageSkia.cpp b/WebCore/platform/graphics/skia/NativeImageSkia.cpp
index 9effa5c..810cb38 100644
--- a/WebCore/platform/graphics/skia/NativeImageSkia.cpp
+++ b/WebCore/platform/graphics/skia/NativeImageSkia.cpp
@@ -33,6 +33,7 @@
#include "skia/ext/image_operations.h"
#include "NativeImageSkia.h"
+#include "SharedGraphicsContext3D.h"
#include "SkiaUtils.h"
namespace WebCore {
@@ -52,6 +53,12 @@ NativeImageSkia::NativeImageSkia(const SkBitmap& other)
{
}
+
+NativeImageSkia::~NativeImageSkia()
+{
+ SharedGraphicsContext3D::removeTexturesFor(this);
+}
+
int NativeImageSkia::decodedSize() const
{
return getSize() + m_resizedImage.getSize();
diff --git a/WebCore/platform/graphics/skia/NativeImageSkia.h b/WebCore/platform/graphics/skia/NativeImageSkia.h
index e26a5ea..00b0a68 100644
--- a/WebCore/platform/graphics/skia/NativeImageSkia.h
+++ b/WebCore/platform/graphics/skia/NativeImageSkia.h
@@ -42,6 +42,7 @@ namespace WebCore {
class NativeImageSkia : public SkBitmap {
public:
NativeImageSkia();
+ ~NativeImageSkia();
// This constructor does a shallow copy of the passed-in SkBitmap (ie., it
// references the same pixel data and bumps the refcount). Use only when
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list