summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDerek Sollenberger <djsollen@google.com>2011-06-28 11:57:05 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-06-28 11:57:05 -0700
commit097dd53a62b6e981036cd640e9c51d6a3fda769e (patch)
treed0c77958e1bcacf1890cde425e9d633171f27bf0
parente452be1935a2ad2683fb2dc3de631ec063e38dc6 (diff)
parentec182c75fb35d955a9115fbaf516f648a48ed0e1 (diff)
downloadexternal_webkit-097dd53a62b6e981036cd640e9c51d6a3fda769e.zip
external_webkit-097dd53a62b6e981036cd640e9c51d6a3fda769e.tar.gz
external_webkit-097dd53a62b6e981036cd640e9c51d6a3fda769e.tar.bz2
Merge "Cleanup Skia related rendering code for raster rendering."
-rw-r--r--Source/WebCore/Android.mk2
-rw-r--r--Source/WebCore/platform/graphics/android/BaseTile.cpp9
-rw-r--r--Source/WebCore/platform/graphics/android/BaseTile.h10
-rw-r--r--Source/WebCore/platform/graphics/android/BaseTileTexture.cpp (renamed from Source/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.cpp)81
-rw-r--r--Source/WebCore/platform/graphics/android/BaseTileTexture.h (renamed from Source/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.h)22
-rw-r--r--Source/WebCore/platform/graphics/android/GLUtils.cpp51
-rw-r--r--Source/WebCore/platform/graphics/android/GLUtils.h13
-rw-r--r--Source/WebCore/platform/graphics/android/LayerAndroid.cpp21
-rw-r--r--Source/WebCore/platform/graphics/android/LayerAndroid.h4
-rw-r--r--Source/WebCore/platform/graphics/android/LayerTexture.h9
-rw-r--r--Source/WebCore/platform/graphics/android/RasterRenderer.cpp6
-rw-r--r--Source/WebCore/platform/graphics/android/RasterRenderer.h6
-rw-r--r--Source/WebCore/platform/graphics/android/TextureOwner.h4
-rw-r--r--Source/WebCore/platform/graphics/android/TilesManager.cpp24
-rw-r--r--Source/WebCore/platform/graphics/android/TilesManager.h7
15 files changed, 108 insertions, 161 deletions
diff --git a/Source/WebCore/Android.mk b/Source/WebCore/Android.mk
index efdfc42..4673b45 100644
--- a/Source/WebCore/Android.mk
+++ b/Source/WebCore/Android.mk
@@ -632,9 +632,9 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
platform/graphics/WidthIterator.cpp \
\
platform/graphics/android/AndroidAnimation.cpp \
- platform/graphics/android/BackedDoubleBufferedTexture.cpp \
platform/graphics/android/BaseLayerAndroid.cpp \
platform/graphics/android/BaseTile.cpp \
+ platform/graphics/android/BaseTileTexture.cpp \
platform/graphics/android/BitmapAllocatorAndroid.cpp \
platform/graphics/android/ClassTracker.cpp \
platform/graphics/android/DoubleBufferedTexture.cpp \
diff --git a/Source/WebCore/platform/graphics/android/BaseTile.cpp b/Source/WebCore/platform/graphics/android/BaseTile.cpp
index 4515083..7020208 100644
--- a/Source/WebCore/platform/graphics/android/BaseTile.cpp
+++ b/Source/WebCore/platform/graphics/android/BaseTile.cpp
@@ -95,7 +95,7 @@ void BaseTile::setContents(TiledPage* page, int x, int y)
void BaseTile::reserveTexture()
{
- BackedDoubleBufferedTexture* texture = TilesManager::instance()->getAvailableTexture(this);
+ BaseTileTexture* texture = TilesManager::instance()->getAvailableTexture(this);
android::AutoMutex lock(m_atomicSync);
if (texture && m_texture != texture) {
@@ -105,7 +105,7 @@ void BaseTile::reserveTexture()
}
}
-bool BaseTile::removeTexture(BackedDoubleBufferedTexture* texture)
+bool BaseTile::removeTexture(BaseTileTexture* texture)
{
XLOG("%x removeTexture res: %x... page %x", this, m_texture, m_page);
// We update atomically, so paintBitmap() can see the correct value
@@ -254,7 +254,7 @@ void BaseTile::paintBitmap()
// can be updated by other threads without consequence.
m_atomicSync.lock();
bool dirty = m_dirty;
- BackedDoubleBufferedTexture* texture = m_texture;
+ BaseTileTexture* texture = m_texture;
SkRegion dirtyArea = *m_currentDirtyArea;
float scale = m_scale;
const int x = m_x;
@@ -289,7 +289,8 @@ void BaseTile::paintBitmap()
// TODO: Implement the partial invalidate in Surface Texture Mode
if (((m_currentDirtyArea == &m_dirtyAreaA) && m_fullRepaintA)
|| ((m_currentDirtyArea == &m_dirtyAreaB) && m_fullRepaintB)
- || !GLUtils::textureExist(textureInfo, texture->bitmap())
+ || textureInfo->m_width != tileWidth
+ || textureInfo->m_height != tileHeight
|| textureInfo->getSharedTextureMode() == SurfaceTextureMode) {
fullRepaint = true;
}
diff --git a/Source/WebCore/platform/graphics/android/BaseTile.h b/Source/WebCore/platform/graphics/android/BaseTile.h
index f58a598..cddaa60 100644
--- a/Source/WebCore/platform/graphics/android/BaseTile.h
+++ b/Source/WebCore/platform/graphics/android/BaseTile.h
@@ -39,7 +39,7 @@ namespace WebCore {
class TextureInfo;
class TiledPage;
-class BackedDoubleBufferedTexture;
+class BaseTileTexture;
/**
* An individual tile that is used to construct part of a webpage's BaseLayer of
@@ -74,7 +74,7 @@ public:
// the only thread-safe function called by the background thread
void paintBitmap();
int paintPartialBitmap(SkIRect rect, float tx, float ty,
- float scale, BackedDoubleBufferedTexture* texture,
+ float scale, BaseTileTexture* texture,
TextureInfo* textureInfo,
TiledPage* tiledPage,
bool fullRepaint = false);
@@ -92,10 +92,10 @@ public:
int x() const { return m_x; }
int y() const { return m_y; }
unsigned int lastPaintedPicture() const { return m_lastPaintedPicture; }
- BackedDoubleBufferedTexture* texture() { return m_texture; }
+ BaseTileTexture* texture() { return m_texture; }
// TextureOwner implementation
- virtual bool removeTexture(BackedDoubleBufferedTexture* texture);
+ virtual bool removeTexture(BaseTileTexture* texture);
virtual TiledPage* page() { return m_page; }
private:
@@ -105,7 +105,7 @@ private:
int m_y;
// The remaining variables can be updated throughout the lifetime of the object
- BackedDoubleBufferedTexture* m_texture;
+ BaseTileTexture* m_texture;
float m_scale;
// used to signal that the that the tile is out-of-date and needs to be redrawn
bool m_dirty;
diff --git a/Source/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.cpp b/Source/WebCore/platform/graphics/android/BaseTileTexture.cpp
index 0e22103..ee8cebf 100644
--- a/Source/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.cpp
+++ b/Source/WebCore/platform/graphics/android/BaseTileTexture.cpp
@@ -24,7 +24,7 @@
*/
#include "config.h"
-#include "BackedDoubleBufferedTexture.h"
+#include "BaseTileTexture.h"
#include "BaseTile.h"
#include "ClassTracker.h"
@@ -33,65 +33,38 @@
#include "TilesManager.h"
#define LOG_NDEBUG 1
-#define LOG_TAG "BackedDoubleBufferedTexture.cpp"
+#define LOG_TAG "BaseTileTexture.cpp"
#include <utils/Log.h>
namespace WebCore {
-BackedDoubleBufferedTexture::BackedDoubleBufferedTexture(uint32_t w, uint32_t h,
- SkBitmap* bitmap,
- SkBitmap::Config config)
+BaseTileTexture::BaseTileTexture(uint32_t w, uint32_t h)
: DoubleBufferedTexture(eglGetCurrentContext(), SurfaceTextureMode)
, m_usedLevel(-1)
- , m_config(config)
, m_owner(0)
, m_delayedReleaseOwner(0)
, m_delayedRelease(false)
, m_busy(false)
{
m_size.set(w, h);
- if (bitmap) {
- m_bitmap = bitmap;
- m_sharedBitmap = true;
- m_canvas = new SkCanvas(*m_bitmap);
- } else {
- m_bitmap = 0;
- m_sharedBitmap = false;
- m_canvas = 0;
- }
#ifdef DEBUG_COUNT
- ClassTracker::instance()->increment("BackedDoubleBufferedTexture");
+ ClassTracker::instance()->increment("BaseTileTexture");
#endif
}
-SkCanvas* BackedDoubleBufferedTexture::canvas()
-{
- if (!m_bitmap && !m_sharedBitmap) {
- m_bitmap = new SkBitmap();
- m_bitmap->setConfig(m_config, m_size.width(), m_size.height());
- m_bitmap->allocPixels();
- m_bitmap->eraseColor(0);
- m_canvas = new SkCanvas(*m_bitmap);
- }
- return m_canvas;
-}
-
-BackedDoubleBufferedTexture::~BackedDoubleBufferedTexture()
+BaseTileTexture::~BaseTileTexture()
{
- if (!m_sharedBitmap)
- delete m_bitmap;
- delete m_canvas;
if (m_sharedTextureMode == EglImageMode) {
SharedTexture* textures[3] = { m_textureA, m_textureB, 0 };
destroyTextures(textures);
}
#ifdef DEBUG_COUNT
- ClassTracker::instance()->decrement("BackedDoubleBufferedTexture");
+ ClassTracker::instance()->decrement("BaseTileTexture");
#endif
}
-void BackedDoubleBufferedTexture::destroyTextures(SharedTexture** textures)
+void BaseTileTexture::destroyTextures(SharedTexture** textures)
{
int x = 0;
while (textures[x]) {
@@ -108,7 +81,7 @@ void BackedDoubleBufferedTexture::destroyTextures(SharedTexture** textures)
}
}
-TextureInfo* BackedDoubleBufferedTexture::producerLock()
+TextureInfo* BaseTileTexture::producerLock()
{
m_busyLock.lock();
m_busy = true;
@@ -116,19 +89,19 @@ TextureInfo* BackedDoubleBufferedTexture::producerLock()
return DoubleBufferedTexture::producerLock();
}
-void BackedDoubleBufferedTexture::producerRelease()
+void BaseTileTexture::producerRelease()
{
DoubleBufferedTexture::producerRelease();
setNotBusy();
}
-void BackedDoubleBufferedTexture::producerReleaseAndSwap()
+void BaseTileTexture::producerReleaseAndSwap()
{
DoubleBufferedTexture::producerReleaseAndSwap();
setNotBusy();
}
-void BackedDoubleBufferedTexture::setNotBusy()
+void BaseTileTexture::setNotBusy()
{
android::Mutex::Autolock lock(m_busyLock);
m_busy = false;
@@ -142,36 +115,26 @@ void BackedDoubleBufferedTexture::setNotBusy()
m_busyCond.signal();
}
-bool BackedDoubleBufferedTexture::busy()
+bool BaseTileTexture::busy()
{
android::Mutex::Autolock lock(m_busyLock);
return m_busy;
}
-void BackedDoubleBufferedTexture::producerUpdate(TextureInfo* textureInfo)
+void BaseTileTexture::producerUpdate(TextureInfo* textureInfo, const SkBitmap& bitmap)
{
- if (!m_bitmap)
- return;
-
// no need to upload a texture since the bitmap is empty
- if (!m_bitmap->width() && !m_bitmap->height()) {
+ if (!bitmap.width() && !bitmap.height()) {
producerRelease();
return;
}
- GLUtils::paintTextureWithBitmap(textureInfo, m_bitmap, 0, 0, this);
-
- if (!m_sharedBitmap) {
- delete m_bitmap;
- delete m_canvas;
- m_bitmap = 0;
- m_canvas = 0;
- }
+ GLUtils::paintTextureWithBitmap(textureInfo, m_size, bitmap, 0, 0);
producerReleaseAndSwap();
}
-bool BackedDoubleBufferedTexture::acquire(TextureOwner* owner, bool force)
+bool BaseTileTexture::acquire(TextureOwner* owner, bool force)
{
if (m_owner == owner) {
if (m_delayedRelease) {
@@ -184,7 +147,7 @@ bool BackedDoubleBufferedTexture::acquire(TextureOwner* owner, bool force)
return setOwner(owner, force);
}
-bool BackedDoubleBufferedTexture::tryAcquire(TextureOwner* owner, TiledPage* currentPage, TiledPage* nextPage)
+bool BaseTileTexture::tryAcquire(TextureOwner* owner, TiledPage* currentPage, TiledPage* nextPage)
{
m_busyLock.lock();
if (!m_busy
@@ -198,7 +161,7 @@ bool BackedDoubleBufferedTexture::tryAcquire(TextureOwner* owner, TiledPage* cur
return false;
}
-bool BackedDoubleBufferedTexture::setOwner(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
@@ -215,7 +178,7 @@ bool BackedDoubleBufferedTexture::setOwner(TextureOwner* owner, bool force)
// 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
- // BackedDoubleBufferedTexture::release(), which will then do nothing
+ // 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)
@@ -229,7 +192,7 @@ bool BackedDoubleBufferedTexture::setOwner(TextureOwner* owner, bool force)
return false;
}
-bool BackedDoubleBufferedTexture::release(TextureOwner* owner)
+bool BaseTileTexture::release(TextureOwner* owner)
{
android::Mutex::Autolock lock(m_busyLock);
if (m_owner != owner)
@@ -244,7 +207,7 @@ bool BackedDoubleBufferedTexture::release(TextureOwner* owner)
return true;
}
-void BackedDoubleBufferedTexture::setTile(TextureInfo* info, int x, int y,
+void BaseTileTexture::setTile(TextureInfo* info, int x, int y,
float scale, unsigned int pictureCount)
{
TextureTileInfo* textureInfo = m_texturesInfo.get(getWriteableTexture());
@@ -258,7 +221,7 @@ void BackedDoubleBufferedTexture::setTile(TextureInfo* info, int x, int y,
m_texturesInfo.set(getWriteableTexture(), textureInfo);
}
-bool BackedDoubleBufferedTexture::readyFor(BaseTile* baseTile)
+bool BaseTileTexture::readyFor(BaseTile* baseTile)
{
TextureTileInfo* info = m_texturesInfo.get(getReadableTexture());
if (info &&
diff --git a/Source/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.h b/Source/WebCore/platform/graphics/android/BaseTileTexture.h
index 89ea771..0a7534a 100644
--- a/Source/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.h
+++ b/Source/WebCore/platform/graphics/android/BaseTileTexture.h
@@ -23,8 +23,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef BackedDoubleBufferedTexture_h
-#define BackedDoubleBufferedTexture_h
+#ifndef BaseTileTexture_h
+#define BaseTileTexture_h
#include "DoubleBufferedTexture.h"
#include "GLWebViewState.h"
@@ -57,14 +57,12 @@ class TextureTileInfo {
};
// DoubleBufferedTexture using a SkBitmap as backing mechanism
-class BackedDoubleBufferedTexture : public DoubleBufferedTexture {
+class BaseTileTexture : public DoubleBufferedTexture {
public:
// This object is to be constructed on the consumer's thread and must have
// a width and height greater than 0.
- BackedDoubleBufferedTexture(uint32_t w, uint32_t h,
- SkBitmap* bitmap = 0,
- SkBitmap::Config config = SkBitmap::kARGB_8888_Config);
- virtual ~BackedDoubleBufferedTexture();
+ BaseTileTexture(uint32_t w, uint32_t h);
+ virtual ~BaseTileTexture();
// these functions override their parent
virtual TextureInfo* producerLock();
@@ -73,8 +71,7 @@ public:
// updates the texture with current bitmap and releases (and if needed also
// swaps) the texture.
- virtual void producerUpdate(TextureInfo* textureInfo);
- void producerUpdate(TextureInfo* textureInfo, SkBitmap* bitmap, SkIRect& rect);
+ virtual void producerUpdate(TextureInfo* textureInfo, const SkBitmap& bitmap);
// The level can be one of the following values:
// * -1 for an unused texture.
@@ -97,8 +94,6 @@ public:
// private member accessor functions
TextureOwner* owner() { return m_owner; } // only used by the consumer thread
TextureOwner* delayedReleaseOwner() { return m_delayedReleaseOwner; }
- SkCanvas* canvas(); // only used by the producer thread
- SkBitmap* bitmap() { return m_bitmap; }
bool busy();
void setNotBusy();
@@ -114,10 +109,7 @@ protected:
private:
void destroyTextures(SharedTexture** textures);
- SkBitmap* m_bitmap;
- bool m_sharedBitmap;
SkSize m_size;
- SkCanvas* m_canvas;
int m_usedLevel;
SkBitmap::Config m_config;
TextureOwner* m_owner;
@@ -142,4 +134,4 @@ private:
} // namespace WebCore
-#endif // BackedDoubleBufferedTexture_h
+#endif // BaseTileTexture_h
diff --git a/Source/WebCore/platform/graphics/android/GLUtils.cpp b/Source/WebCore/platform/graphics/android/GLUtils.cpp
index 29608cf..e32f1e9 100644
--- a/Source/WebCore/platform/graphics/android/GLUtils.cpp
+++ b/Source/WebCore/platform/graphics/android/GLUtils.cpp
@@ -336,45 +336,36 @@ GLuint GLUtils::createSampleTexture()
return texture;
}
-bool GLUtils::textureExist(TextureInfo* textureInfo, const SkBitmap* bitmap)
-{
- if (!bitmap)
- return false;
-
- if (!bitmap->width() || !bitmap->height())
- return false;
-
- if (textureInfo->m_width == bitmap->width()
- && textureInfo->m_height == bitmap->height())
- return true;
-
- return false;
-}
-
void GLUtils::paintTextureWithBitmap(TextureInfo* textureInfo,
- SkBitmap* bitmap,
- int x,
- int y,
- BackedDoubleBufferedTexture* texture)
+ const SkSize& requiredSize,
+ const SkBitmap& bitmap,
+ int x, int y)
{
SharedTextureMode mode = textureInfo->getSharedTextureMode();
- if (textureExist(textureInfo, texture->bitmap())) {
+ if (requiredSize.equals(textureInfo->m_width, textureInfo->m_height)) {
if (mode == EglImageMode)
- GLUtils::updateTextureWithBitmap(textureInfo->m_textureId, x, y, *bitmap);
+ GLUtils::updateTextureWithBitmap(textureInfo->m_textureId, x, y, bitmap);
else if (mode == SurfaceTextureMode)
- GLUtils::updateSurfaceTextureWithBitmap(textureInfo, x, y, *bitmap);
+ GLUtils::updateSurfaceTextureWithBitmap(textureInfo, 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());
+ }
+
if (mode == EglImageMode)
- GLUtils::createTextureWithBitmap(textureInfo->m_textureId, *bitmap);
+ GLUtils::createTextureWithBitmap(textureInfo->m_textureId, bitmap);
else if (mode == SurfaceTextureMode)
- GLUtils::createSurfaceTextureWithBitmap(textureInfo, *bitmap);
+ GLUtils::createSurfaceTextureWithBitmap(textureInfo, bitmap);
- textureInfo->m_width = bitmap->width();
- textureInfo->m_height = bitmap->height();
+ textureInfo->m_width = bitmap.width();
+ textureInfo->m_height = bitmap.height();
}
}
-void GLUtils::createSurfaceTextureWithBitmap(TextureInfo* texture, SkBitmap& bitmap, GLint filter)
+void GLUtils::createSurfaceTextureWithBitmap(TextureInfo* texture, const SkBitmap& bitmap, GLint filter)
{
sp<android::SurfaceTexture> surfaceTexture = texture->m_surfaceTexture;
sp<ANativeWindow> ANW = texture->m_ANW;
@@ -394,7 +385,7 @@ void GLUtils::createSurfaceTextureWithBitmap(TextureInfo* texture, SkBitmap& bit
updateSurfaceTextureWithBitmap(texture, 0, 0, bitmap, filter);
}
-void GLUtils::updateSurfaceTextureWithBitmap(TextureInfo* texture, int x, int y, SkBitmap& bitmap, GLint filter)
+void GLUtils::updateSurfaceTextureWithBitmap(TextureInfo* texture, int x, int y, const SkBitmap& bitmap, GLint filter)
{
sp<android::SurfaceTexture> surfaceTexture = texture->m_surfaceTexture;
sp<ANativeWindow> ANW = texture->m_ANW;
@@ -431,7 +422,7 @@ void GLUtils::updateSurfaceTextureWithBitmap(TextureInfo* texture, int x, int y,
checkSurfaceTextureError("queueBuffer", status);
}
-void GLUtils::createTextureWithBitmap(GLuint texture, SkBitmap& bitmap, GLint filter)
+void GLUtils::createTextureWithBitmap(GLuint texture, const SkBitmap& bitmap, GLint filter)
{
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glBindTexture(GL_TEXTURE_2D, texture);
@@ -462,7 +453,7 @@ void GLUtils::createTextureWithBitmap(GLuint texture, SkBitmap& bitmap, GLint fi
glDeleteFramebuffers(1, &fboID);
}
-void GLUtils::updateTextureWithBitmap(GLuint texture, int x, int y, SkBitmap& bitmap, GLint filter)
+void GLUtils::updateTextureWithBitmap(GLuint texture, int x, int y, const SkBitmap& bitmap, GLint filter)
{
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glBindTexture(GL_TEXTURE_2D, texture);
diff --git a/Source/WebCore/platform/graphics/android/GLUtils.h b/Source/WebCore/platform/graphics/android/GLUtils.h
index 85656f1..a015136 100644
--- a/Source/WebCore/platform/graphics/android/GLUtils.h
+++ b/Source/WebCore/platform/graphics/android/GLUtils.h
@@ -28,9 +28,9 @@
#if USE(ACCELERATED_COMPOSITING)
-#include "BackedDoubleBufferedTexture.h"
#include "SkBitmap.h"
#include "SkMatrix.h"
+#include "SkSize.h"
#include "TextureInfo.h"
#include "TransformationMatrix.h"
#include <EGL/egl.h>
@@ -64,16 +64,15 @@ public:
static void deleteTexture(GLuint* texture);
static GLuint createSampleColorTexture(int r, int g, int b);
static GLuint createSampleTexture();
- static void createTextureWithBitmap(GLuint texture, SkBitmap& bitmap, GLint filter = GL_LINEAR);
- static void updateTextureWithBitmap(GLuint texture, int x, int y, SkBitmap& bitmap, GLint filter = GL_LINEAR);
+ static void createTextureWithBitmap(GLuint texture, const SkBitmap& bitmap, GLint filter = GL_LINEAR);
+ static void updateTextureWithBitmap(GLuint texture, int x, int y, const SkBitmap& bitmap, GLint filter = GL_LINEAR);
static void createEGLImageFromTexture(GLuint texture, EGLImageKHR* image);
static void createTextureFromEGLImage(GLuint texture, EGLImageKHR image, GLint filter = GL_LINEAR);
- static bool textureExist(TextureInfo* textureInfo, const SkBitmap* bitmap);
- static void paintTextureWithBitmap(TextureInfo* textureInfo, SkBitmap* bitmap, int x, int y, BackedDoubleBufferedTexture* texture);
+ static void paintTextureWithBitmap(TextureInfo* textureInfo, const SkSize& requiredSize, const SkBitmap& bitmap, int x, int y);
- static void createSurfaceTextureWithBitmap(TextureInfo* texture, SkBitmap& bitmap, GLint filter = GL_LINEAR);
- static void updateSurfaceTextureWithBitmap(TextureInfo* texture, int x, int y, SkBitmap& bitmap, GLint filter = GL_LINEAR);
+ static void createSurfaceTextureWithBitmap(TextureInfo* texture, const SkBitmap& bitmap, GLint filter = GL_LINEAR);
+ static void updateSurfaceTextureWithBitmap(TextureInfo* texture, int x, int y, const SkBitmap& bitmap, GLint filter = GL_LINEAR);
};
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/LayerAndroid.cpp b/Source/WebCore/platform/graphics/android/LayerAndroid.cpp
index 74b246f..e90829a 100644
--- a/Source/WebCore/platform/graphics/android/LayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/LayerAndroid.cpp
@@ -163,7 +163,7 @@ LayerAndroid::LayerAndroid(SkPicture* picture) : SkLayer(),
#endif
}
-bool LayerAndroid::removeTexture(BackedDoubleBufferedTexture* aTexture)
+bool LayerAndroid::removeTexture(BaseTileTexture* aTexture)
{
LayerTexture* texture = static_cast<LayerTexture*>(aTexture);
android::AutoMutex lock(m_atomicSync);
@@ -1051,14 +1051,21 @@ void LayerAndroid::paintBitmapGL()
}
XLOG("LayerAndroid %d %x (%.2f, %.2f) paintBitmapGL WE ARE PAINTING", uniqueId(), this, getWidth(), getHeight());
- SkCanvas* canvas = texture->canvas();
+
+ SkBitmap bitmap;
+ bitmap.setConfig(SkBitmap::kARGB_8888_Config, texture->getSize().width(), texture->getSize().height());
+ bitmap.allocPixels();
+
+ SkCanvas canvas(bitmap);
+ canvas.drawARGB(0, 0, 0, 0, SkXfermode::kClear_Mode);
+
float scale = texture->scale();
IntRect textureRect = texture->rect();
- canvas->drawARGB(0, 0, 0, 0, SkXfermode::kClear_Mode);
+
if (m_contentsImage) {
- contentDraw(canvas);
+ contentDraw(&canvas);
} else {
SkPicture picture;
SkCanvas* nCanvas = picture.beginRecording(textureRect.width(),
@@ -1067,9 +1074,9 @@ void LayerAndroid::paintBitmapGL()
nCanvas->translate(-textureRect.x(), -textureRect.y());
contentDraw(nCanvas);
picture.endRecording();
- picture.draw(canvas);
+ picture.draw(&canvas);
}
- extraDraw(canvas);
+ extraDraw(&canvas);
m_atomicSync.lock();
texture->setTextureInfoFor(this);
@@ -1078,7 +1085,7 @@ void LayerAndroid::paintBitmapGL()
m_requestSent = false;
XLOG("LayerAndroid %d paintBitmapGL PAINTING DONE, updating the texture", uniqueId());
- texture->producerUpdate(textureInfo);
+ texture->producerUpdate(textureInfo, bitmap);
m_atomicSync.unlock();
diff --git a/Source/WebCore/platform/graphics/android/LayerAndroid.h b/Source/WebCore/platform/graphics/android/LayerAndroid.h
index fe41e35..551e020 100644
--- a/Source/WebCore/platform/graphics/android/LayerAndroid.h
+++ b/Source/WebCore/platform/graphics/android/LayerAndroid.h
@@ -84,7 +84,7 @@ struct SkLength {
namespace WebCore {
class AndroidAnimation;
-class BackedDoubleBufferedTexture;
+class BaseTileTexture;
class LayerAndroidFindState;
class RenderLayer;
class TiledPage;
@@ -98,7 +98,7 @@ public:
virtual ~LayerAndroid();
// TextureOwner methods
- virtual bool removeTexture(BackedDoubleBufferedTexture* texture);
+ virtual bool removeTexture(BaseTileTexture* texture);
LayerTexture* texture() { return m_reservedTexture; }
virtual TiledPage* page() { return 0; }
diff --git a/Source/WebCore/platform/graphics/android/LayerTexture.h b/Source/WebCore/platform/graphics/android/LayerTexture.h
index be3594f..7a6c369 100644
--- a/Source/WebCore/platform/graphics/android/LayerTexture.h
+++ b/Source/WebCore/platform/graphics/android/LayerTexture.h
@@ -26,17 +26,16 @@
#ifndef LayerTexture_h
#define LayerTexture_h
-#include "BackedDoubleBufferedTexture.h"
+#include "BaseTileTexture.h"
#include "ClassTracker.h"
#include "IntRect.h"
namespace WebCore {
-class LayerTexture : public BackedDoubleBufferedTexture {
+class LayerTexture : public BaseTileTexture {
public:
- LayerTexture(uint32_t w, uint32_t h,
- SkBitmap::Config config = SkBitmap::kARGB_8888_Config)
- : BackedDoubleBufferedTexture(w, h, 0, config)
+ LayerTexture(uint32_t w, uint32_t h)
+ : BaseTileTexture(w, h)
, m_layerId(0)
, m_scale(1)
, m_ready(false)
diff --git a/Source/WebCore/platform/graphics/android/RasterRenderer.cpp b/Source/WebCore/platform/graphics/android/RasterRenderer.cpp
index 04eae7c..c1fcbcb 100644
--- a/Source/WebCore/platform/graphics/android/RasterRenderer.cpp
+++ b/Source/WebCore/platform/graphics/android/RasterRenderer.cpp
@@ -87,7 +87,7 @@ RasterRenderer::~RasterRenderer()
}
void RasterRenderer::drawTileInfo(SkCanvas* canvas,
- BackedDoubleBufferedTexture* texture,
+ BaseTileTexture* texture,
TiledPage* tiledPage,
int x, int y, float scale,
int pictureCount)
@@ -120,7 +120,7 @@ void RasterRenderer::drawTileInfo(SkCanvas* canvas,
}
int RasterRenderer::renderContent(int x, int y, SkIRect rect, float tx, float ty,
- float scale, BackedDoubleBufferedTexture* texture,
+ float scale, BaseTileTexture* texture,
TextureInfo* textureInfo,
TiledPage* tiledPage, bool fullRepaint)
{
@@ -177,7 +177,7 @@ int RasterRenderer::renderContent(int x, int y, SkIRect rect, float tx, float ty
if (measurePerf)
m_perfMon.start(TAG_UPDATE_TEXTURE);
- GLUtils::paintTextureWithBitmap(textureInfo, &bitmap, rect.fLeft, rect.fTop, texture);
+ GLUtils::paintTextureWithBitmap(textureInfo, texture->getSize(), bitmap, rect.fLeft, rect.fTop);
if (measurePerf)
m_perfMon.stop(TAG_UPDATE_TEXTURE);
diff --git a/Source/WebCore/platform/graphics/android/RasterRenderer.h b/Source/WebCore/platform/graphics/android/RasterRenderer.h
index 88832f6..efe1bd8 100644
--- a/Source/WebCore/platform/graphics/android/RasterRenderer.h
+++ b/Source/WebCore/platform/graphics/android/RasterRenderer.h
@@ -35,7 +35,7 @@ class SkCanvas;
namespace WebCore {
-class BackedDoubleBufferedTexture;
+class BaseTileTexture;
class TextureInfo;
class TiledPage;
@@ -48,12 +48,12 @@ public:
~RasterRenderer();
void drawTileInfo(SkCanvas* canvas,
- BackedDoubleBufferedTexture* texture,
+ BaseTileTexture* texture,
TiledPage* tiledPage,
int x, int y, float scale, int pictureCount);
int renderContent(int x, int y, SkIRect rect, float tx, float ty,
- float scale, BackedDoubleBufferedTexture* texture,
+ float scale, BaseTileTexture* texture,
TextureInfo* textureInfo,
TiledPage* tiledPage,
bool fullRepaint);
diff --git a/Source/WebCore/platform/graphics/android/TextureOwner.h b/Source/WebCore/platform/graphics/android/TextureOwner.h
index aebbf90..bd3a291 100644
--- a/Source/WebCore/platform/graphics/android/TextureOwner.h
+++ b/Source/WebCore/platform/graphics/android/TextureOwner.h
@@ -29,12 +29,12 @@
namespace WebCore {
class TiledPage;
-class BackedDoubleBufferedTexture;
+class BaseTileTexture;
class TextureOwner {
public:
virtual ~TextureOwner() { }
- virtual bool removeTexture(BackedDoubleBufferedTexture* texture) = 0;
+ virtual bool removeTexture(BaseTileTexture* texture) = 0;
virtual TiledPage* page() = 0;
};
diff --git a/Source/WebCore/platform/graphics/android/TilesManager.cpp b/Source/WebCore/platform/graphics/android/TilesManager.cpp
index 0e91dc7..b4df0a1 100644
--- a/Source/WebCore/platform/graphics/android/TilesManager.cpp
+++ b/Source/WebCore/platform/graphics/android/TilesManager.cpp
@@ -96,10 +96,6 @@ TilesManager::TilesManager()
{
XLOG("TilesManager ctor");
m_textures.reserveCapacity(MAX_TEXTURE_ALLOCATION);
- m_tilesBitmap = new SkBitmap();
- m_tilesBitmap->setConfig(SkBitmap::kARGB_8888_Config, tileWidth(), tileHeight());
- m_tilesBitmap->allocPixels();
- m_tilesBitmap->eraseColor(0);
m_pixmapsGenerationThread = new TexturesGenerator();
m_pixmapsGenerationThread->run("TexturesGenerator");
}
@@ -110,12 +106,12 @@ void TilesManager::allocateTiles()
XLOG("%d tiles to allocate (%d textures planned)", nbTexturesToAllocate, m_maxTextureCount);
int nbTexturesAllocated = 0;
for (int i = 0; i < nbTexturesToAllocate; i++) {
- BackedDoubleBufferedTexture* texture = new BackedDoubleBufferedTexture(
- tileWidth(), tileHeight(), m_tilesBitmap);
+ BaseTileTexture* texture = new BaseTileTexture(
+ tileWidth(), tileHeight());
// the atomic load ensures that the texture has been fully initialized
// before we pass a pointer for other threads to operate on
- BackedDoubleBufferedTexture* loadedTexture =
- reinterpret_cast<BackedDoubleBufferedTexture*>(
+ BaseTileTexture* loadedTexture =
+ reinterpret_cast<BaseTileTexture*>(
android_atomic_acquire_load(reinterpret_cast<int32_t*>(&texture)));
m_textures.append(loadedTexture);
nbTexturesAllocated++;
@@ -128,7 +124,7 @@ void TilesManager::printTextures()
#ifdef DEBUG
XLOG("++++++");
for (unsigned int i = 0; i < m_textures.size(); i++) {
- BackedDoubleBufferedTexture* texture = m_textures[i];
+ BaseTileTexture* texture = m_textures[i];
BaseTile* o = 0;
if (texture->owner())
o = (BaseTile*) texture->owner();
@@ -150,7 +146,7 @@ void TilesManager::resetTextureUsage(TiledPage* page)
{
android::Mutex::Autolock lock(m_texturesLock);
for (unsigned int i = 0; i < m_textures.size(); i++) {
- BackedDoubleBufferedTexture* texture = m_textures[i];
+ BaseTileTexture* texture = m_textures[i];
TextureOwner* owner = texture->owner();
if (owner) {
if (owner->page() == page)
@@ -159,7 +155,7 @@ void TilesManager::resetTextureUsage(TiledPage* page)
}
}
-BackedDoubleBufferedTexture* TilesManager::getAvailableTexture(BaseTile* owner)
+BaseTileTexture* TilesManager::getAvailableTexture(BaseTile* owner)
{
android::Mutex::Autolock lock(m_texturesLock);
@@ -177,11 +173,11 @@ BackedDoubleBufferedTexture* TilesManager::getAvailableTexture(BaseTile* owner)
// 3. return any texture not used by the tile's page or the page's sibiling
//
// The texture level indicates a tiles closeness to the current viewport
- BackedDoubleBufferedTexture* farthestTexture = 0;
+ BaseTileTexture* farthestTexture = 0;
int farthestTextureLevel = 0;
const unsigned int max = m_textures.size();
for (unsigned int i = 0; i < max; i++) {
- BackedDoubleBufferedTexture* texture = m_textures[i];
+ BaseTileTexture* texture = m_textures[i];
if (texture->usedLevel() == -1) { // found an unused texture, grab it
farthestTexture = texture;
break;
@@ -204,7 +200,7 @@ BackedDoubleBufferedTexture* TilesManager::getAvailableTexture(BaseTile* owner)
TiledPage* currentPage = owner->page();
TiledPage* nextPage = currentPage->sibling();
for (unsigned int i = 0; i < max; i++) {
- BackedDoubleBufferedTexture* texture = m_textures[i];
+ BaseTileTexture* texture = m_textures[i];
if (texture->tryAcquire(owner, currentPage, nextPage)) {
XLOG("grab a texture that wasn't ours, (%x != %x) at %d => texture %x",
owner->page(), texture->owner()->page(), i, texture);
diff --git a/Source/WebCore/platform/graphics/android/TilesManager.h b/Source/WebCore/platform/graphics/android/TilesManager.h
index e43afed..5237c14 100644
--- a/Source/WebCore/platform/graphics/android/TilesManager.h
+++ b/Source/WebCore/platform/graphics/android/TilesManager.h
@@ -28,8 +28,8 @@
#if USE(ACCELERATED_COMPOSITING)
-#include "BackedDoubleBufferedTexture.h"
#include "BaseTile.h"
+#include "BaseTileTexture.h"
#include "LayerAndroid.h"
#include "LayerTexture.h"
#include "ShaderProgram.h"
@@ -79,7 +79,7 @@ public:
ShaderProgram* shader() { return &m_shader; }
VideoLayerManager* videoLayerManager() { return &m_videoLayerManager; }
- BackedDoubleBufferedTexture* getAvailableTexture(BaseTile* owner);
+ BaseTileTexture* getAvailableTexture(BaseTile* owner);
void printLayersTextures(const char* s);
void cleanupLayersTextures(LayerAndroid* layer, bool forceCleanup = false);
@@ -134,7 +134,7 @@ private:
m_generatorReadyCond.wait(m_generatorLock);
}
- Vector<BackedDoubleBufferedTexture*> m_textures;
+ Vector<BaseTileTexture*> m_textures;
Vector<LayerTexture*> m_layersTextures;
unsigned int m_layersMemoryUsage;
@@ -156,7 +156,6 @@ private:
ShaderProgram m_shader;
VideoLayerManager m_videoLayerManager;
- SkBitmap* m_tilesBitmap;
};
} // namespace WebCore