summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/WebCore/Android.mk2
-rw-r--r--Source/WebCore/platform/graphics/android/BaseTile.cpp84
-rw-r--r--Source/WebCore/platform/graphics/android/BaseTile.h6
-rw-r--r--Source/WebCore/platform/graphics/android/BaseTileTexture.cpp124
-rw-r--r--Source/WebCore/platform/graphics/android/BaseTileTexture.h38
-rw-r--r--Source/WebCore/platform/graphics/android/DoubleBufferedTexture.cpp217
-rw-r--r--Source/WebCore/platform/graphics/android/DoubleBufferedTexture.h74
-rw-r--r--Source/WebCore/platform/graphics/android/GLUtils.cpp91
-rw-r--r--Source/WebCore/platform/graphics/android/GLUtils.h4
-rw-r--r--Source/WebCore/platform/graphics/android/GaneshContext.cpp6
-rw-r--r--Source/WebCore/platform/graphics/android/GaneshRenderer.cpp40
-rw-r--r--Source/WebCore/platform/graphics/android/SharedTexture.cpp248
-rw-r--r--Source/WebCore/platform/graphics/android/SharedTexture.h118
-rw-r--r--Source/WebCore/platform/graphics/android/TextureInfo.cpp3
-rw-r--r--Source/WebCore/platform/graphics/android/TextureInfo.h16
-rw-r--r--Source/WebCore/platform/graphics/android/TilesManager.cpp10
-rw-r--r--Source/WebCore/platform/graphics/android/TilesManager.h5
-rw-r--r--Source/WebCore/platform/graphics/android/TransferQueue.h1
18 files changed, 57 insertions, 1030 deletions
diff --git a/Source/WebCore/Android.mk b/Source/WebCore/Android.mk
index d731082..bdf6410 100644
--- a/Source/WebCore/Android.mk
+++ b/Source/WebCore/Android.mk
@@ -639,7 +639,6 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
platform/graphics/android/BaseTileTexture.cpp \
platform/graphics/android/BitmapAllocatorAndroid.cpp \
platform/graphics/android/ClassTracker.cpp \
- platform/graphics/android/DoubleBufferedTexture.cpp \
platform/graphics/android/FontAndroid.cpp \
platform/graphics/android/FontCacheAndroid.cpp \
platform/graphics/android/FontCustomPlatformData.cpp \
@@ -674,7 +673,6 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
platform/graphics/android/ScrollableLayerAndroid.cpp \
platform/graphics/android/SharedBufferStream.cpp \
platform/graphics/android/ShaderProgram.cpp \
- platform/graphics/android/SharedTexture.cpp \
platform/graphics/android/TextureInfo.cpp \
platform/graphics/android/TexturesGenerator.cpp \
platform/graphics/android/TilesManager.cpp \
diff --git a/Source/WebCore/platform/graphics/android/BaseTile.cpp b/Source/WebCore/platform/graphics/android/BaseTile.cpp
index 27bd482..73b6422 100644
--- a/Source/WebCore/platform/graphics/android/BaseTile.cpp
+++ b/Source/WebCore/platform/graphics/android/BaseTile.cpp
@@ -68,6 +68,7 @@ BaseTile::BaseTile(bool isLayerTile)
, m_dirty(true)
, m_repaintPending(false)
, m_lastDirtyPicture(0)
+ , m_fullRepaint(true)
, m_isTexturePainted(false)
, m_isLayerTile(isLayerTile)
, m_drawCount(0)
@@ -76,20 +77,6 @@ BaseTile::BaseTile(bool isLayerTile)
#ifdef DEBUG_COUNT
ClassTracker::instance()->increment("BaseTile");
#endif
- m_currentDirtyAreaIndex = 0;
-
- // For EglImage Mode, the internal buffer should be 2.
- // For Surface Texture mode, we only need one.
- if (TilesManager::instance()->getSharedTextureMode() == EglImageMode)
- m_maxBufferNumber = 2;
- else
- m_maxBufferNumber = 1;
-
- m_dirtyArea = new SkRegion[m_maxBufferNumber];
- m_fullRepaint = new bool[m_maxBufferNumber];
- for (int i = 0; i < m_maxBufferNumber; i++)
- m_fullRepaint[i] = true;
-
m_renderer = BaseRenderer::createRenderer();
}
@@ -101,8 +88,6 @@ BaseTile::~BaseTile()
m_frontTexture->release(this);
delete m_renderer;
- delete[] m_dirtyArea;
- delete[] m_fullRepaint;
#ifdef DEBUG_COUNT
ClassTracker::instance()->decrement("BaseTile");
@@ -181,8 +166,7 @@ void BaseTile::markAsDirty(int unsigned pictureCount,
return;
android::AutoMutex lock(m_atomicSync);
m_lastDirtyPicture = pictureCount;
- for (int i = 0; i < m_maxBufferNumber; i++)
- m_dirtyArea[i].op(dirtyArea, SkRegion::kUnion_Op);
+ m_dirtyArea.op(dirtyArea, SkRegion::kUnion_Op);
// Check if we actually intersect with the area
bool intersect = false;
@@ -262,12 +246,6 @@ void BaseTile::draw(float transparency, SkRect& rect, float scale)
if (!isTexturePainted)
return;
- TextureInfo* textureInfo = m_frontTexture->consumerLock();
- if (!textureInfo) {
- m_frontTexture->consumerRelease();
- return;
- }
-
if (m_frontTexture->readyFor(this)) {
if (isLayerTile() && m_painter && m_painter->transform())
TilesManager::instance()->shader()->drawLayerQuad(*m_painter->transform(),
@@ -279,8 +257,6 @@ void BaseTile::draw(float transparency, SkRect& rect, float scale)
} else {
XLOG("tile %p at %d, %d not readyfor (at draw),", this, m_x, m_y);
}
-
- m_frontTexture->consumerRelease();
}
bool BaseTile::isTileReady()
@@ -301,9 +277,7 @@ bool BaseTile::isTileReady()
if (m_state != ReadyToSwap && m_state != UpToDate)
return false;
- texture->consumerLock();
bool ready = texture->readyFor(this);
- texture->consumerRelease();
if (ready)
return true;
@@ -350,7 +324,7 @@ void BaseTile::paintBitmap()
m_atomicSync.lock();
bool dirty = m_dirty;
BaseTileTexture* texture = m_backTexture;
- SkRegion dirtyArea = m_dirtyArea[m_currentDirtyAreaIndex];
+ SkRegion dirtyArea = m_dirtyArea;
float scale = m_scale;
const int x = m_x;
const int y = m_y;
@@ -365,15 +339,12 @@ void BaseTile::paintBitmap()
this, m_state, m_frontTexture, m_backTexture);
}
m_state = PaintingStarted;
-
- texture->producerAcquireContext();
- TextureInfo* textureInfo = texture->producerLock();
+ TextureInfo* textureInfo = texture->getTextureInfo();
m_atomicSync.unlock();
// at this point we can safely check the ownership (if the texture got
// transferred to another BaseTile under us)
if (texture->owner() != this) {
- texture->producerRelease();
return;
}
@@ -381,7 +352,6 @@ void BaseTile::paintBitmap()
// swap out the renderer if necessary
BaseRenderer::swapRendererIfNeeded(m_renderer);
-
// setup the common renderInfo fields;
TileRenderInfo renderInfo;
renderInfo.x = x;
@@ -399,16 +369,16 @@ void BaseTile::paintBitmap()
bool fullRepaint = false;
- if (m_fullRepaint[m_currentDirtyAreaIndex]
+ if (m_fullRepaint
|| textureInfo->m_width != tileWidth
|| textureInfo->m_height != tileHeight) {
fullRepaint = true;
}
- bool surfaceTextureMode = textureInfo->getSharedTextureMode() == SurfaceTextureMode;
-
- if (surfaceTextureMode)
- fullRepaint = true;
+ // With SurfaceTexture, just repaint the entire tile if we intersect.
+ // TODO: Implement the partial invalidate in Surface Texture Mode.
+ // Such that the code of partial invalidation below is preserved.
+ fullRepaint = true;
while (!fullRepaint && !cliperator.done()) {
SkRect realTileRect;
@@ -417,14 +387,7 @@ void BaseTile::paintBitmap()
bool intersect = intersectWithRect(x, y, tileWidth, tileHeight,
scale, dirtyRect, realTileRect);
- // With SurfaceTexture, just repaint the entire tile if we intersect
- // TODO: Implement the partial invalidate in Surface Texture Mode
- if (intersect && surfaceTextureMode) {
- fullRepaint = true;
- break;
- }
-
- if (intersect && !surfaceTextureMode) {
+ if (intersect) {
// initialize finalRealRect to the rounded values of realTileRect
SkIRect finalRealRect;
realTileRect.roundOut(&finalRealRect);
@@ -466,15 +429,11 @@ void BaseTile::paintBitmap()
m_atomicSync.lock();
-#if DEPRECATED_SURFACE_TEXTURE_MODE
- texture->setTile(textureInfo, x, y, scale, painter, pictureCount);
-#endif
- texture->producerReleaseAndSwap();
if (texture == m_backTexture) {
m_isTexturePainted = true;
// set the fullrepaint flags
- m_fullRepaint[m_currentDirtyAreaIndex] = false;
+ m_fullRepaint = false;
// The various checks to see if we are still dirty...
@@ -484,19 +443,11 @@ void BaseTile::paintBitmap()
m_dirty = true;
if (fullRepaint)
- m_dirtyArea[m_currentDirtyAreaIndex].setEmpty();
+ m_dirtyArea.setEmpty();
else
- m_dirtyArea[m_currentDirtyAreaIndex].op(dirtyArea, SkRegion::kDifference_Op);
+ m_dirtyArea.op(dirtyArea, SkRegion::kDifference_Op);
- if (!m_dirtyArea[m_currentDirtyAreaIndex].isEmpty())
- m_dirty = true;
-
- // Now we can swap the dirty areas
- // TODO: For surface texture in Async mode, the index will be updated
- // according to the current buffer just dequeued.
- m_currentDirtyAreaIndex = (m_currentDirtyAreaIndex+1) % m_maxBufferNumber;
-
- if (!m_dirtyArea[m_currentDirtyAreaIndex].isEmpty())
+ if (!m_dirtyArea.isEmpty())
m_dirty = true;
XLOG("painted tile %p (%d, %d), texture %p, dirty=%d", this, x, y, texture, m_dirty);
@@ -522,10 +473,9 @@ void BaseTile::discardTextures() {
m_backTexture->release(this);
m_backTexture = 0;
}
- for (int i = 0; i < m_maxBufferNumber; i++) {
- m_dirtyArea[i].setEmpty();
- m_fullRepaint[i] = true;
- }
+ m_dirtyArea.setEmpty();
+ m_fullRepaint = true;
+
m_dirty = true;
m_state = Unpainted;
}
diff --git a/Source/WebCore/platform/graphics/android/BaseTile.h b/Source/WebCore/platform/graphics/android/BaseTile.h
index 685ca43..ed06332 100644
--- a/Source/WebCore/platform/graphics/android/BaseTile.h
+++ b/Source/WebCore/platform/graphics/android/BaseTile.h
@@ -172,10 +172,8 @@ private:
unsigned int m_lastDirtyPicture;
// store the dirty region
- SkRegion* m_dirtyArea;
- bool* m_fullRepaint;
- int m_maxBufferNumber;
- int m_currentDirtyAreaIndex;
+ SkRegion m_dirtyArea;
+ bool m_fullRepaint;
// flag used to know if we have a texture that was painted at least once
bool m_isTexturePainted;
diff --git a/Source/WebCore/platform/graphics/android/BaseTileTexture.cpp b/Source/WebCore/platform/graphics/android/BaseTileTexture.cpp
index caaf116..6da1b77 100644
--- a/Source/WebCore/platform/graphics/android/BaseTileTexture.cpp
+++ b/Source/WebCore/platform/graphics/android/BaseTileTexture.cpp
@@ -53,10 +53,7 @@
namespace WebCore {
BaseTileTexture::BaseTileTexture(uint32_t w, uint32_t h)
- : DoubleBufferedTexture(eglGetCurrentContext(),
- TilesManager::instance()->getSharedTextureMode())
- , m_owner(0)
- , m_busy(false)
+ : m_owner(0)
{
m_size.set(w, h);
m_ownTextureId = 0;
@@ -71,10 +68,6 @@ BaseTileTexture::BaseTileTexture(uint32_t w, uint32_t h)
BaseTileTexture::~BaseTileTexture()
{
- if (m_sharedTextureMode == EglImageMode) {
- SharedTexture* textures[3] = { m_textureA, m_textureB, 0 };
- destroyTextures(textures);
- }
#ifdef DEBUG_COUNT
ClassTracker::instance()->decrement("BaseTileTexture");
#endif
@@ -98,71 +91,6 @@ void BaseTileTexture::discardGLTexture()
}
}
-void BaseTileTexture::destroyTextures(SharedTexture** textures)
-{
- int x = 0;
- while (textures[x]) {
- // 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* BaseTileTexture::producerLock()
-{
- m_busyLock.lock();
- m_busy = true;
- m_busyLock.unlock();
- return DoubleBufferedTexture::producerLock();
-}
-
-void BaseTileTexture::producerRelease()
-{
- DoubleBufferedTexture::producerRelease();
- setNotBusy();
-}
-
-void BaseTileTexture::producerReleaseAndSwap()
-{
- DoubleBufferedTexture::producerReleaseAndSwap();
- setNotBusy();
-}
-
-void BaseTileTexture::setNotBusy()
-{
- android::Mutex::Autolock lock(m_busyLock);
- m_busy = false;
- m_busyCond.signal();
-}
-
-bool BaseTileTexture::busy()
-{
- android::Mutex::Autolock lock(m_busyLock);
- return m_busy;
-}
-
-void BaseTileTexture::producerUpdate(TextureInfo* textureInfo, const SkBitmap& bitmap)
-{
- // no need to upload a texture since the bitmap is empty
- if (!bitmap.width() && !bitmap.height()) {
- producerRelease();
- return;
- }
-
- // After the tiled layer checked in, this is not called anyway.
- // TODO: cleanup the old code path for layer painting
- // GLUtils::paintTextureWithBitmap(info, m_size, bitmap, 0, 0);
-
- producerReleaseAndSwap();
-}
-
bool BaseTileTexture::acquire(TextureOwner* owner, bool force)
{
if (m_owner == owner)
@@ -173,39 +101,21 @@ bool BaseTileTexture::acquire(TextureOwner* owner, bool force)
bool BaseTileTexture::setOwner(TextureOwner* owner, bool force)
{
- // if the writable texture is busy (i.e. currently being written to) then we
- // can't change the owner out from underneath that texture
- m_busyLock.lock();
- while (m_busy && force)
- m_busyCond.wait(m_busyLock);
- bool busy = m_busy;
- m_busyLock.unlock();
-
- if (!busy) {
- // if we are not busy we can try to remove the texture from the layer;
- // LayerAndroid::removeTexture() is protected by the same lock as
- // LayerAndroid::paintBitmapGL(), so either we execute removeTexture()
- // first and paintBitmapGL() will bail out, or we execute it after,
- // and paintBitmapGL() will mark the texture as busy before
- // relinquishing the lock. LayerAndroid::removeTexture() will call
- // BaseTileTexture::release(), which will then do nothing
- // if the texture is busy and we then don't return true.
- bool proceed = true;
- if (m_owner && m_owner != owner)
- proceed = m_owner->removeTexture(this);
+ bool proceed = true;
+ if (m_owner && m_owner != owner)
+ proceed = m_owner->removeTexture(this);
- if (proceed) {
- m_owner = owner;
- return true;
- }
+ if (proceed) {
+ m_owner = owner;
+ return true;
}
+
return false;
}
bool BaseTileTexture::release(TextureOwner* owner)
{
- android::Mutex::Autolock lock(m_busyLock);
- XLOG("texture %p releasing tile %p, m_owner %p, m_busy %d", this, owner, m_owner, m_busy);
+ XLOG("texture %p releasing tile %p, m_owner %p", this, owner, m_owner);
if (m_owner != owner)
return false;
@@ -213,22 +123,6 @@ bool BaseTileTexture::release(TextureOwner* owner)
return true;
}
-void BaseTileTexture::setTile(TextureInfo* info, int x, int y,
- float scale, TilePainter* painter,
- unsigned int pictureCount)
-{
- TextureTileInfo* textureInfo = m_texturesInfo.get(getWriteableTexture());
- if (!textureInfo) {
- textureInfo = new TextureTileInfo();
- }
- textureInfo->m_x = x;
- textureInfo->m_y = y;
- textureInfo->m_scale = scale;
- textureInfo->m_painter = painter;
- textureInfo->m_picture = pictureCount;
- m_texturesInfo.set(getWriteableTexture(), textureInfo);
-}
-
float BaseTileTexture::scale()
{
TextureTileInfo* textureInfo = &m_ownTextureTileInfo;
diff --git a/Source/WebCore/platform/graphics/android/BaseTileTexture.h b/Source/WebCore/platform/graphics/android/BaseTileTexture.h
index fdd2b0e..379d587 100644
--- a/Source/WebCore/platform/graphics/android/BaseTileTexture.h
+++ b/Source/WebCore/platform/graphics/android/BaseTileTexture.h
@@ -26,10 +26,11 @@
#ifndef BaseTileTexture_h
#define BaseTileTexture_h
-#include "DoubleBufferedTexture.h"
#include "GLWebViewState.h"
+#include "TextureInfo.h"
#include "TextureOwner.h"
#include "TilePainter.h"
+#include <GLES2/gl2.h>
#include <SkBitmap.h>
class SkCanvas;
@@ -61,23 +62,13 @@ public:
bool m_inverted;
};
-// DoubleBufferedTexture using a SkBitmap as backing mechanism
-class BaseTileTexture : public DoubleBufferedTexture {
+class BaseTileTexture {
public:
// This object is to be constructed on the consumer's thread and must have
// a width and height greater than 0.
BaseTileTexture(uint32_t w, uint32_t h);
virtual ~BaseTileTexture();
- // these functions override their parent
- virtual TextureInfo* producerLock();
- virtual void producerRelease();
- virtual void producerReleaseAndSwap();
-
- // updates the texture with current bitmap and releases (and if needed also
- // swaps) the texture.
- virtual void producerUpdate(TextureInfo* textureInfo, const SkBitmap& bitmap);
-
// allows consumer thread to assign ownership of the texture to the tile. It
// returns false if ownership cannot be transferred because the tile is busy
bool acquire(TextureOwner* owner, bool force = false);
@@ -89,13 +80,8 @@ public:
// private member accessor functions
TextureOwner* owner() { return m_owner; } // only used by the consumer thread
- bool busy();
- void setNotBusy();
-
const SkSize& getSize() const { return m_size; }
- void setTile(TextureInfo* info, int x, int y, float scale,
- TilePainter* painter, unsigned int pictureCount);
bool readyFor(BaseTile* baseTile);
float scale();
@@ -107,29 +93,17 @@ public:
void setOwnTextureTileInfoFromQueue(const TextureTileInfo* info);
-protected:
- HashMap<SharedTexture*, TextureTileInfo*> m_texturesInfo;
+ TextureInfo* getTextureInfo() { return &m_ownTextureInfo; }
private:
- void destroyTextures(SharedTexture** textures);
TextureTileInfo m_ownTextureTileInfo;
-
+ // TODO: Merge this info into the TextureTileInfo.
+ TextureInfo m_ownTextureInfo;
SkSize m_size;
SkBitmap::Config m_config;
// BaseTile owning the texture, only modified by UI thread
TextureOwner* m_owner;
-
- // This values signals that the texture is currently in use by the consumer.
- // This allows us to prevent the owner of the texture from changing while the
- // consumer is holding a lock on the texture.
- bool m_busy;
- // We mutex protect the reads/writes of m_busy to ensure that we are reading
- // the most up-to-date value even across processors in an SMP system.
- android::Mutex m_busyLock;
- // We use this condition variable to signal that the texture
- // is not busy anymore
- android::Condition m_busyCond;
};
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/DoubleBufferedTexture.cpp b/Source/WebCore/platform/graphics/android/DoubleBufferedTexture.cpp
deleted file mode 100644
index 3194cb9..0000000
--- a/Source/WebCore/platform/graphics/android/DoubleBufferedTexture.cpp
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * Copyright 2010, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "DoubleBufferedTexture.h"
-
-#include "ClassTracker.h"
-#include "GLUtils.h"
-
-#define LOG_NDEBUG 1
-#define LOG_TAG "DoubleBufferedTexture.cpp"
-#include <utils/Log.h>
-
-namespace WebCore {
-
-DoubleBufferedTexture::DoubleBufferedTexture(EGLContext sharedContext, SharedTextureMode mode)
-{
- m_sharedTextureMode = mode;
-
- m_textureA = new SharedTexture(m_sharedTextureMode);
- if (m_sharedTextureMode == EglImageMode)
- m_textureB = new SharedTexture(m_sharedTextureMode);
- else
- m_textureB = 0;
-
- m_display = eglGetCurrentDisplay();
- m_pContext = EGL_NO_CONTEXT;
- m_cContext = sharedContext;
- m_writeableTexture = m_textureA;
- m_lockedConsumerTexture = GL_NO_TEXTURE;
- m_supportsEGLImage = GLUtils::isEGLImageSupported();
-#ifdef DEBUG_COUNT
- ClassTracker::instance()->increment("DoubleBufferedTexture");
-#endif
-}
-
-DoubleBufferedTexture::~DoubleBufferedTexture()
-{
-#ifdef DEBUG_COUNT
- ClassTracker::instance()->decrement("DoubleBufferedTexture");
-#endif
- delete m_textureA;
- delete m_textureB;
-}
-
-SharedTexture* DoubleBufferedTexture::getWriteableTexture()
-{
- if (m_sharedTextureMode == SurfaceTextureMode)
- return m_textureA;
- return reinterpret_cast<SharedTexture*>(
- android_atomic_release_load((int32_t*)&m_writeableTexture));
-}
-
-SharedTexture* DoubleBufferedTexture::getReadableTexture()
-{
- if (m_sharedTextureMode == SurfaceTextureMode)
- return m_textureA;
- return (getWriteableTexture() != m_textureA) ? m_textureA : m_textureB;
-}
-
-EGLContext DoubleBufferedTexture::producerAcquireContext()
-{
- if (m_sharedTextureMode == SurfaceTextureMode)
- return EGL_NO_CONTEXT;
-
- if (m_pContext != EGL_NO_CONTEXT) {
- ALOGV("AquireContext has previously generated a context.\n");
- return m_pContext;
- }
-
- // check to see if a context already exists on this thread
- EGLContext context = eglGetCurrentContext();
-
- // if no context exists then create one
- if (context == EGL_NO_CONTEXT) {
- EGLContext sharedContext = m_supportsEGLImage ? EGL_NO_CONTEXT : m_cContext;
- context = GLUtils::createBackgroundContext(sharedContext);
- }
-
- if (context == EGL_NO_CONTEXT) {
- LOGE("eglCreateContext failed");
- return EGL_NO_CONTEXT;
- }
-
- // initialize the producer's textures
- m_textureA->lock();
- if (m_sharedTextureMode == EglImageMode)
- m_textureB->lock();
-
- m_textureA->initSourceTexture();
- ALOGV("Initialized Textures A (%d)", m_textureA->getSourceTextureId());
- if (m_sharedTextureMode == EglImageMode) {
- m_textureB->initSourceTexture();
- ALOGV("Initialized Textures B (%d)", m_textureB->getSourceTextureId());
- }
-
- m_textureA->unlock();
- if (m_sharedTextureMode == EglImageMode)
- m_textureB->unlock();
-
- m_pContext = context;
- return context;
-}
-
-// For MediaTexture only
-void DoubleBufferedTexture::producerDeleteTextures()
-{
- m_textureA->lock();
- if (m_sharedTextureMode == EglImageMode)
- m_textureB->lock();
-
- ALOGV("Deleting Producer Textures A (%d)", m_textureA->getSourceTextureId());
- m_textureA->deleteSourceTexture();
- if (m_sharedTextureMode == EglImageMode){
- ALOGV("Deleting Producer Textures B (%d)", m_textureB->getSourceTextureId());
- m_textureB->deleteSourceTexture();
- }
-
- m_textureA->unlock();
- if (m_sharedTextureMode == EglImageMode)
- m_textureB->unlock();
-}
-
-// For MediaTexture only
-void DoubleBufferedTexture::consumerDeleteTextures()
-{
- m_textureA->lock();
- if (m_sharedTextureMode == EglImageMode)
- m_textureB->lock();
-
- ALOGV("Deleting Consumer Textures A (%d)", m_textureA->getTargetTextureId());
- m_textureA->deleteTargetTexture();
- if (m_sharedTextureMode == EglImageMode) {
- ALOGV("Deleting Consumer Textures B (%d)", m_textureB->getTargetTextureId());
- m_textureB->deleteTargetTexture();
- }
-
- m_textureA->unlock();
- if (m_sharedTextureMode == EglImageMode)
- m_textureB->unlock();
-}
-
-TextureInfo* DoubleBufferedTexture::producerLock()
-{
- SharedTexture* sharedTex = getWriteableTexture();
- ALOGV("Acquiring P Lock (%d)", sharedTex->getSourceTextureId());
- TextureInfo* texInfo = sharedTex->lockSource();
- ALOGV("Acquired P Lock");
-
- return texInfo;
-}
-
-void DoubleBufferedTexture::producerRelease()
-{
- // get the writable texture and unlock it
- SharedTexture* sharedTex = getWriteableTexture();
- ALOGV("Releasing P Lock (%d)", sharedTex->getSourceTextureId());
- sharedTex->releaseSource();
- ALOGV("Released P Lock (%d)", sharedTex->getSourceTextureId());
-}
-
-void DoubleBufferedTexture::producerReleaseAndSwap()
-{
- producerRelease();
- if (m_sharedTextureMode == EglImageMode) {
- // swap the front and back buffers using an atomic op for the memory barrier
- android_atomic_acquire_store((int32_t)getReadableTexture(), (int32_t*)&m_writeableTexture);
- }
-}
-
-TextureInfo* DoubleBufferedTexture::consumerLock()
-{
- SharedTexture* sharedTex = getReadableTexture();
- ALOGV("Acquiring C Lock (%d)", sharedTex->getSourceTextureId());
- m_lockedConsumerTexture = sharedTex;
-
- TextureInfo* texInfo = sharedTex->lockTarget();
- ALOGV("Acquired C Lock");
-
- if (!texInfo)
- ALOGV("Released C Lock (Empty)");
-
- return texInfo;
-}
-
-void DoubleBufferedTexture::consumerRelease()
-{
- // we must check to see what texture the consumer had locked since the
- // producer may have swapped out the readable buffer
- SharedTexture* sharedTex = m_lockedConsumerTexture;
- sharedTex->releaseTarget();
- ALOGV("Released C Lock (%d)", sharedTex->getSourceTextureId());
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/DoubleBufferedTexture.h b/Source/WebCore/platform/graphics/android/DoubleBufferedTexture.h
deleted file mode 100644
index 821b79b..0000000
--- a/Source/WebCore/platform/graphics/android/DoubleBufferedTexture.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright 2010, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef DoubleBufferedTexture_h
-#define DoubleBufferedTexture_h
-
-#include "SharedTexture.h"
-#include <EGL/egl.h>
-
-namespace WebCore {
-
-class DoubleBufferedTexture {
-public:
- // consumer thread functions
- DoubleBufferedTexture(EGLContext sharedContext, SharedTextureMode mode);
- virtual ~DoubleBufferedTexture();
-
- // provider thread functions
- virtual TextureInfo* producerLock();
- virtual void producerRelease();
- virtual void producerReleaseAndSwap();
- EGLContext producerAcquireContext();
- void producerDeleteTextures();
-
- // consumer thread functions
- TextureInfo* consumerLock();
- void consumerRelease();
- void consumerDeleteTextures();
-
-protected:
- SharedTexture* getReadableTexture();
- SharedTexture* getWriteableTexture();
-
- SharedTexture* m_textureA;
- SharedTexture* m_textureB;
-
- SharedTextureMode m_sharedTextureMode;
-private:
-
- SharedTexture* m_writeableTexture;
- SharedTexture* m_lockedConsumerTexture; // only used by the consumer
-
- EGLDisplay m_display;
- EGLContext m_pContext;
- EGLContext m_cContext;
-
- bool m_supportsEGLImage;
-};
-
-} // namespace WebCore
-
-#endif // DoubleBufferedTexture_h
diff --git a/Source/WebCore/platform/graphics/android/GLUtils.cpp b/Source/WebCore/platform/graphics/android/GLUtils.cpp
index eb459df..afb9bb0 100644
--- a/Source/WebCore/platform/graphics/android/GLUtils.cpp
+++ b/Source/WebCore/platform/graphics/android/GLUtils.cpp
@@ -385,106 +385,23 @@ void GLUtils::paintTextureWithBitmap(const TileRenderInfo* renderInfo,
const int y = renderInfo->invalRect->fTop;
const SkSize& requiredSize = renderInfo->tileSize;
TextureInfo* textureInfo = renderInfo->textureInfo;
- SharedTextureMode mode = textureInfo->getSharedTextureMode();
- if (requiredSize.equals(textureInfo->m_width, textureInfo->m_height)) {
- if (mode == EglImageMode)
- GLUtils::updateTextureWithBitmap(textureInfo->m_textureId, x, y, bitmap);
- else if (mode == SurfaceTextureMode)
-#if DEPRECATED_SURFACE_TEXTURE_MODE
- GLUtils::updateSurfaceTextureWithBitmap(renderInfo, x, y, bitmap);
-#else
- GLUtils::updateSharedSurfaceTextureWithBitmap(renderInfo, x, y, bitmap);
-#endif
- } else {
+ if (requiredSize.equals(textureInfo->m_width, textureInfo->m_height))
+ GLUtils::updateSharedSurfaceTextureWithBitmap(renderInfo, x, y, bitmap);
+ else {
if (!requiredSize.equals(bitmap.width(), bitmap.height())) {
XLOG("The bitmap size (%d,%d) does not equal the texture size (%d,%d)",
bitmap.width(), bitmap.height(),
requiredSize.width(), requiredSize.height());
}
+ GLUtils::updateSharedSurfaceTextureWithBitmap(renderInfo, 0, 0, bitmap);
- if (mode == EglImageMode)
- GLUtils::createTextureWithBitmap(textureInfo->m_textureId, bitmap);
- else if (mode == SurfaceTextureMode)
-#if DEPRECATED_SURFACE_TEXTURE_MODE
- GLUtils::createSurfaceTextureWithBitmap(renderInfo, bitmap);
-#else
- GLUtils::updateSharedSurfaceTextureWithBitmap(renderInfo, 0, 0, bitmap);
-#endif
textureInfo->m_width = bitmap.width();
textureInfo->m_height = bitmap.height();
textureInfo->m_internalFormat = GL_RGBA;
}
}
-#if DEPRECATED_SURFACE_TEXTURE_MODE
-void GLUtils::createSurfaceTextureWithBitmap(const TileRenderInfo* renderInfo, const SkBitmap& bitmap, GLint filter)
-{
-
- TextureInfo* texture = renderInfo->textureInfo;
-
- texture->m_width = bitmap.width();
- texture->m_height = bitmap.height();
- texture->m_internalFormat = GL_RGBA;
-
- sp<android::SurfaceTexture> surfaceTexture = texture->m_surfaceTexture;
- sp<ANativeWindow> ANW = texture->m_ANW;
-
- int result;
- result = native_window_set_buffers_geometry(ANW.get(),
- texture->m_width, texture->m_height, HAL_PIXEL_FORMAT_RGBA_8888);
- checkSurfaceTextureError("native_window_set_buffers_geometry", result);
- result = native_window_set_usage(ANW.get(),
- GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN);
- checkSurfaceTextureError("native_window_set_usage", result);
-
- updateSurfaceTextureWithBitmap(renderInfo, 0, 0, bitmap, filter);
-}
-
-void GLUtils::updateSurfaceTextureWithBitmap(const TileRenderInfo* renderInfo, int x, int y, const SkBitmap& bitmap, GLint filter)
-{
- TextureInfo* texture = renderInfo->textureInfo;
- sp<android::SurfaceTexture> surfaceTexture = texture->m_surfaceTexture;
- sp<ANativeWindow> ANW = texture->m_ANW;
-
- ANativeWindowBuffer* anb;
- int status = ANW->dequeueBuffer(ANW.get(), &anb);
- checkSurfaceTextureError("dequeueBuffer", status);
-
- if (status != NO_ERROR) { // FIXME: add proper error handling!
- native_window_set_buffer_count(ANW.get(), 3);
- return;
- }
-
- sp<android::GraphicBuffer> buf(new android::GraphicBuffer(anb, false));
- status |= ANW->lockBuffer(ANW.get(), buf->getNativeBuffer());
- checkSurfaceTextureError("lockBuffer", status);
-
- // Fill the buffer with the content of the bitmap
- uint8_t* img = 0;
- status |= buf->lock(GRALLOC_USAGE_SW_WRITE_OFTEN, (void**)(&img));
- checkSurfaceTextureError("lock", status);
-
- if (status == NO_ERROR) {
- int row, col;
- int bpp = 4; // Now only deal with RGBA8888 format.
-
- bitmap.lockPixels();
- uint8_t* bitmapOrigin = static_cast<uint8_t*>(bitmap.getPixels());
- // Copied line by line since we need to handle the offsets and stride.
- for (row = 0 ; row < bitmap.height(); row ++) {
- uint8_t* dst = &(img[(buf->getStride() * (row + x) + y) * bpp]);
- uint8_t* src = &(bitmapOrigin[bitmap.width() * row * bpp]);
- memcpy(dst, src, bpp * bitmap.width());
- }
- bitmap.unlockPixels();
- }
- buf->unlock();
- status = ANW->queueBuffer(ANW.get(), buf->getNativeBuffer());
- checkSurfaceTextureError("queueBuffer", status);
-}
-#endif
-
void GLUtils::updateSharedSurfaceTextureWithBitmap(const TileRenderInfo* renderInfo, int x, int y, const SkBitmap& bitmap)
{
if (!renderInfo
diff --git a/Source/WebCore/platform/graphics/android/GLUtils.h b/Source/WebCore/platform/graphics/android/GLUtils.h
index 68acbab..48235a5 100644
--- a/Source/WebCore/platform/graphics/android/GLUtils.h
+++ b/Source/WebCore/platform/graphics/android/GLUtils.h
@@ -78,10 +78,6 @@ public:
static void createTextureFromEGLImage(GLuint texture, EGLImageKHR image, GLint filter = GL_LINEAR);
static void paintTextureWithBitmap(const TileRenderInfo* renderInfo, const SkBitmap& bitmap);
-#if DEPRECATED_SURFACE_TEXTURE_MODE
- static void createSurfaceTextureWithBitmap(const TileRenderInfo* , const SkBitmap& bitmap, GLint filter = GL_LINEAR);
- static void updateSurfaceTextureWithBitmap(const TileRenderInfo* , int x, int y, const SkBitmap& bitmap, GLint filter = GL_LINEAR);
-#endif
static void updateSharedSurfaceTextureWithBitmap(const TileRenderInfo* , int x, int y, const SkBitmap& bitmap);
static void convertToTransformationMatrix(const float* matrix, TransformationMatrix& transformMatrix);
};
diff --git a/Source/WebCore/platform/graphics/android/GaneshContext.cpp b/Source/WebCore/platform/graphics/android/GaneshContext.cpp
index 03e6eb7..d4fa4e7 100644
--- a/Source/WebCore/platform/graphics/android/GaneshContext.cpp
+++ b/Source/WebCore/platform/graphics/android/GaneshContext.cpp
@@ -95,11 +95,7 @@ SkDevice* GaneshContext::getDeviceForBaseTile(const TileRenderInfo& renderInfo)
contextNeedsReset = true;
}
- SkDevice* device = 0;
- if (renderInfo.textureInfo->getSharedTextureMode() == SurfaceTextureMode)
- device = getDeviceForBaseTileSurface(renderInfo);
- else if (renderInfo.textureInfo->getSharedTextureMode() == EglImageMode)
- device = getDeviceForBaseTileFBO(renderInfo);
+ SkDevice* device = getDeviceForBaseTileSurface(renderInfo);
// We must reset the Ganesh context only after we are sure we have
// re-established our EGLContext as the current context.
diff --git a/Source/WebCore/platform/graphics/android/GaneshRenderer.cpp b/Source/WebCore/platform/graphics/android/GaneshRenderer.cpp
index f4df33a..5889655 100644
--- a/Source/WebCore/platform/graphics/android/GaneshRenderer.cpp
+++ b/Source/WebCore/platform/graphics/android/GaneshRenderer.cpp
@@ -84,20 +84,16 @@ void GaneshRenderer::setupCanvas(const TileRenderInfo& renderInfo, SkCanvas* can
GaneshContext* ganesh = GaneshContext::instance();
-#if !DEPRECATED_SURFACE_TEXTURE_MODE
- if (renderInfo.textureInfo->getSharedTextureMode() == SurfaceTextureMode) {
- TransferQueue* tileQueue = TilesManager::instance()->transferQueue();
-
- tileQueue->lockQueue();
-
- bool ready = tileQueue->readyForUpdate();
- if (!ready) {
- XLOG("!ready");
- tileQueue->unlockQueue();
- return;
- }
+ TransferQueue* tileQueue = TilesManager::instance()->transferQueue();
+
+ tileQueue->lockQueue();
+
+ bool ready = tileQueue->readyForUpdate();
+ if (!ready) {
+ XLOG("!ready");
+ tileQueue->unlockQueue();
+ return;
}
-#endif
SkDevice* device = NULL;
if (renderInfo.tileSize.width() == TilesManager::tileWidth()
@@ -118,12 +114,6 @@ void GaneshRenderer::setupCanvas(const TileRenderInfo& renderInfo, SkCanvas* can
// set the GPU device to the canvas
canvas->setDevice(device);
canvas->setDeviceFactory(device->getDeviceFactory());
-
- // invert canvas contents
- if (renderInfo.textureInfo->getSharedTextureMode() == EglImageMode) {
- canvas->scale(SK_Scalar1, -SK_Scalar1);
- canvas->translate(0, -renderInfo.tileSize.height());
- }
}
void GaneshRenderer::setupPartialInval(const TileRenderInfo& renderInfo, SkCanvas* canvas)
@@ -149,14 +139,10 @@ void GaneshRenderer::renderingComplete(const TileRenderInfo& renderInfo, SkCanva
// In SurfaceTextureMode we must call swapBuffers to unlock and post the
// tile's ANativeWindow (i.e. SurfaceTexture) buffer
- if (renderInfo.textureInfo->getSharedTextureMode() == SurfaceTextureMode) {
-#if !DEPRECATED_SURFACE_TEXTURE_MODE
- TransferQueue* tileQueue = TilesManager::instance()->transferQueue();
- eglSwapBuffers(eglGetCurrentDisplay(), tileQueue->m_eglSurface);
- tileQueue->addItemInTransferQueue(&renderInfo, GpuUpload, 0);
- tileQueue->unlockQueue();
-#endif
- }
+ TransferQueue* tileQueue = TilesManager::instance()->transferQueue();
+ eglSwapBuffers(eglGetCurrentDisplay(), tileQueue->m_eglSurface);
+ tileQueue->addItemInTransferQueue(&renderInfo, GpuUpload, 0);
+ tileQueue->unlockQueue();
if (renderInfo.measurePerf)
m_perfMon.stop(TAG_UPDATE_TEXTURE);
diff --git a/Source/WebCore/platform/graphics/android/SharedTexture.cpp b/Source/WebCore/platform/graphics/android/SharedTexture.cpp
deleted file mode 100644
index 429c589..0000000
--- a/Source/WebCore/platform/graphics/android/SharedTexture.cpp
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * Copyright 2010, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "SharedTexture.h"
-
-#include "GLUtils.h"
-#include <android/native_window.h>
-#include <gui/SurfaceTexture.h>
-#include <gui/SurfaceTextureClient.h>
-
-#define LOG_NDEBUG 1
-#define LOG_TAG "SharedTexture.cpp"
-#include <utils/Log.h>
-
-namespace WebCore {
-
-SharedTexture::SharedTexture(SharedTextureMode mode)
-{
- m_sharedTextureMode = mode;
-
- m_sourceTexture = new TextureInfo(m_sharedTextureMode);
- m_targetTexture = 0;
-
- if (m_sharedTextureMode == EglImageMode) {
- m_targetTexture = new TextureInfo(m_sharedTextureMode);
- m_eglImage = EGL_NO_IMAGE_KHR;
- m_isNewImage = true;
- m_syncObject = EGL_NO_SYNC_KHR;
-
- // Defer initialization of these values until we initialize the source
- // texture. This ensures that this initialization happens in the appropriate
- // thread.
- m_display = 0;
- m_supportsEGLImage = false;
- m_supportsEGLFenceSyncKHR = false;
- } else if (m_sharedTextureMode == SurfaceTextureMode) {
-#if DEPRECATED_SURFACE_TEXTURE_MODE
- glGenTextures(1, &m_sourceTexture->m_textureId);
-
- m_sourceTexture->m_surfaceTexture =
- new android::SurfaceTexture(m_sourceTexture->m_textureId, false);
- m_sourceTexture->m_ANW =
- new android::SurfaceTextureClient(m_sourceTexture->m_surfaceTexture);
-#endif
- }
-}
-
-// called by the consumer when it no longer wants to consume and after it has
-// terminated all providers. If EGLImages are used, the deletion of the
-// source texture and EGLImage is the responsibility of the caller.
-SharedTexture::~SharedTexture()
-{
- if (m_sharedTextureMode == EglImageMode)
- deleteTargetTexture();
- else if (m_sharedTextureMode == SurfaceTextureMode) {
-#if DEPRECATED_SURFACE_TEXTURE_MODE
- m_sourceTexture->m_surfaceTexture.clear();
- m_sourceTexture->m_ANW.clear();
- GLUtils::deleteTexture(&m_sourceTexture->m_textureId);
-#endif
- }
- delete m_sourceTexture;
- delete m_targetTexture;
-}
-
-
-void SharedTexture::initSourceTexture()
-{
- if (m_sharedTextureMode == SurfaceTextureMode)
- return;
-
- m_display = eglGetCurrentDisplay();
- m_supportsEGLImage = GLUtils::isEGLImageSupported();
- m_supportsEGLFenceSyncKHR = GLUtils::isEGLFenceSyncSupported();
-
- // TODO temporarily disable fence sync until the EGL framework fixes
- // performance issues that result from consistently adding/removing fences.
- m_supportsEGLFenceSyncKHR = false;
-
- LOGI("imageEGL: %d syncKHR: %d", m_supportsEGLImage, m_supportsEGLFenceSyncKHR);
-
- glGenTextures(1, &m_sourceTexture->m_textureId);
-
-}
-
-// For MediaTexture only
-void SharedTexture::deleteSourceTexture()
-{
- if (m_sharedTextureMode == SurfaceTextureMode)
- return;
- // We need to delete the source texture and EGLImage in the thread in which
- // it was created. 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.
- if (m_supportsEGLImage) {
- GLUtils::deleteTexture(&m_sourceTexture->m_textureId);
- if (m_eglImage != EGL_NO_IMAGE_KHR) {
- eglDestroyImageKHR(eglGetCurrentDisplay(), m_eglImage);
- m_eglImage = EGL_NO_IMAGE_KHR;
- m_isNewImage = true;
- }
- LOGI("Deleted Source Texture and EGLImage");
- }
-}
-
-// For MediaTexture only
-void SharedTexture::deleteTargetTexture()
-{
- if (m_sharedTextureMode == SurfaceTextureMode)
- return;
-
- if (m_supportsEGLImage)
- GLUtils::deleteTexture(&m_targetTexture->m_textureId);
- else
- GLUtils::deleteTexture(&m_sourceTexture->m_textureId);
-}
-
-TextureInfo* SharedTexture::lockSource()
-{
- if (m_sharedTextureMode == SurfaceTextureMode)
- return m_sourceTexture;
-
- m_lock.lock();
-
- if (m_supportsEGLFenceSyncKHR && m_syncObject != EGL_NO_SYNC_KHR) {
-
- EGLint status = eglClientWaitSyncKHR(m_display, m_syncObject, 0, 1000000);
-
- if (status == EGL_TIMEOUT_EXPIRED_KHR)
- LOGE("Sync timeout for shared texture (%d)", m_sourceTexture->m_textureId);
-
- eglDestroySyncKHR(m_display, m_syncObject);
- m_syncObject = EGL_NO_SYNC_KHR;
- }
- return m_sourceTexture;
-}
-
-void SharedTexture::releaseSource()
-{
- if (m_sharedTextureMode == SurfaceTextureMode)
- return;
-
- if (m_supportsEGLImage) {
- // delete the existing image if needed
- if (!m_sourceTexture->equalsAttributes(m_targetTexture)) {
- if (m_eglImage != EGL_NO_IMAGE_KHR) {
- eglDestroyImageKHR(m_display, m_eglImage);
- m_eglImage = EGL_NO_IMAGE_KHR;
- m_isNewImage = true;
- }
- m_targetTexture->copyAttributes(m_sourceTexture);
- }
-
- // create an image from the texture, only when the texture is valid
- if (m_eglImage == EGL_NO_IMAGE_KHR && m_sourceTexture->m_width
- && m_sourceTexture->m_height) {
- GLUtils::createEGLImageFromTexture(m_sourceTexture->m_textureId, &m_eglImage);
- ALOGV("Generating Image (%d) 0x%x", m_sourceTexture->m_textureId, m_eglImage);
-
- glFinish(); // ensures the texture is ready to be used by the consumer
- }
-
- } else {
-
- m_targetTexture = m_sourceTexture;
-
- // in the case of shared contexts we must flush the texture edits to the
- // GPU. This ensures the edits complete prior to allowing the texture to
- // be bound on the producers context.
- glFlush();
- }
-
- m_lock.unlock();
-}
-
-TextureInfo* SharedTexture::lockTarget()
-{
- // Note that the source and targe are the same when using Surface Texture.
- if (m_sharedTextureMode == SurfaceTextureMode) {
-#if DEPRECATED_SURFACE_TEXTURE_MODE
- m_sourceTexture->m_surfaceTexture->updateTexImage();
-#endif
- return m_sourceTexture;
- }
-
- m_lock.lock();
-
- if ((!m_supportsEGLImage && m_targetTexture->m_textureId == GL_NO_TEXTURE)
- || (m_supportsEGLImage && m_eglImage == EGL_NO_IMAGE_KHR)) {
- m_lock.unlock();
- return 0;
- }
-
- if (m_supportsEGLImage && (m_isNewImage || m_targetTexture->m_textureId == GL_NO_TEXTURE)) {
- if (m_targetTexture->m_textureId == GL_NO_TEXTURE)
- glGenTextures(1, &m_targetTexture->m_textureId);
-
- GLUtils::createTextureFromEGLImage(m_targetTexture->m_textureId, m_eglImage);
- ALOGV("Generating Consumer Texture from 0x%x", m_eglImage);
- m_isNewImage = false;
- }
- return m_targetTexture;
-}
-
-void SharedTexture::releaseTarget()
-{
- if (m_sharedTextureMode == SurfaceTextureMode)
- return;
-
- if (m_supportsEGLFenceSyncKHR) {
- if (m_syncObject != EGL_NO_SYNC_KHR)
- eglDestroySyncKHR(m_display, m_syncObject);
- m_syncObject = eglCreateSyncKHR(m_display, EGL_SYNC_FENCE_KHR, 0);
- } else {
- // TODO the flush currently prevents the screen from getting partial
- // updates but the only way to guarantee this is to call glFinish. Until
- // we support an EGL sync we will leave flush enable in order to test
- // with modest performance.
- glFlush();
- }
-
- m_lock.unlock();
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/SharedTexture.h b/Source/WebCore/platform/graphics/android/SharedTexture.h
deleted file mode 100644
index 305a442..0000000
--- a/Source/WebCore/platform/graphics/android/SharedTexture.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright 2010, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef SharedTexture_h
-#define SharedTexture_h
-
-#include "TextureInfo.h"
-#include <EGL/egl.h>
-#include <EGL/eglext.h>
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
-#include <utils/threads.h>
-
-namespace WebCore {
-
-/**
- * SharedTexture is a class that encapsulates all the necessary variables
- * needed to share a single texture across threads. In the case that threads
- * communicate using EGL's sharedContext mechanism or do not support the proper
- * EGLImage extensions the targetTexture, eglImage, and isNewImage variables are
- * not used.
- */
-class SharedTexture {
-public:
- // consumer thread functions
- SharedTexture(SharedTextureMode mode);
- ~SharedTexture();
-
- TextureInfo* lockSource();
- void releaseSource();
-
- TextureInfo* lockTarget();
- void releaseTarget();
-
- // these locks are only used for the methods below
- void lock() { m_lock.lock(); }
- void unlock() { m_lock.unlock(); }
-
- void initSourceTexture(); // producer thread only
- void deleteSourceTexture(); // producer thread only
- void deleteTargetTexture(); // consumer thread only
- GLuint getSourceTextureId() { return m_sourceTexture->m_textureId; }
- GLuint getTargetTextureId() { return m_targetTexture->m_textureId; }
- EGLImageKHR getEGLImage() { return m_eglImage; }
-
-private:
- /**
- * The mutex is used to ensure that the contents of the struct are current across
- * threads and that only one thread is manipulating the texture at a given time.
- */
- android::Mutex m_lock;
- /**
- * The texture and its associated metadata that is used by the producer. The
- * texture is created in the producer's thread and can only be read by the
- * consumer when the consumer shares the same context as the producer. The
- * metadata is used to track changes to the texture that would orphan the
- * target texture and require a new EGLImage to be constructed.
- */
- TextureInfo* m_sourceTexture;
- /**
- * The target texture stores the id and metadata of the texture that is to be
- * used by the consumer. In the case where EGLImages are supported this hold
- * the current eglImage target.
- */
- TextureInfo* m_targetTexture;
- /**
- * The EGLImage is used to share the texture between EGLContexts on two
- * different threads. This serves as an alternative to sharing the contexts
- * but is only used if GL and EGL support the required extensions.
- */
- EGLImageKHR m_eglImage;
- /**
- * This flag is used to determine if the eglImage has been updated. This
- * signals the consumer thread to rebind the targetTexture to the new image.
- */
- bool m_isNewImage;
- /**
- * The sync allows the consumer to release the lock prior to the commands
- * executing on the GPU. Prior to releasing the lock the consumer creates
- * a sync object and stores it here. After locking the texture the client
- * must check that the sync has completed prior to manipulating the texture.
- * This value is only used if the proper EGL extensions are supported.
- */
- EGLSyncKHR m_syncObject;
-
- EGLDisplay m_display;
-
- bool m_supportsEGLImage;
- bool m_supportsEGLFenceSyncKHR;
-
- SharedTextureMode m_sharedTextureMode;
-};
-
-} // namespace WebCore
-
-#endif // SharedTexture_h
diff --git a/Source/WebCore/platform/graphics/android/TextureInfo.cpp b/Source/WebCore/platform/graphics/android/TextureInfo.cpp
index 5356dcb..3c4dde2 100644
--- a/Source/WebCore/platform/graphics/android/TextureInfo.cpp
+++ b/Source/WebCore/platform/graphics/android/TextureInfo.cpp
@@ -35,13 +35,12 @@
namespace WebCore {
-TextureInfo::TextureInfo(SharedTextureMode mode)
+TextureInfo::TextureInfo()
{
m_textureId = GL_NO_TEXTURE;
m_width = 0;
m_height = 0;
m_internalFormat = 0;
- m_sharedTextureMode = mode;
m_eglSurface = EGL_NO_SURFACE;
m_pictureCount = 0;
}
diff --git a/Source/WebCore/platform/graphics/android/TextureInfo.h b/Source/WebCore/platform/graphics/android/TextureInfo.h
index 1c48937..8549365 100644
--- a/Source/WebCore/platform/graphics/android/TextureInfo.h
+++ b/Source/WebCore/platform/graphics/android/TextureInfo.h
@@ -34,8 +34,6 @@
#include "BaseTile.h"
using android::sp;
-#define DEPRECATED_SURFACE_TEXTURE_MODE 0
-
namespace android {
class SurfaceTexture;
}
@@ -47,20 +45,14 @@ static const GLuint GL_NO_TEXTURE = 0;
* TextureInfo is a class that stores both the texture and metadata about the
* texture.
*/
-enum SharedTextureMode {
- EglImageMode,
- SurfaceTextureMode
-};
class TextureInfo {
public:
-
- TextureInfo(SharedTextureMode mode);
+ TextureInfo();
bool equalsAttributes(const TextureInfo* otherTexture);
void copyAttributes(const TextureInfo* sourceTexture);
- SharedTextureMode getSharedTextureMode() { return m_sharedTextureMode; }
bool operator==(const TextureInfo& otherTexture);
GLuint m_textureId;
@@ -68,18 +60,12 @@ public:
int32_t m_height;
GLenum m_internalFormat;
- // Surface Texture specific data
-#if DEPRECATED_SURFACE_TEXTURE_MODE
- sp<android::SurfaceTexture> m_surfaceTexture;
-#endif
// TODO: Delete this after the Ganesh code path get fixed.
sp<ANativeWindow> m_ANW;
// The EGLSurface wraps the m_ANW to enable direct OpenGL rendering (e.g. Ganesh)
EGLSurface m_eglSurface;
int m_pictureCount;
-private:
- SharedTextureMode m_sharedTextureMode;
};
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/TilesManager.cpp b/Source/WebCore/platform/graphics/android/TilesManager.cpp
index 42a9a57..e36ba36 100644
--- a/Source/WebCore/platform/graphics/android/TilesManager.cpp
+++ b/Source/WebCore/platform/graphics/android/TilesManager.cpp
@@ -229,9 +229,9 @@ void TilesManager::printTextures()
x = o->x();
y = o->y();
}
- XLOG("[%d] texture %x busy: %d owner: %x (%d, %d) page: %x scale: %.2f",
+ XLOG("[%d] texture %x owner: %x (%d, %d) page: %x scale: %.2f",
i, texture,
- texture->busy(), o, x, y, o ? o->page() : 0, o ? o->scale() : 0);
+ o, x, y, o ? o->page() : 0, o ? o->scale() : 0);
}
XLOG("------");
#endif // DEBUG
@@ -293,12 +293,6 @@ BaseTileTexture* TilesManager::getAvailableTexture(BaseTile* owner)
for (unsigned int i = 0; i < max; i++) {
BaseTileTexture* texture = (*availableTexturePool)[i];
BaseTile* currentOwner = static_cast<BaseTile*>(texture->owner());
-
- if (texture->busy()) {
- // don't bother, since the acquire() will likely fail
- continue;
- }
-
if (!currentOwner) {
// unused texture! take it!
farthestTexture = texture;
diff --git a/Source/WebCore/platform/graphics/android/TilesManager.h b/Source/WebCore/platform/graphics/android/TilesManager.h
index 424e226..396cf93 100644
--- a/Source/WebCore/platform/graphics/android/TilesManager.h
+++ b/Source/WebCore/platform/graphics/android/TilesManager.h
@@ -132,11 +132,6 @@ public:
m_showVisualIndicator = showVisualIndicator;
}
- SharedTextureMode getSharedTextureMode()
- {
- return SurfaceTextureMode;
- }
-
TilesProfiler* getProfiler()
{
return &m_profiler;
diff --git a/Source/WebCore/platform/graphics/android/TransferQueue.h b/Source/WebCore/platform/graphics/android/TransferQueue.h
index 63455de..b33a576 100644
--- a/Source/WebCore/platform/graphics/android/TransferQueue.h
+++ b/Source/WebCore/platform/graphics/android/TransferQueue.h
@@ -32,6 +32,7 @@
#include "BaseTileTexture.h"
#include "ShaderProgram.h"
#include "TiledPage.h"
+#include <EGL/eglext.h>
namespace WebCore {