summaryrefslogtreecommitdiffstats
path: root/WebCore
diff options
context:
space:
mode:
authorDerek Sollenberger <djsollen@google.com>2010-12-09 11:32:41 -0500
committerDerek Sollenberger <djsollen@google.com>2010-12-09 13:20:34 -0500
commit56338e6791747d7c23fe7fd4e216d7755a18fa43 (patch)
treebfb1653800735ee4e95d541668b7a98aeee3a1bb /WebCore
parent8a8bcba6421d62a32ffbc3a2461cb978d522dbdc (diff)
downloadexternal_webkit-56338e6791747d7c23fe7fd4e216d7755a18fa43.zip
external_webkit-56338e6791747d7c23fe7fd4e216d7755a18fa43.tar.gz
external_webkit-56338e6791747d7c23fe7fd4e216d7755a18fa43.tar.bz2
Refactor recent changes to SharedTexture and TilesManager.
These changes are directly related to the comments found in this CL --> https://android-git.corp.google.com/g/#change,83984 Change-Id: Ida0acb772f9bcaa4f4f5b394676d45b27f4149d2
Diffstat (limited to 'WebCore')
-rw-r--r--WebCore/platform/graphics/android/BackedDoubleBufferedTexture.cpp20
-rw-r--r--WebCore/platform/graphics/android/BackedDoubleBufferedTexture.h3
-rw-r--r--WebCore/platform/graphics/android/DoubleBufferedTexture.cpp2
-rw-r--r--WebCore/platform/graphics/android/DoubleBufferedTexture.h6
-rw-r--r--WebCore/platform/graphics/android/SharedTexture.cpp12
-rw-r--r--WebCore/platform/graphics/android/SharedTexture.h1
-rw-r--r--WebCore/platform/graphics/android/TexturesGenerator.cpp7
-rw-r--r--WebCore/platform/graphics/android/TexturesGenerator.h1
-rw-r--r--WebCore/platform/graphics/android/TiledPage.cpp8
-rw-r--r--WebCore/platform/graphics/android/TilesManager.h5
10 files changed, 39 insertions, 26 deletions
diff --git a/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.cpp b/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.cpp
index 02168a9..ced0c2e 100644
--- a/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.cpp
+++ b/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.cpp
@@ -25,8 +25,9 @@
#include "config.h"
#include "BackedDoubleBufferedTexture.h"
-
#include "BaseTile.h"
+#include "DeleteTextureOperation.h"
+#include "TilesManager.h"
#include "GLUtils.h"
#define LOG_NDEBUG 1
@@ -54,6 +55,23 @@ BackedDoubleBufferedTexture::~BackedDoubleBufferedTexture()
delete m_canvas;
}
+void BackedDoubleBufferedTexture::onDestroy(SharedTexture** textures)
+{
+ int x = 0;
+ while (textures[x] != 0) {
+ // We need to delete the source texture and EGLImage in the texture
+ // generation thread. In theory we should be able to delete the EGLImage
+ // from either thread, but it currently throws an error if not deleted
+ // in the same EGLContext from which it was created.
+ textures[x]->lock();
+ DeleteTextureOperation* operation = new DeleteTextureOperation(
+ textures[x]->getSourceTextureId(), textures[x]->getEGLImage());
+ textures[x]->unlock();
+ TilesManager::instance()->scheduleOperation(operation);
+ x++;
+ }
+}
+
TextureInfo* BackedDoubleBufferedTexture::producerLock()
{
m_busyLock.lock();
diff --git a/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.h b/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.h
index b07cdd1..76b9f36 100644
--- a/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.h
+++ b/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.h
@@ -75,6 +75,9 @@ public:
// This is to be only used for debugging on the producer thread
bool busy() { return m_busy; }
+protected:
+ virtual void onDestroy(SharedTexture** textures);
+
private:
SkBitmap m_bitmap;
SkCanvas* m_canvas;
diff --git a/WebCore/platform/graphics/android/DoubleBufferedTexture.cpp b/WebCore/platform/graphics/android/DoubleBufferedTexture.cpp
index 31a1186..a3ae5ab 100644
--- a/WebCore/platform/graphics/android/DoubleBufferedTexture.cpp
+++ b/WebCore/platform/graphics/android/DoubleBufferedTexture.cpp
@@ -58,6 +58,8 @@ DoubleBufferedTexture::DoubleBufferedTexture(EGLContext sharedContext)
DoubleBufferedTexture::~DoubleBufferedTexture()
{
+ SharedTexture* textures[3] = { &m_textureA, &m_textureB, 0 };
+ onDestroy(textures);
#ifdef DEBUG_COUNT
gDoubleBufferedTextureCount--;
#endif
diff --git a/WebCore/platform/graphics/android/DoubleBufferedTexture.h b/WebCore/platform/graphics/android/DoubleBufferedTexture.h
index 2b2fd03..c028302 100644
--- a/WebCore/platform/graphics/android/DoubleBufferedTexture.h
+++ b/WebCore/platform/graphics/android/DoubleBufferedTexture.h
@@ -50,6 +50,12 @@ public:
TextureInfo* consumerLock();
void consumerRelease();
+protected:
+ // enables sub-classes to signal the provider thread that the consumer is
+ // being deleted and therefore should clean up any producer specific
+ // textures or EGLImages
+ virtual void onDestroy(SharedTexture** textures) { };
+
private:
SharedTexture* getReadableTexture();
SharedTexture* getWriteableTexture();
diff --git a/WebCore/platform/graphics/android/SharedTexture.cpp b/WebCore/platform/graphics/android/SharedTexture.cpp
index 56f9279..16ec97f 100644
--- a/WebCore/platform/graphics/android/SharedTexture.cpp
+++ b/WebCore/platform/graphics/android/SharedTexture.cpp
@@ -24,9 +24,7 @@
*/
#include "config.h"
-#include "DeleteTextureOperation.h"
#include "SharedTexture.h"
-#include "TilesManager.h"
#include "GLUtils.h"
#define LOG_NDEBUG 1
@@ -73,16 +71,12 @@ SharedTexture::SharedTexture() {
}
// called by the consumer when it no longer wants to consume and after it has
-// terminated all providers. If EGLImages are used, we schedule a delete
-// operation (see DeleteTextureOperation.h) to the textures generation thread.
+// terminated all providers. If EGLImages are used, the deletion of the
+// source texture and EGLImage is the responsibility of the caller. In the case
+// of double buffered textures this is handled in the onDestroy(...) method.
SharedTexture::~SharedTexture() {
if (m_supportsEGLImage) {
GLUtils::deleteTexture(&m_targetTexture.m_textureId);
- // We need to delete the EGLImage and the source texture
- // in the textures generation thread.
- DeleteTextureOperation* operation = new DeleteTextureOperation(
- m_sourceTexture.m_textureId, m_eglImage);
- TilesManager::instance()->scheduleOperation(operation);
} else {
GLUtils::deleteTexture(&m_sourceTexture.m_textureId);
}
diff --git a/WebCore/platform/graphics/android/SharedTexture.h b/WebCore/platform/graphics/android/SharedTexture.h
index dc5dfd3..581ad77 100644
--- a/WebCore/platform/graphics/android/SharedTexture.h
+++ b/WebCore/platform/graphics/android/SharedTexture.h
@@ -82,6 +82,7 @@ public:
void initSourceTexture(); // producer thread only
GLuint getSourceTextureId() { return m_sourceTexture.m_textureId; }
GLuint getTargetTextureId() { return m_targetTexture.m_textureId; }
+ EGLImageKHR getEGLImage() { return m_eglImage; }
private:
/**
diff --git a/WebCore/platform/graphics/android/TexturesGenerator.cpp b/WebCore/platform/graphics/android/TexturesGenerator.cpp
index 836dd64..26090b0 100644
--- a/WebCore/platform/graphics/android/TexturesGenerator.cpp
+++ b/WebCore/platform/graphics/android/TexturesGenerator.cpp
@@ -29,7 +29,6 @@
#if USE(ACCELERATED_COMPOSITING)
#include "GLUtils.h"
-#include "PaintTileSetOperation.h"
#include "TilesManager.h"
#ifdef DEBUG
@@ -50,12 +49,6 @@
namespace WebCore {
-void TexturesGenerator::schedulePaintForTileSet(TileSet* set)
-{
- PaintTileSetOperation* operation = new PaintTileSetOperation(set);
- scheduleOperation(operation);
-}
-
void TexturesGenerator::scheduleOperation(QueuedOperation* operation)
{
android::Mutex::Autolock lock(mRequestedOperationsLock);
diff --git a/WebCore/platform/graphics/android/TexturesGenerator.h b/WebCore/platform/graphics/android/TexturesGenerator.h
index 573d94f..ae02d14 100644
--- a/WebCore/platform/graphics/android/TexturesGenerator.h
+++ b/WebCore/platform/graphics/android/TexturesGenerator.h
@@ -44,7 +44,6 @@ public:
virtual ~TexturesGenerator() { }
virtual status_t readyToRun();
- void schedulePaintForTileSet(TileSet* set);
void removeOperationsForPage(TiledPage* page);
void scheduleOperation(QueuedOperation* operation);
diff --git a/WebCore/platform/graphics/android/TiledPage.cpp b/WebCore/platform/graphics/android/TiledPage.cpp
index 815fda0..3a08f9b 100644
--- a/WebCore/platform/graphics/android/TiledPage.cpp
+++ b/WebCore/platform/graphics/android/TiledPage.cpp
@@ -30,6 +30,7 @@
#include "GLUtils.h"
#include "IntRect.h"
+#include "PaintTileSetOperation.h"
#include "TilesManager.h"
#ifdef DEBUG
@@ -270,9 +271,10 @@ void TiledPage::prepare(bool goingDown, bool goingLeft, const SkIRect& tileBound
prepareRow(goingLeft, nbTilesWidth, firstTileX, firstTileY + i, highResSet);
}
- // schedulePaintForTileSet will take ownership of the highResSet here,
- // so no delete necessary.
- TilesManager::instance()->schedulePaintForTileSet(highResSet);
+ // The paint operation will take ownership of the tileSet here, so no delete
+ // is necessary.
+ PaintTileSetOperation* operation = new PaintTileSetOperation(highResSet);
+ TilesManager::instance()->scheduleOperation(operation);
}
bool TiledPage::ready(const SkIRect& tileBounds)
diff --git a/WebCore/platform/graphics/android/TilesManager.h b/WebCore/platform/graphics/android/TilesManager.h
index 1a3eb05..f855738 100644
--- a/WebCore/platform/graphics/android/TilesManager.h
+++ b/WebCore/platform/graphics/android/TilesManager.h
@@ -43,11 +43,6 @@ class TilesManager {
public:
static TilesManager* instance();
- void schedulePaintForTileSet(TileSet* set)
- {
- m_pixmapsGenerationThread->schedulePaintForTileSet(set);
- }
-
void removeOperationsForPage(TiledPage* page)
{
m_pixmapsGenerationThread->removeOperationsForPage(page);