webkit: changes for skia update
*Commit 1 of 2*
Skia API changes as a result of an update to the Skia library.
These changes are required to work with r3022 of Skia
Change-Id: I4d4a13bad9acc54934bbb46bdfc08ee424c7a33a
*Commit 2 of 2*
Update WebKit with necessary changes for the Skia merge.
This CL address the modifications needed for r3312 of Skia
Change-Id: I0574657e7a84e53c6b92cefbe07668e9467880db
diff --git a/Source/WebCore/platform/graphics/android/BaseLayerAndroid.h b/Source/WebCore/platform/graphics/android/BaseLayerAndroid.h
index c5ce52f..f0c2766 100644
--- a/Source/WebCore/platform/graphics/android/BaseLayerAndroid.h
+++ b/Source/WebCore/platform/graphics/android/BaseLayerAndroid.h
@@ -26,6 +26,8 @@
#ifndef BaseLayerAndroid_h
#define BaseLayerAndroid_h
+#include <utils/threads.h>
+
#include "Color.h"
#include "GLWebViewState.h"
#include "IntRect.h"
diff --git a/Source/WebCore/platform/graphics/android/GaneshContext.cpp b/Source/WebCore/platform/graphics/android/GaneshContext.cpp
index 03e6eb7..80fe749 100644
--- a/Source/WebCore/platform/graphics/android/GaneshContext.cpp
+++ b/Source/WebCore/platform/graphics/android/GaneshContext.cpp
@@ -51,9 +51,6 @@
GaneshContext::GaneshContext()
: m_grContext(0)
- , m_baseTileDeviceFBO(0)
- , m_baseTileFBO(0)
- , m_baseTileStencil(0)
, m_baseTileDeviceSurface(0)
, m_surfaceConfig(0)
, m_surfaceContext(EGL_NO_CONTEXT)
@@ -95,22 +92,6 @@
contextNeedsReset = true;
}
- SkDevice* device = 0;
- if (renderInfo.textureInfo->getSharedTextureMode() == SurfaceTextureMode)
- device = getDeviceForBaseTileSurface(renderInfo);
- else if (renderInfo.textureInfo->getSharedTextureMode() == EglImageMode)
- device = getDeviceForBaseTileFBO(renderInfo);
-
- // We must reset the Ganesh context only after we are sure we have
- // re-established our EGLContext as the current context.
- if (device && contextNeedsReset)
- getGrContext()->resetContext();
-
- return device;
-}
-
-SkDevice* GaneshContext::getDeviceForBaseTileSurface(const TileRenderInfo& renderInfo)
-{
EGLDisplay display;
if (!m_surfaceContext) {
@@ -154,7 +135,6 @@
}
TransferQueue* tileQueue = TilesManager::instance()->transferQueue();
-
if (tileQueue->m_eglSurface == EGL_NO_SURFACE) {
const float tileWidth = renderInfo.tileSize.width();
@@ -179,101 +159,32 @@
if (!m_baseTileDeviceSurface) {
- GrPlatformSurfaceDesc surfaceDesc;
- surfaceDesc.fSurfaceType = kRenderTarget_GrPlatformSurfaceType;
- surfaceDesc.fRenderTargetFlags = kNone_GrPlatformRenderTargetFlagBit;
- surfaceDesc.fWidth = TilesManager::tileWidth();
- surfaceDesc.fHeight = TilesManager::tileHeight();
- surfaceDesc.fConfig = kRGBA_8888_GrPixelConfig;
- surfaceDesc.fStencilBits = 8;
- surfaceDesc.fPlatformRenderTarget = 0;
+ GrPlatformRenderTargetDesc renderTargetDesc;
+ renderTargetDesc.fWidth = TilesManager::tileWidth();
+ renderTargetDesc.fHeight = TilesManager::tileHeight();
+ renderTargetDesc.fConfig = kRGBA_8888_PM_GrPixelConfig;
+ renderTargetDesc.fSampleCnt = 0;
+ renderTargetDesc.fStencilBits = 8;
+ renderTargetDesc.fRenderTargetHandle = 0;
GrContext* grContext = getGrContext();
- GrRenderTarget* renderTarget = (GrRenderTarget*) grContext->createPlatformSurface(surfaceDesc);
+ GrRenderTarget* renderTarget = grContext->createPlatformRenderTarget(renderTargetDesc);
- SkBitmap bitmap;
- bitmap.setConfig(SkBitmap::kARGB_8888_Config,
- renderInfo.tileSize.width(),
- renderInfo.tileSize.height());
-
- m_baseTileDeviceSurface = new SkGpuDevice(grContext, bitmap, renderTarget);
+ m_baseTileDeviceSurface = new SkGpuDevice(grContext, renderTarget);
renderTarget->unref();
XLOG("generated device %p", m_baseTileDeviceSurface);
}
GLUtils::checkGlError("getDeviceForBaseTile");
+
+ // We must reset the Ganesh context only after we are sure we have
+ // re-established our EGLContext as the current context.
+ if (m_baseTileDeviceSurface && contextNeedsReset)
+ getGrContext()->resetContext();
+
return m_baseTileDeviceSurface;
}
-SkDevice* GaneshContext::getDeviceForBaseTileFBO(const TileRenderInfo& renderInfo)
-{
- const GLuint textureId = renderInfo.textureInfo->m_textureId;
- const float tileWidth = renderInfo.tileSize.width();
- const float tileHeight = renderInfo.tileSize.height();
-
- // bind to the current texture
- glBindTexture(GL_TEXTURE_2D, textureId);
-
- // setup the texture if needed
- if (renderInfo.textureInfo->m_width != tileWidth
- || renderInfo.textureInfo->m_height != tileHeight) {
-
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tileWidth, tileHeight,
- 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
- renderInfo.textureInfo->m_width = tileWidth;
- renderInfo.textureInfo->m_height = tileHeight;
-
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- }
-
- if (!m_baseTileFBO) {
- glGenFramebuffers(1, &m_baseTileFBO);
- XLOG("generated FBO");
- }
-
- if (!m_baseTileStencil) {
- glGenRenderbuffers(1, &m_baseTileStencil);
- glBindRenderbuffer(GL_RENDERBUFFER, m_baseTileStencil);
- glRenderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX8,
- TilesManager::tileWidth(),
- TilesManager::tileHeight());
- glClearStencil(0);
- glClear(GL_STENCIL_BUFFER_BIT);
- XLOG("generated stencil");
- }
-
- // bind the FBO and attach the texture and stencil
- glBindFramebuffer(GL_FRAMEBUFFER, m_baseTileFBO);
- glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureId, 0);
- glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_baseTileStencil);
-
- if (!m_baseTileDeviceFBO) {
-
- GrPlatformSurfaceDesc surfaceDesc;
- surfaceDesc.fSurfaceType = kRenderTarget_GrPlatformSurfaceType;
- surfaceDesc.fRenderTargetFlags = kNone_GrPlatformRenderTargetFlagBit;
- surfaceDesc.fWidth = TilesManager::tileWidth();
- surfaceDesc.fHeight = TilesManager::tileHeight();
- surfaceDesc.fConfig = kRGBA_8888_GrPixelConfig;
- surfaceDesc.fStencilBits = 8;
- surfaceDesc.fPlatformRenderTarget = m_baseTileFBO;
-
- GrContext* grContext = getGrContext();
- GrRenderTarget* renderTarget = (GrRenderTarget*) grContext->createPlatformSurface(surfaceDesc);
-
- SkBitmap bitmap;
- bitmap.setConfig(SkBitmap::kARGB_8888_Config,
- TilesManager::tileWidth(), TilesManager::tileWidth());
-
- m_baseTileDeviceFBO = new SkGpuDevice(grContext, bitmap, renderTarget);
- renderTarget->unref();
- XLOG("generated device %p", m_baseTileDeviceFBO);
- }
-
- GLUtils::checkGlError("getDeviceForBaseTile");
- return m_baseTileDeviceFBO;
-}
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/GaneshContext.h b/Source/WebCore/platform/graphics/android/GaneshContext.h
index 12ea92d..def35e5 100644
--- a/Source/WebCore/platform/graphics/android/GaneshContext.h
+++ b/Source/WebCore/platform/graphics/android/GaneshContext.h
@@ -48,20 +48,8 @@
GaneshContext();
GrContext* getGrContext();
-
- // Creates a device for rendering into a SurfaceTexture via an EGLSurface
- SkDevice* getDeviceForBaseTileSurface(const TileRenderInfo& renderInfo);
- // Creates a device for rendering into a EGLImage via an FBO
- SkDevice* getDeviceForBaseTileFBO(const TileRenderInfo& renderInfo);
-
GrContext* m_grContext;
- // FBO specific variables
- SkGpuDevice* m_baseTileDeviceFBO;
- GLuint m_baseTileFBO;
- GLuint m_baseTileStencil;
-
- // Surface specific variables
SkGpuDevice* m_baseTileDeviceSurface;
EGLConfig m_surfaceConfig;
EGLContext m_surfaceContext;
diff --git a/Source/WebCore/platform/graphics/android/GaneshRenderer.cpp b/Source/WebCore/platform/graphics/android/GaneshRenderer.cpp
index f4df33a..29acb2b 100644
--- a/Source/WebCore/platform/graphics/android/GaneshRenderer.cpp
+++ b/Source/WebCore/platform/graphics/android/GaneshRenderer.cpp
@@ -117,7 +117,6 @@
// set the GPU device to the canvas
canvas->setDevice(device);
- canvas->setDeviceFactory(device->getDeviceFactory());
// invert canvas contents
if (renderInfo.textureInfo->getSharedTextureMode() == EglImageMode) {
diff --git a/Source/WebCore/platform/graphics/android/ImageBufferAndroid.cpp b/Source/WebCore/platform/graphics/android/ImageBufferAndroid.cpp
index 691fbca..751a08f 100644
--- a/Source/WebCore/platform/graphics/android/ImageBufferAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/ImageBufferAndroid.cpp
@@ -36,6 +36,7 @@
#include "SkBitmapRef.h"
#include "SkCanvas.h"
#include "SkColorPriv.h"
+#include "SkData.h"
#include "SkDevice.h"
#include "SkImageEncoder.h"
#include "SkStream.h"
@@ -241,7 +242,9 @@
// Convert it into base64.
Vector<char> pngEncodedData;
- pngEncodedData.append(pngStream.getStream(), pngStream.getOffset());
+ SkData* streamData = pngStream.copyToData();
+ pngEncodedData.append((char*)streamData->data(), streamData->size());
+ streamData->unref();
Vector<char> base64EncodedData;
base64Encode(pngEncodedData, base64EncodedData);
// Append with a \0 so that it's a valid string.
diff --git a/Source/WebCore/platform/graphics/android/ImageTexture.cpp b/Source/WebCore/platform/graphics/android/ImageTexture.cpp
index 23e3899..577e7f0 100644
--- a/Source/WebCore/platform/graphics/android/ImageTexture.cpp
+++ b/Source/WebCore/platform/graphics/android/ImageTexture.cpp
@@ -126,7 +126,7 @@
// Create a copy of the image
img->setConfig(SkBitmap::kARGB_8888_Config, w, h);
img->allocPixels();
- SkDevice* device = new SkDevice(NULL, *img, false);
+ SkDevice* device = new SkDevice(*img);
SkCanvas canvas;
canvas.setDevice(device);
device->unref();
diff --git a/Source/WebCore/platform/graphics/android/ImagesManager.h b/Source/WebCore/platform/graphics/android/ImagesManager.h
index a3ea859..b915a46 100644
--- a/Source/WebCore/platform/graphics/android/ImagesManager.h
+++ b/Source/WebCore/platform/graphics/android/ImagesManager.h
@@ -32,6 +32,8 @@
#include "SkRefCnt.h"
#include "Vector.h"
+#include <utils/threads.h>
+
namespace WebCore {
class ImageTexture;
diff --git a/Source/WebCore/platform/graphics/android/RasterRenderer.cpp b/Source/WebCore/platform/graphics/android/RasterRenderer.cpp
index 0c92de4..9991fbd 100644
--- a/Source/WebCore/platform/graphics/android/RasterRenderer.cpp
+++ b/Source/WebCore/platform/graphics/android/RasterRenderer.cpp
@@ -101,7 +101,7 @@
g_bitmap->eraseARGB(255, 255, 255, 255);
}
- SkDevice* device = new SkDevice(NULL, *g_bitmap, false);
+ SkDevice* device = new SkDevice(*g_bitmap);
if (renderInfo.measurePerf) {
m_perfMon.stop(TAG_CREATE_BITMAP);
diff --git a/Source/WebCore/platform/graphics/android/TextureInfo.cpp b/Source/WebCore/platform/graphics/android/TextureInfo.cpp
index 5356dcb..aff9a3d 100644
--- a/Source/WebCore/platform/graphics/android/TextureInfo.cpp
+++ b/Source/WebCore/platform/graphics/android/TextureInfo.cpp
@@ -42,7 +42,6 @@
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..aca74b7 100644
--- a/Source/WebCore/platform/graphics/android/TextureInfo.h
+++ b/Source/WebCore/platform/graphics/android/TextureInfo.h
@@ -72,11 +72,6 @@
#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;
diff --git a/Source/WebKit/android/jni/WebViewCore.h b/Source/WebKit/android/jni/WebViewCore.h
index a05c3ea..a19a5b2 100644
--- a/Source/WebKit/android/jni/WebViewCore.h
+++ b/Source/WebKit/android/jni/WebViewCore.h
@@ -45,6 +45,7 @@
#include <jni.h>
#include <ui/KeycodeLabels.h>
#include <ui/PixelFormat.h>
+#include <utils/threads.h>
namespace WebCore {
class Color;
diff --git a/Source/WebKit/android/nav/WebView.cpp b/Source/WebKit/android/nav/WebView.cpp
index 76f0fb8..7cb41d9 100644
--- a/Source/WebKit/android/nav/WebView.cpp
+++ b/Source/WebKit/android/nav/WebView.cpp
@@ -503,7 +503,7 @@
// Make sure we have valid coordinates. We might not have valid coords
// if the zoom manager is still initializing. We will be redrawn
// once the correct scale is set
- if (!m_visibleRect.hasValidCoordinates())
+ if (!m_visibleRect.isFinite())
return false;
bool treesSwapped = false;
bool newTreeHasAnim = false;