diff options
Diffstat (limited to 'Source')
44 files changed, 1025 insertions, 215 deletions
diff --git a/Source/WebCore/Android.mk b/Source/WebCore/Android.mk index 9ea7007..a55c8ab 100644 --- a/Source/WebCore/Android.mk +++ b/Source/WebCore/Android.mk @@ -644,6 +644,8 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \ platform/graphics/android/FontCustomPlatformData.cpp \ platform/graphics/android/FontDataAndroid.cpp \ platform/graphics/android/FontPlatformDataAndroid.cpp \ + platform/graphics/android/GaneshContext.cpp \ + platform/graphics/android/GaneshRenderer.cpp \ platform/graphics/android/GLUtils.cpp \ platform/graphics/android/GLWebViewState.cpp \ platform/graphics/android/GlyphMapAndroid.cpp \ @@ -653,6 +655,7 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \ platform/graphics/android/ImageAndroid.cpp \ platform/graphics/android/ImageBufferAndroid.cpp \ platform/graphics/android/ImageSourceAndroid.cpp \ + platform/graphics/android/Layer.cpp \ platform/graphics/android/LayerAndroid.cpp \ platform/graphics/android/LayerTexture.cpp \ platform/graphics/android/MediaLayer.cpp \ diff --git a/Source/WebCore/platform/graphics/android/AndroidAnimation.cpp b/Source/WebCore/platform/graphics/android/AndroidAnimation.cpp index 1eb7f39..2939cf0 100644 --- a/Source/WebCore/platform/graphics/android/AndroidAnimation.cpp +++ b/Source/WebCore/platform/graphics/android/AndroidAnimation.cpp @@ -83,6 +83,7 @@ AndroidAnimation::AndroidAnimation(AndroidAnimation* anim) , m_iterationCount(anim->m_iterationCount) , m_direction(anim->m_direction) , m_timingFunction(anim->m_timingFunction) + , m_name(anim->name()) , m_type(anim->m_type) , m_operations(anim->m_operations) , m_originalLayer(0) diff --git a/Source/WebCore/platform/graphics/android/BaseLayerAndroid.h b/Source/WebCore/platform/graphics/android/BaseLayerAndroid.h index e6680b5..29ecf57 100644 --- a/Source/WebCore/platform/graphics/android/BaseLayerAndroid.h +++ b/Source/WebCore/platform/graphics/android/BaseLayerAndroid.h @@ -29,13 +29,13 @@ #include "Color.h" #include "GLWebViewState.h" #include "IntRect.h" +#include "Layer.h" #include "PictureSet.h" -#include "SkLayer.h" #include "SkPicture.h" namespace WebCore { -class BaseLayerAndroid : public SkLayer { +class BaseLayerAndroid : public Layer { public: BaseLayerAndroid(); diff --git a/Source/WebCore/platform/graphics/android/BaseRenderer.cpp b/Source/WebCore/platform/graphics/android/BaseRenderer.cpp index 13dfce6..f9da6f5 100644 --- a/Source/WebCore/platform/graphics/android/BaseRenderer.cpp +++ b/Source/WebCore/platform/graphics/android/BaseRenderer.cpp @@ -67,48 +67,68 @@ void BaseRenderer::drawTileInfo(SkCanvas* canvas, canvas->drawText(str, strlen(str), 0, 10, paint); paint.setARGB(255, 255, 0, 0); canvas->drawText(str, strlen(str), 0, 11, paint); - drawPerformanceInfo(canvas); + + int tagCount = 0; + const String* tags = getPerformanceTags(tagCount); + + float total = 0; + for (int i = 0; i < tagCount; i++) { + float tagDuration = m_perfMon.getAverageDuration(tags[i]); + total += tagDuration; + snprintf(str, 256, "%s: %.2f", tags[i].utf8().data(), tagDuration); + paint.setARGB(255, 0, 0, 0); + int textY = (i * 12) + 25; + canvas->drawText(str, strlen(str), 0, textY, paint); + paint.setARGB(255, 255, 0, 0); + canvas->drawText(str, strlen(str), 0, textY + 1, paint); + } + snprintf(str, 256, "total: %.2f", total); + paint.setARGB(255, 0, 0, 0); + int textY = (tagCount * 12) + 30; + canvas->drawText(str, strlen(str), 0, textY, paint); + paint.setARGB(255, 255, 0, 0); + canvas->drawText(str, strlen(str), 0, textY + 1, paint); } int BaseRenderer::renderTiledContent(const TileRenderInfo& renderInfo) { - bool visualIndicator = TilesManager::instance()->getShowVisualIndicator(); + const bool visualIndicator = TilesManager::instance()->getShowVisualIndicator(); + const SkSize& tileSize = renderInfo.tileSize; -#ifdef DEBUG - visualIndicator = true; - measurePerf = true; -#endif - - SkIRect* invalRect = renderInfo.invalRect; - - SkDevice* device = setupDevice(renderInfo); - SkCanvas canvas(device); - device->unref(); + SkCanvas canvas; + setupCanvas(renderInfo, &canvas); if (visualIndicator) canvas.save(); + setupPartialInval(renderInfo, &canvas); + canvas.translate(-renderInfo.x * tileSize.width(), -renderInfo.y * tileSize.height()); canvas.scale(renderInfo.scale, renderInfo.scale); - canvas.translate(-renderInfo.invalX, -renderInfo.invalY); int pictureCount = renderInfo.tiledPage->paintBaseLayerContent(&canvas); if (visualIndicator) { canvas.restore(); - int color = 20 + pictureCount % 100; - canvas.drawARGB(color, 0, 255, 0); + const int color = 20 + (pictureCount % 100); + + // only color the invalidated area + SkPaint invalPaint; + invalPaint.setARGB(color, 0, 255, 0); + canvas.drawIRect(*renderInfo.invalRect, invalPaint); + // paint the tile boundaries SkPaint paint; paint.setARGB(128, 255, 0, 0); paint.setStrokeWidth(3); - canvas.drawLine(0, 0, invalRect->width(), invalRect->height(), paint); + canvas.drawLine(0, 0, tileSize.width(), tileSize.height(), paint); paint.setARGB(128, 0, 255, 0); - canvas.drawLine(0, invalRect->height(), invalRect->width(), 0, paint); + canvas.drawLine(0, tileSize.height(), tileSize.width(), 0, paint); paint.setARGB(128, 0, 0, 255); - canvas.drawLine(0, 0, invalRect->width(), 0, paint); - canvas.drawLine(invalRect->width(), 0, invalRect->width(), invalRect->height(), paint); + canvas.drawLine(0, 0, tileSize.width(), 0, paint); + canvas.drawLine(tileSize.width(), 0, tileSize.width(), tileSize.height(), paint); - drawTileInfo(&canvas, renderInfo, pictureCount); + if (renderInfo.measurePerf) + drawTileInfo(&canvas, renderInfo, pictureCount); } renderingComplete(renderInfo, &canvas); diff --git a/Source/WebCore/platform/graphics/android/BaseRenderer.h b/Source/WebCore/platform/graphics/android/BaseRenderer.h index b48145f..046634a 100644 --- a/Source/WebCore/platform/graphics/android/BaseRenderer.h +++ b/Source/WebCore/platform/graphics/android/BaseRenderer.h @@ -50,10 +50,6 @@ struct TileRenderInfo { // inval rectangle with coordinates in the tile's coordinate space SkIRect* invalRect; - // coordinates for the invalRect (upper-left) in the DOM's coordinate space - float invalX; - float invalY; - // the expected size of the tile SkSize tileSize; @@ -82,13 +78,14 @@ public: protected: - virtual SkDevice* setupDevice(const TileRenderInfo& renderInfo) = 0; + virtual void setupCanvas(const TileRenderInfo& renderInfo, SkCanvas* canvas) = 0; + virtual void setupPartialInval(const TileRenderInfo& renderInfo, SkCanvas* canvas) {} virtual void renderingComplete(const TileRenderInfo& renderInfo, SkCanvas* canvas) = 0; void drawTileInfo(SkCanvas* canvas, const TileRenderInfo& renderInfo, int pictureCount); - virtual void drawPerformanceInfo(SkCanvas* canvas) {} + virtual const String* getPerformanceTags(int& tagCount) = 0; // Performance tracking PerformanceMonitor m_perfMon; diff --git a/Source/WebCore/platform/graphics/android/BaseTile.cpp b/Source/WebCore/platform/graphics/android/BaseTile.cpp index 87bdba4..70b98b0 100644 --- a/Source/WebCore/platform/graphics/android/BaseTile.cpp +++ b/Source/WebCore/platform/graphics/android/BaseTile.cpp @@ -28,7 +28,7 @@ #if USE(ACCELERATED_COMPOSITING) -#include "BaseRenderer.h" +#include "RasterRenderer.h" #include "GLUtils.h" #include "TextureInfo.h" #include "TilesManager.h" @@ -54,7 +54,8 @@ namespace WebCore { BaseTile::BaseTile() - : m_page(0) + : m_glWebViewState(0) + , m_page(0) , m_x(-1) , m_y(-1) , m_texture(0) @@ -71,6 +72,7 @@ BaseTile::BaseTile() ClassTracker::instance()->increment("BaseTile"); #endif m_currentDirtyArea = &m_dirtyAreaA; + m_renderer = new RasterRenderer(); } BaseTile::~BaseTile() @@ -79,6 +81,8 @@ BaseTile::~BaseTile() if (m_texture) m_texture->release(this); + delete m_renderer; + #ifdef DEBUG_COUNT ClassTracker::instance()->decrement("BaseTile"); #endif @@ -347,11 +351,9 @@ void BaseTile::paintBitmap() finalRealRect.fBottom = finalRealRect.fTop + iHeight; renderInfo.invalRect = &finalRealRect; - renderInfo.invalX = realTileRect.fLeft / scale; - renderInfo.invalY = realTileRect.fTop / scale; renderInfo.measurePerf = false; - pictureCount = m_renderer.renderTiledContent(renderInfo); + pictureCount = m_renderer->renderTiledContent(renderInfo); cliperator.next(); } @@ -362,11 +364,9 @@ void BaseTile::paintBitmap() rect.set(0, 0, tileWidth, tileHeight); renderInfo.invalRect = ▭ - renderInfo.invalX = x * tileWidth / scale; - renderInfo.invalY = y * tileHeight / scale; renderInfo.measurePerf = TilesManager::instance()->getShowVisualIndicator(); - pictureCount = m_renderer.renderTiledContent(renderInfo); + pictureCount = m_renderer->renderTiledContent(renderInfo); } XLOG("%x update texture %x for tile %d, %d scale %.2f (m_scale: %.2f)", this, textureInfo, x, y, scale, m_scale); diff --git a/Source/WebCore/platform/graphics/android/BaseTile.h b/Source/WebCore/platform/graphics/android/BaseTile.h index cddaa60..8a812f8 100644 --- a/Source/WebCore/platform/graphics/android/BaseTile.h +++ b/Source/WebCore/platform/graphics/android/BaseTile.h @@ -28,7 +28,7 @@ #if USE(ACCELERATED_COMPOSITING) -#include "RasterRenderer.h" +#include "BaseRenderer.h" #include "SkRect.h" #include "SkRegion.h" #include "TextureOwner.h" @@ -40,6 +40,7 @@ namespace WebCore { class TextureInfo; class TiledPage; class BaseTileTexture; +class GLWebViewState; /** * An individual tile that is used to construct part of a webpage's BaseLayer of @@ -94,11 +95,16 @@ public: unsigned int lastPaintedPicture() const { return m_lastPaintedPicture; } BaseTileTexture* texture() { return m_texture; } + void setGLWebViewState(GLWebViewState* state) { m_glWebViewState = state; } + // TextureOwner implementation virtual bool removeTexture(BaseTileTexture* texture); virtual TiledPage* page() { return m_page; } + virtual GLWebViewState* state() { return m_glWebViewState; } private: + GLWebViewState* m_glWebViewState; + // these variables are only set when the object is constructed TiledPage* m_page; int m_x; @@ -135,7 +141,7 @@ private: // across all threads and cores. android::Mutex m_atomicSync; - RasterRenderer m_renderer; + BaseRenderer* m_renderer; }; } // namespace WebCore diff --git a/Source/WebCore/platform/graphics/android/BaseTileTexture.cpp b/Source/WebCore/platform/graphics/android/BaseTileTexture.cpp index ee8cebf..4d1dec1 100644 --- a/Source/WebCore/platform/graphics/android/BaseTileTexture.cpp +++ b/Source/WebCore/platform/graphics/android/BaseTileTexture.cpp @@ -147,13 +147,12 @@ bool BaseTileTexture::acquire(TextureOwner* owner, bool force) return setOwner(owner, force); } -bool BaseTileTexture::tryAcquire(TextureOwner* owner, TiledPage* currentPage, TiledPage* nextPage) +bool BaseTileTexture::tryAcquire(TextureOwner* owner) { m_busyLock.lock(); if (!m_busy && m_owner - && m_owner->page() != currentPage - && m_owner->page() != nextPage) { + && m_owner->state() != owner->state()) { m_busyLock.unlock(); return this->acquire(owner); } diff --git a/Source/WebCore/platform/graphics/android/BaseTileTexture.h b/Source/WebCore/platform/graphics/android/BaseTileTexture.h index 0a7534a..5496e66 100644 --- a/Source/WebCore/platform/graphics/android/BaseTileTexture.h +++ b/Source/WebCore/platform/graphics/android/BaseTileTexture.h @@ -86,7 +86,7 @@ public: // returns false if ownership cannot be transferred because the tile is busy bool acquire(TextureOwner* owner, bool force = false); bool release(TextureOwner* owner); - bool tryAcquire(TextureOwner* owner, TiledPage* currentPage, TiledPage* nextPage); + bool tryAcquire(TextureOwner* owner); // set the texture owner if not busy. Return false if busy, true otherwise. bool setOwner(TextureOwner* owner, bool force = false); diff --git a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp index dda5dee..54176e0 100644 --- a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp +++ b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp @@ -116,6 +116,7 @@ GLWebViewState::~GLWebViewState() #ifdef DEBUG_COUNT ClassTracker::instance()->decrement("GLWebViewState"); #endif + TilesManager::instance()->unregisterGLWebViewState(this); } void GLWebViewState::setBaseLayer(BaseLayerAndroid* layer, const SkRegion& inval, @@ -497,6 +498,7 @@ bool GLWebViewState::drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect, IntRect& clip, float scale, SkColor color) { glFinish(); + TilesManager::instance()->registerGLWebViewState(this); m_baseLayerLock.lock(); BaseLayerAndroid* baseLayer = m_currentBaseLayer; diff --git a/Source/WebCore/platform/graphics/android/GaneshContext.cpp b/Source/WebCore/platform/graphics/android/GaneshContext.cpp new file mode 100644 index 0000000..b316e5a --- /dev/null +++ b/Source/WebCore/platform/graphics/android/GaneshContext.cpp @@ -0,0 +1,128 @@ +/* + * Copyright 2011, 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 "GaneshContext.h" +#include "GLUtils.h" + +#if USE(ACCELERATED_COMPOSITING) + +#ifdef DEBUG + +#include <cutils/log.h> +#include <wtf/CurrentTime.h> + +#undef XLOG +#define XLOG(...) android_printLog(ANDROID_LOG_DEBUG, "GaneshContext", __VA_ARGS__) + +#else + +#undef XLOG +#define XLOG(...) + +#endif // DEBUG + +namespace WebCore { + +GaneshContext::GaneshContext() + : m_grContext(0) + , m_baseTileDevice(0) + , m_baseTileFbo(0) + , m_baseTileStencil(0) +{ +} + +GaneshContext* GaneshContext::gInstance = 0; + +GaneshContext* GaneshContext::instance() +{ + if (!gInstance) + gInstance = new GaneshContext(); + return gInstance; +} + +GrContext* GaneshContext::getGrContext() +{ + if (!m_grContext) { + m_grContext = GrContext::Create(kOpenGL_Shaders_GrEngine, NULL); + } + return m_grContext; +} + +SkDevice* GaneshContext::getDeviceForBaseTile(GLuint textureId) +{ + 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"); + } + + 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_baseTileDevice) { + + GrPlatformSurfaceDesc surfaceDesc; + surfaceDesc.fSurfaceType = kRenderTarget_GrPlatformSurfaceType; + surfaceDesc.fRenderTargetFlags = kNone_GrPlatformRenderTargetFlagBit; + surfaceDesc.fWidth = TilesManager::tileWidth(); + surfaceDesc.fHeight = TilesManager::tileWidth(); + 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_baseTileDevice = new SkGpuDevice(grContext, bitmap, renderTarget); + renderTarget->unref(); + XLOG("generated device %p", m_baseTileDevice); + } + + GLUtils::checkGlError("getDeviceForBaseTile"); + return m_baseTileDevice; +} + + + +} // namespace WebCore + +#endif // USE(ACCELERATED_COMPOSITING) diff --git a/Source/WebCore/platform/graphics/android/GaneshContext.h b/Source/WebCore/platform/graphics/android/GaneshContext.h new file mode 100644 index 0000000..9d90b96 --- /dev/null +++ b/Source/WebCore/platform/graphics/android/GaneshContext.h @@ -0,0 +1,60 @@ +/* + * Copyright 2011, 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 GaneshContext_h +#define GaneshContext_h + +#if USE(ACCELERATED_COMPOSITING) + +#include "GrContext.h" +#include "SkGpuDevice.h" +#include "TilesManager.h" + +namespace WebCore { + +class GaneshContext { +public: + static GaneshContext* instance(); + + GrContext* getGrContext(); + + SkDevice* getDeviceForBaseTile(GLuint textureId); + +private: + + GaneshContext(); + + GrContext* m_grContext; + SkGpuDevice* m_baseTileDevice; + GLuint m_baseTileFbo; + GLuint m_baseTileStencil; + + static GaneshContext* gInstance; +}; + +} // namespace WebCore + +#endif // USE(ACCELERATED_COMPOSITING) +#endif // GaneshContext_h diff --git a/Source/WebCore/platform/graphics/android/GaneshRenderer.cpp b/Source/WebCore/platform/graphics/android/GaneshRenderer.cpp new file mode 100644 index 0000000..fcb0675 --- /dev/null +++ b/Source/WebCore/platform/graphics/android/GaneshRenderer.cpp @@ -0,0 +1,164 @@ +/* + * Copyright 2011, 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 "GaneshRenderer.h" + +#if USE(ACCELERATED_COMPOSITING) + +#include "GaneshContext.h" +#include "SkCanvas.h" +#include "SkGpuDevice.h" +#include "TilesManager.h" + +#include <wtf/text/CString.h> + +#ifdef DEBUG + +#include <cutils/log.h> +#include <wtf/CurrentTime.h> + +#undef XLOG +#define XLOG(...) android_printLog(ANDROID_LOG_DEBUG, "GaneshRenderer", __VA_ARGS__) + +#else + +#undef XLOG +#define XLOG(...) + +#endif // DEBUG + +namespace WebCore { + +static const String TAG_CREATE_FBO = "create_fbo"; +static const String TAG_DRAW_PICTURE = "draw_picture"; +static const String TAG_UPDATE_TEXTURE = "update_texture"; +#define TAG_COUNT 3 +static const String TAGS[] = { + TAG_CREATE_FBO, + TAG_DRAW_PICTURE, + TAG_UPDATE_TEXTURE, +}; + +GaneshRenderer::GaneshRenderer() : BaseRenderer(BaseRenderer::Raster) +{ +#ifdef DEBUG_COUNT + ClassTracker::instance()->increment("GaneshRenderer"); +#endif +} + +GaneshRenderer::~GaneshRenderer() +{ +#ifdef DEBUG_COUNT + ClassTracker::instance()->decrement("GaneshRenderer"); +#endif +} + +void GaneshRenderer::setupCanvas(const TileRenderInfo& renderInfo, SkCanvas* canvas) +{ + if (renderInfo.measurePerf) + m_perfMon.start(TAG_CREATE_FBO); + + const float tileWidth = renderInfo.tileSize.width(); + const float tileHeight = renderInfo.tileSize.height(); + + glBindTexture(GL_TEXTURE_2D, renderInfo.textureInfo->m_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); + } + + GaneshContext* ganesh = GaneshContext::instance(); + + // TODO only need to reset if others are sharing our context + ganesh->getGrContext()->resetContext(); + + SkDevice* device = NULL; + if (tileWidth == TilesManager::tileWidth() && tileHeight == TilesManager::tileHeight()) { + device = ganesh->getDeviceForBaseTile(renderInfo.textureInfo->m_textureId); + } else { + // TODO support arbitrary sizes for layers + XLOG("ERROR: expected (%d,%d) actual (%d,%d)", + TilesManager::tileWidth(), TilesManager::tileHeight(), + tileWidth, tileHeight); + } + + if (renderInfo.measurePerf) { + m_perfMon.stop(TAG_CREATE_FBO); + m_perfMon.start(TAG_DRAW_PICTURE); + } + + // set the GPU device to the canvas + canvas->setDevice(device); + + // invert canvas contents + canvas->scale(SK_Scalar1, -SK_Scalar1); + canvas->translate(0, -SkIntToScalar(renderInfo.tileSize.height())); +} + +void GaneshRenderer::setupPartialInval(const TileRenderInfo& renderInfo, SkCanvas* canvas) +{ + // set the clip to our invalRect + SkRect clipRect = SkRect::MakeLTRB(renderInfo.invalRect->fLeft, + renderInfo.invalRect->fTop, + renderInfo.invalRect->fRight, + renderInfo.invalRect->fBottom); + canvas->clipRect(clipRect); +} + +void GaneshRenderer::renderingComplete(const TileRenderInfo& renderInfo, SkCanvas* canvas) +{ + if (renderInfo.measurePerf) { + m_perfMon.stop(TAG_DRAW_PICTURE); + m_perfMon.start(TAG_UPDATE_TEXTURE); + } + + GaneshContext::instance()->getGrContext()->flush(); + + //TODO if texture is surfaceTexture then... + + if (renderInfo.measurePerf) + m_perfMon.stop(TAG_UPDATE_TEXTURE); +} + +const String* GaneshRenderer::getPerformanceTags(int& tagCount) +{ + tagCount = TAG_COUNT; + return TAGS; +} + +} // namespace WebCore + +#endif // USE(ACCELERATED_COMPOSITING) diff --git a/Source/WebCore/platform/graphics/android/GaneshRenderer.h b/Source/WebCore/platform/graphics/android/GaneshRenderer.h new file mode 100644 index 0000000..0e1d41e --- /dev/null +++ b/Source/WebCore/platform/graphics/android/GaneshRenderer.h @@ -0,0 +1,59 @@ +/* + * Copyright 2011, 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 GaneshRenderer_h +#define GaneshRenderer_h + +#if USE(ACCELERATED_COMPOSITING) + +#include "BaseRenderer.h" +#include "SkRect.h" + +class SkCanvas; +class SkDevice; + +namespace WebCore { + +/** + * + */ +class GaneshRenderer : public BaseRenderer { +public: + GaneshRenderer(); + ~GaneshRenderer(); + +protected: + + virtual void setupCanvas(const TileRenderInfo& renderInfo, SkCanvas* canvas); + virtual void setupPartialInval(const TileRenderInfo& renderInfo, SkCanvas* canvas); + virtual void renderingComplete(const TileRenderInfo& renderInfo, SkCanvas* canvas); + virtual const String* getPerformanceTags(int& tagCount); + +}; + +} // namespace WebCore + +#endif // USE(ACCELERATED_COMPOSITING) +#endif // GaneshRenderer_h diff --git a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp index 992585a..fc9d85f 100644 --- a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp @@ -24,6 +24,7 @@ #include "FloatRect.h" #include "GraphicsContext.h" #include "Image.h" +#include "Layer.h" #include "Length.h" #include "MediaLayer.h" #include "PlatformBridge.h" @@ -34,7 +35,6 @@ #include "ScaleTransformOperation.h" #include "ScrollableLayerAndroid.h" #include "SkCanvas.h" -#include "SkLayer.h" #include "TransformationMatrix.h" #include "TranslateTransformOperation.h" diff --git a/Source/WebCore/platform/graphics/android/Layer.cpp b/Source/WebCore/platform/graphics/android/Layer.cpp new file mode 100644 index 0000000..4741397 --- /dev/null +++ b/Source/WebCore/platform/graphics/android/Layer.cpp @@ -0,0 +1,224 @@ +#include "config.h" +#include "Layer.h" +#include "SkCanvas.h" + +//#define DEBUG_DRAW_LAYER_BOUNDS +//#define DEBUG_TRACK_NEW_DELETE + +#ifdef DEBUG_TRACK_NEW_DELETE + static int gLayerAllocCount; +#endif + +/////////////////////////////////////////////////////////////////////////////// + +Layer::Layer() { + fParent = NULL; + m_opacity = SK_Scalar1; + m_size.set(0, 0); + m_position.set(0, 0); + m_anchorPoint.set(SK_ScalarHalf, SK_ScalarHalf); + + fMatrix.reset(); + fChildrenMatrix.reset(); + fFlags = 0; + +#ifdef DEBUG_TRACK_NEW_DELETE + gLayerAllocCount += 1; + SkDebugf("Layer new: %d\n", gLayerAllocCount); +#endif +} + +Layer::Layer(const Layer& src) : INHERITED() { + fParent = NULL; + m_opacity = src.m_opacity; + m_size = src.m_size; + m_position = src.m_position; + m_anchorPoint = src.m_anchorPoint; + + fMatrix = src.fMatrix; + fChildrenMatrix = src.fChildrenMatrix; + fFlags = src.fFlags; + +#ifdef DEBUG_TRACK_NEW_DELETE + gLayerAllocCount += 1; + SkDebugf("Layer copy: %d\n", gLayerAllocCount); +#endif +} + +Layer::~Layer() { + this->removeChildren(); + +#ifdef DEBUG_TRACK_NEW_DELETE + gLayerAllocCount -= 1; + SkDebugf("Layer delete: %d\n", gLayerAllocCount); +#endif +} + +/////////////////////////////////////////////////////////////////////////////// + +bool Layer::isInheritFromRootTransform() const { + return (fFlags & kInheritFromRootTransform_Flag) != 0; +} + +void Layer::setInheritFromRootTransform(bool doInherit) { + if (doInherit) { + fFlags |= kInheritFromRootTransform_Flag; + } else { + fFlags &= ~kInheritFromRootTransform_Flag; + } +} + +void Layer::setMatrix(const SkMatrix& matrix) { + fMatrix = matrix; +} + +void Layer::setChildrenMatrix(const SkMatrix& matrix) { + fChildrenMatrix = matrix; +} + +/////////////////////////////////////////////////////////////////////////////// + +int Layer::countChildren() const { + return m_children.count(); +} + +Layer* Layer::getChild(int index) const { + if ((unsigned)index < (unsigned)m_children.count()) { + SkASSERT(m_children[index]->fParent == this); + return m_children[index]; + } + return NULL; +} + +Layer* Layer::addChild(Layer* child) { + SkASSERT(this != child); + child->ref(); + child->detachFromParent(); + SkASSERT(child->fParent == NULL); + child->fParent = this; + + *m_children.append() = child; + return child; +} + +void Layer::detachFromParent() { + if (fParent) { + int index = fParent->m_children.find(this); + SkASSERT(index >= 0); + fParent->m_children.remove(index); + fParent = NULL; + this->unref(); // this call might delete us + } +} + +void Layer::removeChildren() { + int count = m_children.count(); + for (int i = 0; i < count; i++) { + Layer* child = m_children[i]; + SkASSERT(child->fParent == this); + child->fParent = NULL; // in case it has more than one owner + child->unref(); + } + m_children.reset(); +} + +Layer* Layer::getRootLayer() const { + const Layer* root = this; + while (root->fParent != NULL) { + root = root->fParent; + } + return const_cast<Layer*>(root); +} + +/////////////////////////////////////////////////////////////////////////////// + +void Layer::getLocalTransform(SkMatrix* matrix) const { + matrix->setTranslate(m_position.fX, m_position.fY); + + SkScalar tx = SkScalarMul(m_anchorPoint.fX, m_size.width()); + SkScalar ty = SkScalarMul(m_anchorPoint.fY, m_size.height()); + matrix->preTranslate(tx, ty); + matrix->preConcat(this->getMatrix()); + matrix->preTranslate(-tx, -ty); +} + +void Layer::localToGlobal(SkMatrix* matrix) const { + this->getLocalTransform(matrix); + + if (this->isInheritFromRootTransform()) { + matrix->postConcat(this->getRootLayer()->getMatrix()); + return; + } + + const Layer* layer = this; + while (layer->fParent != NULL) { + layer = layer->fParent; + + SkMatrix tmp; + layer->getLocalTransform(&tmp); + tmp.preConcat(layer->getChildrenMatrix()); + matrix->postConcat(tmp); + } +} + +/////////////////////////////////////////////////////////////////////////////// + +void Layer::onDraw(SkCanvas*, SkScalar opacity) { +// SkDebugf("----- no onDraw for %p\n", this); +} + +#include "SkString.h" + +void Layer::draw(SkCanvas* canvas, SkScalar opacity) { +#if 0 + SkString str1, str2; + // this->getMatrix().toDumpString(&str1); + // this->getChildrenMatrix().toDumpString(&str2); + SkDebugf("--- drawlayer %p opacity %g size [%g %g] pos [%g %g] matrix %s children %s\n", + this, opacity * this->getOpacity(), m_size.width(), m_size.height(), + m_position.fX, m_position.fY, str1.c_str(), str2.c_str()); +#endif + + opacity = SkScalarMul(opacity, this->getOpacity()); + if (opacity <= 0) { +// SkDebugf("---- abort drawing %p opacity %g\n", this, opacity); + return; + } + + SkAutoCanvasRestore acr(canvas, true); + + // apply our local transform + { + SkMatrix tmp; + this->getLocalTransform(&tmp); + if (this->isInheritFromRootTransform()) { + // should we also apply the root's childrenMatrix? + canvas->setMatrix(getRootLayer()->getMatrix()); + } + canvas->concat(tmp); + } + + this->onDraw(canvas, opacity); + +#ifdef DEBUG_DRAW_LAYER_BOUNDS + { + SkRect r = SkRect::MakeSize(this->getSize()); + SkPaint p; + p.setAntiAlias(true); + p.setStyle(SkPaint::kStroke_Style); + p.setStrokeWidth(SkIntToScalar(2)); + p.setColor(0xFFFF44DD); + canvas->drawRect(r, p); + canvas->drawLine(r.fLeft, r.fTop, r.fRight, r.fBottom, p); + canvas->drawLine(r.fLeft, r.fBottom, r.fRight, r.fTop, p); + } +#endif + + int count = this->countChildren(); + if (count > 0) { + canvas->concat(this->getChildrenMatrix()); + for (int i = 0; i < count; i++) { + this->getChild(i)->draw(canvas, opacity); + } + } +} diff --git a/Source/WebCore/platform/graphics/android/Layer.h b/Source/WebCore/platform/graphics/android/Layer.h new file mode 100644 index 0000000..0e2d7d8 --- /dev/null +++ b/Source/WebCore/platform/graphics/android/Layer.h @@ -0,0 +1,135 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef Layer_DEFINED +#define Layer_DEFINED + +#include "SkRefCnt.h" +#include "SkTDArray.h" +#include "SkColor.h" +#include "SkMatrix.h" +#include "SkPoint.h" +#include "SkRect.h" +#include "SkSize.h" + +class SkCanvas; + +class Layer : public SkRefCnt { + +public: + Layer(); + Layer(const Layer&); + virtual ~Layer(); + + bool isInheritFromRootTransform() const; + SkScalar getOpacity() const { return m_opacity; } + const SkSize& getSize() const { return m_size; } + const SkPoint& getPosition() const { return m_position; } + const SkPoint& getAnchorPoint() const { return m_anchorPoint; } + const SkMatrix& getMatrix() const { return fMatrix; } + const SkMatrix& getChildrenMatrix() const { return fChildrenMatrix; } + + SkScalar getWidth() const { return m_size.width(); } + SkScalar getHeight() const { return m_size.height(); } + + void setInheritFromRootTransform(bool); + void setOpacity(SkScalar opacity) { m_opacity = opacity; } + void setSize(SkScalar w, SkScalar h) { m_size.set(w, h); } + void setPosition(SkScalar x, SkScalar y) { m_position.set(x, y); } + void setAnchorPoint(SkScalar x, SkScalar y) { m_anchorPoint.set(x, y); } + void setMatrix(const SkMatrix&); + void setChildrenMatrix(const SkMatrix&); + + // children + + /** Return the number of layers in our child list. + */ + int countChildren() const; + + /** Return the child at the specified index (starting at 0). This does not + affect the reference count of the child. + */ + Layer* getChild(int index) const; + + /** Add this layer to our child list at the end (top-most), and ref() it. + If it was already in another hierarchy, remove it from that list. + Return the new child. + */ + Layer* addChild(Layer* child); + + /** Remove this layer from its parent's list (or do nothing if it has no + parent.) If it had a parent, then unref() is called. + */ + void detachFromParent(); + + /** Remove, and unref(), all of the layers in our child list. + */ + void removeChildren(); + + /** Return our parent layer, or NULL if we have none. + */ + Layer* getParent() const { return fParent; } + + /** Return the root layer in this hiearchy. If this layer is the root + (i.e. has no parent), then this returns itself. + */ + Layer* getRootLayer() const; + + // coordinate system transformations + + /** Return, in matrix, the matix transfomations that are applied locally + when this layer draws (i.e. its position and matrix/anchorPoint). + This does not include the childrenMatrix, since that is only applied + after this layer draws (but before its children draw). + */ + void getLocalTransform(SkMatrix* matrix) const; + + /** Return, in matrix, the concatenation of transforms that are applied + from this layer's root parent to the layer itself. + This is the matrix that is applied to the layer during drawing. + */ + void localToGlobal(SkMatrix* matrix) const; + + // paint method + + void draw(SkCanvas*, SkScalar opacity); + void draw(SkCanvas* canvas) { + this->draw(canvas, SK_Scalar1); + } + +protected: + virtual void onDraw(SkCanvas*, SkScalar opacity); + +private: + enum Flags { + kInheritFromRootTransform_Flag = 0x01 + }; + + Layer* fParent; + SkScalar m_opacity; + SkSize m_size; + SkPoint m_position; + SkPoint m_anchorPoint; + SkMatrix fMatrix; + SkMatrix fChildrenMatrix; + uint32_t fFlags; + + SkTDArray<Layer*> m_children; + + typedef SkRefCnt INHERITED; +}; + +#endif diff --git a/Source/WebCore/platform/graphics/android/LayerAndroid.cpp b/Source/WebCore/platform/graphics/android/LayerAndroid.cpp index e90829a..cfbbd0d 100644 --- a/Source/WebCore/platform/graphics/android/LayerAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/LayerAndroid.cpp @@ -54,7 +54,7 @@ class OpacityDrawFilter : public SkDrawFilter { /////////////////////////////////////////////////////////////////////////////// -LayerAndroid::LayerAndroid(RenderLayer* owner) : SkLayer(), +LayerAndroid::LayerAndroid(RenderLayer* owner) : Layer(), m_haveClip(false), m_isFixed(false), m_isIframe(false), @@ -84,7 +84,7 @@ LayerAndroid::LayerAndroid(RenderLayer* owner) : SkLayer(), #endif } -LayerAndroid::LayerAndroid(const LayerAndroid& layer) : SkLayer(layer), +LayerAndroid::LayerAndroid(const LayerAndroid& layer) : Layer(layer), m_haveClip(layer.m_haveClip), m_isIframe(layer.m_isIframe), m_contentsImage(0), @@ -139,7 +139,7 @@ LayerAndroid::LayerAndroid(const LayerAndroid& layer) : SkLayer(layer), #endif } -LayerAndroid::LayerAndroid(SkPicture* picture) : SkLayer(), +LayerAndroid::LayerAndroid(SkPicture* picture) : Layer(), m_haveClip(false), m_isFixed(false), m_isIframe(false), diff --git a/Source/WebCore/platform/graphics/android/LayerAndroid.h b/Source/WebCore/platform/graphics/android/LayerAndroid.h index 551e020..bd6c0ef 100644 --- a/Source/WebCore/platform/graphics/android/LayerAndroid.h +++ b/Source/WebCore/platform/graphics/android/LayerAndroid.h @@ -23,10 +23,10 @@ #include "FloatPoint3D.h" #include "FloatRect.h" #include "GraphicsLayerClient.h" +#include "Layer.h" #include "LayerTexture.h" #include "RefPtr.h" #include "SkColor.h" -#include "SkLayer.h" #include "TextureOwner.h" #include "TransformationMatrix.h" @@ -89,7 +89,7 @@ class LayerAndroidFindState; class RenderLayer; class TiledPage; -class LayerAndroid : public SkLayer, public TextureOwner { +class LayerAndroid : public Layer, public TextureOwner { public: LayerAndroid(RenderLayer* owner); @@ -102,6 +102,7 @@ public: LayerTexture* texture() { return m_reservedTexture; } virtual TiledPage* page() { return 0; } + virtual GLWebViewState* state() { return 0; } void setBackfaceVisibility(bool value) { m_backfaceVisibility = value; } void setTransform(const TransformationMatrix& matrix) { m_transform = matrix; } @@ -371,7 +372,7 @@ private: RenderLayer* m_owningLayer; - typedef SkLayer INHERITED; + typedef Layer INHERITED; }; } diff --git a/Source/WebCore/platform/graphics/android/PaintLayerOperation.cpp b/Source/WebCore/platform/graphics/android/PaintLayerOperation.cpp index 35867c7..c1ac865 100644 --- a/Source/WebCore/platform/graphics/android/PaintLayerOperation.cpp +++ b/Source/WebCore/platform/graphics/android/PaintLayerOperation.cpp @@ -42,7 +42,7 @@ void PaintLayerOperation::run() m_layer->paintBitmapGL(); } -SkLayer* PaintLayerOperation::baseLayer() +Layer* PaintLayerOperation::baseLayer() { if (!m_layer) return 0; diff --git a/Source/WebCore/platform/graphics/android/PaintLayerOperation.h b/Source/WebCore/platform/graphics/android/PaintLayerOperation.h index 74e87af..e688d87 100644 --- a/Source/WebCore/platform/graphics/android/PaintLayerOperation.h +++ b/Source/WebCore/platform/graphics/android/PaintLayerOperation.h @@ -28,7 +28,7 @@ #include "QueuedOperation.h" -class SkLayer; +class Layer; namespace WebCore { @@ -43,7 +43,7 @@ class PaintLayerOperation : public QueuedOperation { virtual ~PaintLayerOperation() {} virtual bool operator==(const QueuedOperation* operation); virtual void run(); - SkLayer* baseLayer(); + Layer* baseLayer(); LayerAndroid* layer() { return m_layer; } LayerTexture* texture(); @@ -53,11 +53,11 @@ class PaintLayerOperation : public QueuedOperation { class PaintLayerBaseFilter : public OperationFilter { public: - PaintLayerBaseFilter(SkLayer* layer) : m_baseLayer(layer) {} + PaintLayerBaseFilter(Layer* layer) : m_baseLayer(layer) {} virtual bool check(QueuedOperation* operation); private: - SkLayer* m_baseLayer; + Layer* m_baseLayer; }; class PaintLayerTextureFilter : public OperationFilter { diff --git a/Source/WebCore/platform/graphics/android/RasterRenderer.cpp b/Source/WebCore/platform/graphics/android/RasterRenderer.cpp index 025dbae..dc35cdd 100644 --- a/Source/WebCore/platform/graphics/android/RasterRenderer.cpp +++ b/Source/WebCore/platform/graphics/android/RasterRenderer.cpp @@ -34,7 +34,6 @@ #include "SkBitmapRef.h" #include "SkCanvas.h" #include "SkDevice.h" -#include "SkPicture.h" #include "TilesManager.h" #include <wtf/text/CString.h> @@ -59,7 +58,7 @@ namespace WebCore { static const String TAG_CREATE_BITMAP = "create_bitmap"; static const String TAG_DRAW_PICTURE = "draw_picture"; static const String TAG_UPDATE_TEXTURE = "update_texture"; -#define TAG_COUNT 4 +#define TAG_COUNT 3 static const String TAGS[] = { TAG_CREATE_BITMAP, TAG_DRAW_PICTURE, @@ -80,7 +79,7 @@ RasterRenderer::~RasterRenderer() #endif } -SkDevice* RasterRenderer::setupDevice(const TileRenderInfo& renderInfo) +void RasterRenderer::setupCanvas(const TileRenderInfo& renderInfo, SkCanvas* canvas) { if (renderInfo.measurePerf) m_perfMon.start(TAG_CREATE_BITMAP); @@ -98,7 +97,11 @@ SkDevice* RasterRenderer::setupDevice(const TileRenderInfo& renderInfo) m_perfMon.start(TAG_DRAW_PICTURE); } - return device; + canvas->setDevice(device); + device->unref(); + + // ensure the canvas origin is translated to the coordinates of our inval rect + canvas->translate(-renderInfo.invalRect->fLeft, -renderInfo.invalRect->fTop); } void RasterRenderer::renderingComplete(const TileRenderInfo& renderInfo, SkCanvas* canvas) @@ -117,27 +120,10 @@ void RasterRenderer::renderingComplete(const TileRenderInfo& renderInfo, SkCanva m_perfMon.stop(TAG_UPDATE_TEXTURE); } -void RasterRenderer::drawPerformanceInfo(SkCanvas* canvas) +const String* RasterRenderer::getPerformanceTags(int& tagCount) { - SkPaint paint; - char str[256]; - float total = 0; - for (int i = 0; i < TAG_COUNT; i++) { - float tagDuration = m_perfMon.getAverageDuration(TAGS[i]); - total += tagDuration; - snprintf(str, 256, "%s: %.2f", TAGS[i].utf8().data(), tagDuration); - paint.setARGB(255, 0, 0, 0); - int textY = (i * 12) + 25; - canvas->drawText(str, strlen(str), 0, textY, paint); - paint.setARGB(255, 255, 0, 0); - canvas->drawText(str, strlen(str), 0, textY + 1, paint); - } - snprintf(str, 256, "total: %.2f", total); - paint.setARGB(255, 0, 0, 0); - int textY = (TAG_COUNT * 12) + 30; - canvas->drawText(str, strlen(str), 0, textY, paint); - paint.setARGB(255, 255, 0, 0); - canvas->drawText(str, strlen(str), 0, textY + 1, paint); + tagCount = TAG_COUNT; + return TAGS; } } // namespace WebCore diff --git a/Source/WebCore/platform/graphics/android/RasterRenderer.h b/Source/WebCore/platform/graphics/android/RasterRenderer.h index 218d1b7..4308452 100644 --- a/Source/WebCore/platform/graphics/android/RasterRenderer.h +++ b/Source/WebCore/platform/graphics/android/RasterRenderer.h @@ -36,10 +36,6 @@ class SkDevice; namespace WebCore { -class BaseTileTexture; -class TextureInfo; -class TiledPage; - /** * */ @@ -50,9 +46,9 @@ public: protected: - virtual SkDevice* setupDevice(const TileRenderInfo& renderInfo); + virtual void setupCanvas(const TileRenderInfo& renderInfo, SkCanvas* canvas); virtual void renderingComplete(const TileRenderInfo& renderInfo, SkCanvas* canvas); - virtual void drawPerformanceInfo(SkCanvas* canvas); + virtual const String* getPerformanceTags(int& tagCount); }; diff --git a/Source/WebCore/platform/graphics/android/TextureOwner.h b/Source/WebCore/platform/graphics/android/TextureOwner.h index bd3a291..15395bb 100644 --- a/Source/WebCore/platform/graphics/android/TextureOwner.h +++ b/Source/WebCore/platform/graphics/android/TextureOwner.h @@ -30,12 +30,14 @@ namespace WebCore { class TiledPage; class BaseTileTexture; +class GLWebViewState; class TextureOwner { public: virtual ~TextureOwner() { } virtual bool removeTexture(BaseTileTexture* texture) = 0; virtual TiledPage* page() = 0; + virtual GLWebViewState* state() = 0; }; } diff --git a/Source/WebCore/platform/graphics/android/TiledPage.cpp b/Source/WebCore/platform/graphics/android/TiledPage.cpp index 0e1e947..b532d7a 100644 --- a/Source/WebCore/platform/graphics/android/TiledPage.cpp +++ b/Source/WebCore/platform/graphics/android/TiledPage.cpp @@ -171,6 +171,7 @@ void TiledPage::prepareRow(bool goingLeft, int tilesInRow, int firstTileX, int y if (currentTile) { currentTile->setScale(m_scale); + currentTile->setGLWebViewState(m_glWebViewState); // ensure there is a texture associated with the tile and then check to // see if the texture is dirty and in need of repainting diff --git a/Source/WebCore/platform/graphics/android/TilesManager.cpp b/Source/WebCore/platform/graphics/android/TilesManager.cpp index b4df0a1..ad4cbd3 100644 --- a/Source/WebCore/platform/graphics/android/TilesManager.cpp +++ b/Source/WebCore/platform/graphics/android/TilesManager.cpp @@ -93,6 +93,7 @@ TilesManager::TilesManager() , m_expandedTileBounds(false) , m_generatorReady(false) , m_showVisualIndicator(false) + , m_drawRegistrationCount(0) { XLOG("TilesManager ctor"); m_textures.reserveCapacity(MAX_TEXTURE_ALLOCATION); @@ -168,47 +169,41 @@ BaseTileTexture* TilesManager::getAvailableTexture(BaseTile* owner) } // The heuristic for selecting a texture is as follows: - // 1. return an unused texture if one exists - // 2. return the farthest texture from the viewport (from any tiled page) - // 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 + // 1. If usedLevel == -1, break with that one + // 2. Otherwise, select the highest usedLevel available + // 3. Break ties with the lowest LRU(RecentLevel) valued GLWebViewState + BaseTileTexture* farthestTexture = 0; int farthestTextureLevel = 0; + unsigned int lowestDrawCount = ~0; //maximum uint const unsigned int max = m_textures.size(); for (unsigned int i = 0; i < max; i++) { BaseTileTexture* texture = m_textures[i]; + if (texture->usedLevel() == -1) { // found an unused texture, grab it farthestTexture = texture; break; } - if (farthestTextureLevel < texture->usedLevel()) { - farthestTextureLevel = texture->usedLevel(); + + int textureLevel = texture->usedLevel(); + unsigned int textureDrawCount = getGLWebViewStateDrawCount(texture->owner()->state()); + + // if (higher distance or equal distance but less recently rendered) + if (farthestTextureLevel < textureLevel + || ((farthestTextureLevel == textureLevel) && (lowestDrawCount > textureDrawCount))) { farthestTexture = texture; + farthestTextureLevel = textureLevel; + lowestDrawCount = textureDrawCount; } } + if (farthestTexture && farthestTexture->acquire(owner)) { - XLOG("farthest texture, getAvailableTexture(%x) => texture %x (level %d)", - owner, farthestTexture, farthestTexture->usedLevel()); + XLOG("farthest texture, getAvailableTexture(%x) => texture %x (level %d, drawCount %d)", + owner, farthestTexture, farthestTextureLevel, lowestDrawCount); farthestTexture->setUsedLevel(0); return farthestTexture; } - // At this point, all textures are used or we failed to aquire the farthest - // texture. Now let's just grab a texture not in use by either of the two - // tiled pages associated with this view. - TiledPage* currentPage = owner->page(); - TiledPage* nextPage = currentPage->sibling(); - for (unsigned int i = 0; i < max; 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); - texture->setUsedLevel(0); - return texture; - } - } - XLOG("Couldn't find an available texture for BaseTile %x (%d, %d) !!!", owner, owner->x(), owner->y()); #ifdef DEBUG @@ -272,7 +267,7 @@ void TilesManager::printLayersTextures(const char* s) void TilesManager::cleanupLayersTextures(LayerAndroid* layer, bool forceCleanup) { android::Mutex::Autolock lock(m_texturesLock); - SkLayer* rootLayer = 0; + Layer* rootLayer = 0; if (layer) rootLayer = layer->getRootLayer(); #ifdef DEBUG @@ -355,6 +350,10 @@ LayerTexture* TilesManager::createTextureForLayer(LayerAndroid* layer, const Int if (m_layersMemoryUsage + size > MAX_LAYERS_ALLOCATION) cleanupLayersTextures(layer, true); + // If the cleanup can't achieve the goal, then don't create a layerTexture. + if (m_layersMemoryUsage + size > MAX_LAYERS_ALLOCATION) + return 0; + LayerTexture* texture = new LayerTexture(w, h); texture->setId(layer->uniqueId()); texture->setRect(rect); @@ -420,6 +419,25 @@ int TilesManager::expandedTileBoundsY() { return m_expandedTileBounds ? EXPANDED_TILE_BOUNDS_Y : 0; } +void TilesManager::registerGLWebViewState(GLWebViewState* state) +{ + m_glWebViewStateMap.set(state, m_drawRegistrationCount); + m_drawRegistrationCount++; + XLOG("now state %p, total of %d states", state, m_glWebViewStateMap.size()); +} + +void TilesManager::unregisterGLWebViewState(GLWebViewState* state) +{ + m_glWebViewStateMap.remove(state); + XLOG("state %p now removed, total of %d states", state, m_glWebViewStateMap.size()); +} + +unsigned int TilesManager::getGLWebViewStateDrawCount(GLWebViewState* state) +{ + XLOG("looking up state %p, contains=%s", state, m_glWebViewStateMap.contains(state) ? "TRUE" : "FALSE"); + return m_glWebViewStateMap.find(state)->second; +} + TilesManager* TilesManager::instance() { if (!gInstance) { diff --git a/Source/WebCore/platform/graphics/android/TilesManager.h b/Source/WebCore/platform/graphics/android/TilesManager.h index 5237c14..2ef9e66 100644 --- a/Source/WebCore/platform/graphics/android/TilesManager.h +++ b/Source/WebCore/platform/graphics/android/TilesManager.h @@ -37,6 +37,7 @@ #include "TiledPage.h" #include "VideoLayerManager.h" #include <utils/threads.h> +#include <wtf/HashMap.h> namespace WebCore { @@ -108,6 +109,8 @@ public: static float tileHeight(); int expandedTileBoundsX(); int expandedTileBoundsY(); + void registerGLWebViewState(GLWebViewState* state); + void unregisterGLWebViewState(GLWebViewState* state); void allocateTiles(); @@ -156,6 +159,11 @@ private: ShaderProgram m_shader; VideoLayerManager m_videoLayerManager; + + HashMap<GLWebViewState*, unsigned int> m_glWebViewStateMap; + unsigned int m_drawRegistrationCount; + + unsigned int getGLWebViewStateDrawCount(GLWebViewState* state); }; } // namespace WebCore diff --git a/Source/WebCore/platform/graphics/android/VideoLayerAndroid.h b/Source/WebCore/platform/graphics/android/VideoLayerAndroid.h index 0f3f007..abc1c13 100644 --- a/Source/WebCore/platform/graphics/android/VideoLayerAndroid.h +++ b/Source/WebCore/platform/graphics/android/VideoLayerAndroid.h @@ -44,7 +44,7 @@ namespace WebCore { // Otherwise will draw a static image. // NOTE: These values are matching the ones in HTML5VideoView.java // Please keep them in sync when changed here. -typedef enum {INITIALIZED, PREPARING, PREPARED, PLAYING} PlayerState; +typedef enum {INITIALIZED, PREPARING, PREPARED, PLAYING, RELEASED} PlayerState; class VideoLayerAndroid : public LayerAndroid { diff --git a/Source/WebKit/Android.mk b/Source/WebKit/Android.mk index 7a5fabf..3a47909 100644 --- a/Source/WebKit/Android.mk +++ b/Source/WebKit/Android.mk @@ -133,5 +133,5 @@ LOCAL_SRC_FILES += \ android/WebCoreSupport/autofill/AutoFillHostAndroid.cpp \ android/WebCoreSupport/autofill/FormFieldAndroid.cpp \ android/WebCoreSupport/autofill/FormManagerAndroid.cpp \ - android/WebCoreSupport/autofill/WebAutoFill.cpp + android/WebCoreSupport/autofill/WebAutofill.cpp endif # ENABLE_AUTOFILL == true diff --git a/Source/WebKit/android/WebCoreSupport/ChromiumIncludes.h b/Source/WebKit/android/WebCoreSupport/ChromiumIncludes.h index 1636405..670b307 100644 --- a/Source/WebKit/android/WebCoreSupport/ChromiumIncludes.h +++ b/Source/WebKit/android/WebCoreSupport/ChromiumIncludes.h @@ -91,7 +91,7 @@ #include <base/utf_string_conversions.h> #include <chrome/browser/autofill/autofill_host.h> #include <chrome/browser/profiles/profile.h> -#include <chrome/browser/tab_contents/tab_contents.h> +#include <content/browser/tab_contents/tab_contents.h> #include <webkit/glue/form_data.h> #endif diff --git a/Source/WebKit/android/WebCoreSupport/EditorClientAndroid.cpp b/Source/WebKit/android/WebCoreSupport/EditorClientAndroid.cpp index 2667b71..785f0a8 100644 --- a/Source/WebKit/android/WebCoreSupport/EditorClientAndroid.cpp +++ b/Source/WebKit/android/WebCoreSupport/EditorClientAndroid.cpp @@ -270,10 +270,10 @@ void EditorClientAndroid::willSetInputMethodState() void EditorClientAndroid::requestCheckingOfString(SpellChecker*, int, TextCheckingTypeMask, const String&) {} #if ENABLE(WEB_AUTOFILL) -WebAutoFill* EditorClientAndroid::getAutoFill() +WebAutofill* EditorClientAndroid::getAutofill() { if (!m_autoFill) - m_autoFill.set(new WebAutoFill()); + m_autoFill.set(new WebAutofill()); return m_autoFill.get(); } diff --git a/Source/WebKit/android/WebCoreSupport/EditorClientAndroid.h b/Source/WebKit/android/WebCoreSupport/EditorClientAndroid.h index 9bf6e1f..385d75c 100644 --- a/Source/WebKit/android/WebCoreSupport/EditorClientAndroid.h +++ b/Source/WebKit/android/WebCoreSupport/EditorClientAndroid.h @@ -32,7 +32,7 @@ #include "EditorClient.h" #include "Page.h" #include "TextCheckerClient.h" -#include "autofill/WebAutoFill.h" +#include "autofill/WebAutofill.h" #include <wtf/OwnPtr.h> @@ -124,14 +124,14 @@ public: void setShouldChangeSelectedRange(bool shouldChangeSelectedRange) { m_shouldChangeSelectedRange = shouldChangeSelectedRange; } void setUiGeneratedSelectionChange(bool uiGenerated) { m_uiGeneratedSelectionChange = uiGenerated; } #if ENABLE(WEB_AUTOFILL) - WebAutoFill* getAutoFill(); + WebAutofill* getAutofill(); #endif private: Page* m_page; bool m_shouldChangeSelectedRange; bool m_uiGeneratedSelectionChange; #if ENABLE(WEB_AUTOFILL) - OwnPtr<WebAutoFill> m_autoFill; + OwnPtr<WebAutofill> m_autoFill; #endif }; diff --git a/Source/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp b/Source/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp index 99f34d5..88ab4a3 100644 --- a/Source/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp +++ b/Source/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp @@ -76,7 +76,7 @@ #include "WebFrameView.h" #include "WebViewClientError.h" #include "WebViewCore.h" -#include "autofill/WebAutoFill.h" +#include "autofill/WebAutofill.h" #include "android_graphics.h" #include <utils/AssetManager.h> @@ -301,7 +301,7 @@ void FrameLoaderClientAndroid::dispatchDidCommitLoad() { #if ENABLE(WEB_AUTOFILL) if (m_frame == m_frame->page()->mainFrame()) { EditorClientAndroid* editorC = static_cast<EditorClientAndroid*>(m_frame->page()->editorClient()); - WebAutoFill* autoFill = editorC->getAutoFill(); + WebAutofill* autoFill = editorC->getAutofill(); autoFill->reset(); } #endif diff --git a/Source/WebKit/android/WebCoreSupport/WebRequestContext.cpp b/Source/WebKit/android/WebCoreSupport/WebRequestContext.cpp index f51ba53..43f5eb1 100644 --- a/Source/WebKit/android/WebCoreSupport/WebRequestContext.cpp +++ b/Source/WebKit/android/WebCoreSupport/WebRequestContext.cpp @@ -61,15 +61,15 @@ WebRequestContext::WebRequestContext(bool isPrivateBrowsing) } WebCache* cache = WebCache::get(m_isPrivateBrowsing); - host_resolver_ = cache->hostResolver(); - http_transaction_factory_ = cache->cache(); + set_host_resolver(cache->hostResolver()); + set_http_transaction_factory(cache->cache()); WebCookieJar* cookieJar = WebCookieJar::get(m_isPrivateBrowsing); - cookie_store_ = cookieJar->cookieStore(); - cookie_policy_ = cookieJar; + set_cookie_store(cookieJar->cookieStore()); + set_cookie_policy(cookieJar); // Also hardcoded in FrameLoader.java - accept_charset_ = "utf-8, iso-8859-1, utf-16, *;q=0.7"; + set_accept_charset("utf-8, iso-8859-1, utf-16, *;q=0.7"); } WebRequestContext::~WebRequestContext() diff --git a/Source/WebKit/android/WebCoreSupport/autofill/AutoFillHostAndroid.cpp b/Source/WebKit/android/WebCoreSupport/autofill/AutoFillHostAndroid.cpp index 5bc4c92..d2dc201 100644 --- a/Source/WebKit/android/WebCoreSupport/autofill/AutoFillHostAndroid.cpp +++ b/Source/WebKit/android/WebCoreSupport/autofill/AutoFillHostAndroid.cpp @@ -26,26 +26,26 @@ #include "config.h" #include "AutoFillHostAndroid.h" -#include "autofill/WebAutoFill.h" +#include "autofill/WebAutofill.h" namespace android { -AutoFillHostAndroid::AutoFillHostAndroid(WebAutoFill* autoFill) - : mAutoFill(autoFill) +AutoFillHostAndroid::AutoFillHostAndroid(WebAutofill* autofill) + : mAutofill(autofill) { } void AutoFillHostAndroid::AutoFillSuggestionsReturned(const std::vector<string16>& names, const std::vector<string16>& labels, const std::vector<string16>& icons, const std::vector<int>& uniqueIds) { // TODO: what do we do with icons? - if (mAutoFill) - mAutoFill->querySuccessful(names[0], labels[0], uniqueIds[0]); + if (mAutofill) + mAutofill->querySuccessful(names[0], labels[0], uniqueIds[0]); } void AutoFillHostAndroid::AutoFillFormDataFilled(int queryId, const webkit_glue::FormData& form) { - if (mAutoFill) - mAutoFill->fillFormInPage(queryId, form); + if (mAutofill) + mAutofill->fillFormInPage(queryId, form); } } diff --git a/Source/WebKit/android/WebCoreSupport/autofill/AutoFillHostAndroid.h b/Source/WebKit/android/WebCoreSupport/autofill/AutoFillHostAndroid.h index 9677b46..31767d5 100644 --- a/Source/WebKit/android/WebCoreSupport/autofill/AutoFillHostAndroid.h +++ b/Source/WebKit/android/WebCoreSupport/autofill/AutoFillHostAndroid.h @@ -35,19 +35,19 @@ class FormData; } namespace android { -class WebAutoFill; +class WebAutofill; -// This class receives the callbacks from the AutoFillManager in the Chromium code. +// This class receives the callbacks from the AutofillManager in the Chromium code. class AutoFillHostAndroid : public AutoFillHost { public: - AutoFillHostAndroid(WebAutoFill* autoFill); + AutoFillHostAndroid(WebAutofill* autofill); virtual ~AutoFillHostAndroid() { } virtual void AutoFillSuggestionsReturned(const std::vector<string16>& names, const std::vector<string16>& labels, const std::vector<string16>& icons, const std::vector<int>& uniqueIds); virtual void AutoFillFormDataFilled(int queryId, const webkit_glue::FormData&); private: - WebAutoFill* mAutoFill; + WebAutofill* mAutofill; }; } diff --git a/Source/WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp b/Source/WebKit/android/WebCoreSupport/autofill/WebAutofill.cpp index 1fdb671..ff4f593 100644 --- a/Source/WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp +++ b/Source/WebKit/android/WebCoreSupport/autofill/WebAutofill.cpp @@ -24,7 +24,7 @@ */ #include "config.h" -#include "WebAutoFill.h" +#include "WebAutofill.h" #if ENABLE(WEB_AUTOFILL) @@ -48,7 +48,7 @@ namespace android { -WebAutoFill::WebAutoFill() +WebAutofill::WebAutofill() : mQueryId(1) , mWebViewCore(0) , mLastSearchDomVersion(0) @@ -58,34 +58,34 @@ WebAutoFill::WebAutoFill() setEmptyProfile(); } -void WebAutoFill::init() +void WebAutofill::init() { - if (mAutoFillManager) + if (mAutofillManager) return; mFormManager = new FormManager(); // We use the WebView's WebRequestContext, which may be a private browsing context. ASSERT(mWebViewCore); - mAutoFillManager = new AutoFillManager(mTabContents.get()); - mAutoFillHost = new AutoFillHostAndroid(this); + mAutofillManager = new AutofillManager(mTabContents.get()); + mAutofillHost = new AutoFillHostAndroid(this); mTabContents->SetProfileRequestContext(new AndroidURLRequestContextGetter(mWebViewCore->webRequestContext(), WebUrlLoaderClient::ioThread())); - mTabContents->SetAutoFillHost(mAutoFillHost.get()); + mTabContents->SetAutoFillHost(mAutofillHost.get()); } -WebAutoFill::~WebAutoFill() +WebAutofill::~WebAutofill() { cleanUpQueryMap(); mUniqueIdMap.clear(); } -void WebAutoFill::cleanUpQueryMap() +void WebAutofill::cleanUpQueryMap() { - for (AutoFillQueryFormDataMap::iterator it = mQueryMap.begin(); it != mQueryMap.end(); it++) + for (AutofillQueryFormDataMap::iterator it = mQueryMap.begin(); it != mQueryMap.end(); it++) delete it->second; mQueryMap.clear(); } -void WebAutoFill::searchDocument(WebCore::Frame* frame) +void WebAutofill::searchDocument(WebCore::Frame* frame) { if (!enabled()) return; @@ -100,41 +100,41 @@ void WebAutoFill::searchDocument(WebCore::Frame* frame) mQueryId = 1; ASSERT(mFormManager); - ASSERT(mAutoFillManager); + ASSERT(mAutofillManager); - mAutoFillManager->Reset(); + mAutofillManager->Reset(); mFormManager->Reset(); mFormManager->ExtractForms(frame); mFormManager->GetFormsInFrame(frame, FormManager::REQUIRE_AUTOCOMPLETE, &mForms); - // Needs to be done on a Chrome thread as it will make a URL request to the AutoFill server. + // Needs to be done on a Chrome thread as it will make a URL request to the Autofill server. // TODO: Use our own Autofill thread instead of the IO thread. // TODO: For now, block here. Would like to make this properly async. base::Thread* thread = WebUrlLoaderClient::ioThread(); mParsingForms = true; - thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(this, &WebAutoFill::formsSeenImpl)); + thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(this, &WebAutofill::formsSeenImpl)); while (mParsingForms) mFormsSeenCondition.wait(mFormsSeenMutex); } // Called on the Chromium IO thread. -void WebAutoFill::formsSeenImpl() +void WebAutofill::formsSeenImpl() { MutexLocker lock(mFormsSeenMutex); - mAutoFillManager->OnFormsSeenWrapper(mForms); + mAutofillManager->OnFormsSeenWrapper(mForms); mParsingForms = false; mFormsSeenCondition.signal(); } -void WebAutoFill::formFieldFocused(WebCore::HTMLFormControlElement* formFieldElement) +void WebAutofill::formFieldFocused(WebCore::HTMLFormControlElement* formFieldElement) { ASSERT(formFieldElement); Document* doc = formFieldElement->document(); Frame* frame = doc->frame(); - // FIXME: AutoFill only works in main frame for now. Should consider + // FIXME: Autofill only works in main frame for now. Should consider // child frames. if (frame != frame->page()->mainFrame()) return; @@ -166,7 +166,7 @@ void WebAutoFill::formFieldFocused(WebCore::HTMLFormControlElement* formFieldEle mFormManager->FindFormWithFormControlElement(formFieldElement, FormManager::REQUIRE_AUTOCOMPLETE, form); mQueryMap[mQueryId] = new FormDataAndField(form, formField); - bool suggestions = mAutoFillManager->OnQueryFormFieldAutoFillWrapper(*form, *formField); + bool suggestions = mAutofillManager->OnQueryFormFieldAutoFillWrapper(*form, *formField); mQueryId++; if (!suggestions) { @@ -177,7 +177,7 @@ void WebAutoFill::formFieldFocused(WebCore::HTMLFormControlElement* formFieldEle } } -void WebAutoFill::querySuccessful(const string16& value, const string16& label, int uniqueId) +void WebAutofill::querySuccessful(const string16& value, const string16& label, int uniqueId) { if (!enabled()) return; @@ -187,10 +187,10 @@ void WebAutoFill::querySuccessful(const string16& value, const string16& label, mUniqueIdMap[mQueryId] = uniqueId; ASSERT(mWebViewCore); - mWebViewCore->setWebTextViewAutoFillable(mQueryId, mAutoFillProfile->Label()); + mWebViewCore->setWebTextViewAutoFillable(mQueryId, mAutofillProfile->Label()); } -void WebAutoFill::fillFormFields(int queryId) +void WebAutofill::fillFormFields(int queryId) { if (!enabled()) return; @@ -200,23 +200,23 @@ void WebAutoFill::fillFormFields(int queryId) ASSERT(form); ASSERT(field); - AutoFillQueryToUniqueIdMap::iterator iter = mUniqueIdMap.find(queryId); + AutofillQueryToUniqueIdMap::iterator iter = mUniqueIdMap.find(queryId); if (iter == mUniqueIdMap.end()) { - // The user has most likely tried to AutoFill the form again without + // The user has most likely tried to Autofill the form again without // refocussing the form field. The UI should protect against this // but stop here to be certain. return; } - mAutoFillManager->OnFillAutoFillFormDataWrapper(queryId, *form, *field, iter->second); + mAutofillManager->OnFillAutoFillFormDataWrapper(queryId, *form, *field, iter->second); mUniqueIdMap.erase(iter); } -void WebAutoFill::fillFormInPage(int queryId, const webkit_glue::FormData& form) +void WebAutofill::fillFormInPage(int queryId, const webkit_glue::FormData& form) { if (!enabled()) return; - // FIXME: Pass a pointer to the Node that triggered the AutoFill flow here instead of 0. + // FIXME: Pass a pointer to the Node that triggered the Autofill flow here instead of 0. // The consquence of passing 0 is that we should always fail the test in FormManader::ForEachMathcingFormField():169 // that says "only overwrite an elements current value if the user triggered autofill through that element" // for elements that have a value already. But by a quirk of Android text views we are OK. We should still @@ -224,58 +224,58 @@ void WebAutoFill::fillFormInPage(int queryId, const webkit_glue::FormData& form) mFormManager->FillForm(form, 0); } -bool WebAutoFill::enabled() const +bool WebAutofill::enabled() const { Page* page = mWebViewCore->mainFrame()->page(); return page ? page->settings()->autoFillEnabled() : false; } -void WebAutoFill::setProfile(const string16& fullName, const string16& emailAddress, const string16& companyName, +void WebAutofill::setProfile(const string16& fullName, const string16& emailAddress, const string16& companyName, const string16& addressLine1, const string16& addressLine2, const string16& city, const string16& state, const string16& zipCode, const string16& country, const string16& phoneNumber) { - if (!mAutoFillProfile) - mAutoFillProfile.set(new AutoFillProfile()); + if (!mAutofillProfile) + mAutofillProfile.set(new AutoFillProfile()); // Update the profile. - // Constants for AutoFill field types are found in external/chromium/chrome/browser/autofill/field_types.h. - mAutoFillProfile->SetInfo(AutoFillType(NAME_FULL), fullName); - mAutoFillProfile->SetInfo(AutoFillType(EMAIL_ADDRESS), emailAddress); - mAutoFillProfile->SetInfo(AutoFillType(COMPANY_NAME), companyName); - mAutoFillProfile->SetInfo(AutoFillType(ADDRESS_HOME_LINE1), addressLine1); - mAutoFillProfile->SetInfo(AutoFillType(ADDRESS_HOME_LINE2), addressLine2); - mAutoFillProfile->SetInfo(AutoFillType(ADDRESS_HOME_CITY), city); - mAutoFillProfile->SetInfo(AutoFillType(ADDRESS_HOME_STATE), state); - mAutoFillProfile->SetInfo(AutoFillType(ADDRESS_HOME_ZIP), zipCode); - mAutoFillProfile->SetInfo(AutoFillType(ADDRESS_HOME_COUNTRY), country); - mAutoFillProfile->SetInfo(AutoFillType(PHONE_HOME_WHOLE_NUMBER), phoneNumber); + // Constants for Autofill field types are found in external/chromium/chrome/browser/autofill/field_types.h. + mAutofillProfile->SetInfo(AutofillType(NAME_FULL), fullName); + mAutofillProfile->SetInfo(AutofillType(EMAIL_ADDRESS), emailAddress); + mAutofillProfile->SetInfo(AutofillType(COMPANY_NAME), companyName); + mAutofillProfile->SetInfo(AutofillType(ADDRESS_HOME_LINE1), addressLine1); + mAutofillProfile->SetInfo(AutofillType(ADDRESS_HOME_LINE2), addressLine2); + mAutofillProfile->SetInfo(AutofillType(ADDRESS_HOME_CITY), city); + mAutofillProfile->SetInfo(AutofillType(ADDRESS_HOME_STATE), state); + mAutofillProfile->SetInfo(AutofillType(ADDRESS_HOME_ZIP), zipCode); + mAutofillProfile->SetInfo(AutofillType(ADDRESS_HOME_COUNTRY), country); + mAutofillProfile->SetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER), phoneNumber); std::vector<AutoFillProfile> profiles; - profiles.push_back(*mAutoFillProfile); + profiles.push_back(*mAutofillProfile); updateProfileLabel(); mTabContents->profile()->GetPersonalDataManager()->SetProfiles(&profiles); } -bool WebAutoFill::updateProfileLabel() +bool WebAutofill::updateProfileLabel() { std::vector<AutoFillProfile*> profiles; - profiles.push_back(mAutoFillProfile.get()); + profiles.push_back(mAutofillProfile.get()); return AutoFillProfile::AdjustInferredLabels(&profiles); } -void WebAutoFill::clearProfiles() +void WebAutofill::clearProfiles() { - if (!mAutoFillProfile) + if (!mAutofillProfile) return; // For now Chromium only ever knows about one profile, so we can just // remove it. If we support multiple profiles in the future // we need to remove them all here. - std::string profileGuid = mAutoFillProfile->guid(); + std::string profileGuid = mAutofillProfile->guid(); mTabContents->profile()->GetPersonalDataManager()->RemoveProfile(profileGuid); setEmptyProfile(); } -void WebAutoFill::setEmptyProfile() +void WebAutofill::setEmptyProfile() { // Set an empty profile. This will ensure that when autofill is enabled, // we will still search the document for autofillable forms and inform @@ -285,7 +285,7 @@ void WebAutoFill::setEmptyProfile() // Chromium code will strip the values sent into the profile so we need them to be // at least one non-whitespace character long. We need to set all fields of the // profile to a non-empty string so that any field type can trigger the autofill - // suggestion. AutoFill will not detect form fields if the profile value for that + // suggestion. Autofill will not detect form fields if the profile value for that // field is an empty string. static const string16 empty = string16(ASCIIToUTF16("a")); setProfile(empty, empty, empty, empty, empty, empty, empty, empty, empty, empty); diff --git a/Source/WebKit/android/WebCoreSupport/autofill/WebAutoFill.h b/Source/WebKit/android/WebCoreSupport/autofill/WebAutofill.h index 4dbd8ba..a2f56a2 100644 --- a/Source/WebKit/android/WebCoreSupport/autofill/WebAutoFill.h +++ b/Source/WebKit/android/WebCoreSupport/autofill/WebAutofill.h @@ -36,7 +36,7 @@ #include <wtf/OwnPtr.h> #include <wtf/ThreadingPrimitives.h> -class AutoFillManager; +class AutofillManager; class AutoFillProfile; class AutoFillHost; @@ -66,12 +66,12 @@ private: OwnPtr<webkit_glue::FormField> mField; }; -class WebAutoFill +class WebAutofill { - WTF_MAKE_NONCOPYABLE(WebAutoFill); + WTF_MAKE_NONCOPYABLE(WebAutofill); public: - WebAutoFill(); - virtual ~WebAutoFill(); + WebAutofill(); + virtual ~WebAutofill(); void formFieldFocused(WebCore::HTMLFormControlElement*); void fillFormFields(int queryId); void querySuccessful(const string16& value, const string16& label, int uniqueId); @@ -96,19 +96,19 @@ private: void cleanUpQueryMap(); OwnPtr<FormManager> mFormManager; - OwnPtr<AutoFillManager> mAutoFillManager; - OwnPtr<AutoFillHost> mAutoFillHost; + OwnPtr<AutofillManager> mAutofillManager; + OwnPtr<AutoFillHost> mAutofillHost; OwnPtr<TabContents> mTabContents; - OwnPtr<AutoFillProfile> mAutoFillProfile; + OwnPtr<AutoFillProfile> mAutofillProfile; typedef std::vector<webkit_glue::FormData, std::allocator<webkit_glue::FormData> > FormList; FormList mForms; - typedef std::map<int, FormDataAndField*> AutoFillQueryFormDataMap; - AutoFillQueryFormDataMap mQueryMap; + typedef std::map<int, FormDataAndField*> AutofillQueryFormDataMap; + AutofillQueryFormDataMap mQueryMap; - typedef std::map<int, int> AutoFillQueryToUniqueIdMap; - AutoFillQueryToUniqueIdMap mUniqueIdMap; + typedef std::map<int, int> AutofillQueryToUniqueIdMap; + AutofillQueryToUniqueIdMap mUniqueIdMap; int mQueryId; WebViewCore* mWebViewCore; @@ -122,7 +122,7 @@ private: } -DISABLE_RUNNABLE_METHOD_REFCOUNT(android::WebAutoFill); +DISABLE_RUNNABLE_METHOD_REFCOUNT(android::WebAutofill); #endif // ENABLE(WEB_AUTOFILL) #endif // WebAutoFill_h diff --git a/Source/WebKit/android/jni/ViewStateSerializer.cpp b/Source/WebKit/android/jni/ViewStateSerializer.cpp index 7ec77ed..794c118 100644 --- a/Source/WebKit/android/jni/ViewStateSerializer.cpp +++ b/Source/WebKit/android/jni/ViewStateSerializer.cpp @@ -27,10 +27,10 @@ #include "BaseLayerAndroid.h" #include "CreateJavaOutputStreamAdaptor.h" +#include "Layer.h" #include "LayerAndroid.h" #include "PictureSet.h" #include "ScrollableLayerAndroid.h" -#include "SkLayer.h" #include "SkPicture.h" #include <JNIUtility.h> @@ -256,7 +256,7 @@ void serializeLayer(LayerAndroid* layer, SkWStream* stream) : LTLayerAndroid; stream->write8(type); - // Start with SkLayer fields + // Start with Layer fields stream->writeBool(layer->isInheritFromRootTransform()); stream->writeScalar(layer->getOpacity()); stream->writeScalar(layer->getSize().width()); @@ -337,7 +337,7 @@ LayerAndroid* deserializeLayer(SkStream* stream) return 0; } - // SkLayer fields + // Layer fields layer->setInheritFromRootTransform(stream->readBool()); layer->setOpacity(stream->readScalar()); layer->setSize(stream->readScalar(), stream->readScalar()); diff --git a/Source/WebKit/android/jni/WebCoreFrameBridge.cpp b/Source/WebKit/android/jni/WebCoreFrameBridge.cpp index fb558c6..bdb502e 100644 --- a/Source/WebKit/android/jni/WebCoreFrameBridge.cpp +++ b/Source/WebKit/android/jni/WebCoreFrameBridge.cpp @@ -124,7 +124,7 @@ #endif #if ENABLE(WEB_AUTOFILL) -#include "autofill/WebAutoFill.h" +#include "autofill/WebAutofill.h" #endif using namespace JSC::Bindings; @@ -1334,7 +1334,7 @@ static void CreateFrame(JNIEnv* env, jobject obj, jobject javaview, jobject jAss WebViewCore* webViewCore = new WebViewCore(env, javaview, frame); #if ENABLE(WEB_AUTOFILL) - editorC->getAutoFill()->setWebViewCore(webViewCore); + editorC->getAutofill()->setWebViewCore(webViewCore); #endif // Create a FrameView diff --git a/Source/WebKit/android/jni/WebSettings.cpp b/Source/WebKit/android/jni/WebSettings.cpp index 6f18695..589615d 100644 --- a/Source/WebKit/android/jni/WebSettings.cpp +++ b/Source/WebKit/android/jni/WebSettings.cpp @@ -293,7 +293,7 @@ inline string16 getStringFieldAsString16(JNIEnv* env, jobject autoFillProfile, j return str ? jstringToString16(env, str) : string16(); } -void syncAutoFillProfile(JNIEnv* env, jobject autoFillProfile, WebAutoFill* webAutoFill) +void syncAutoFillProfile(JNIEnv* env, jobject autoFillProfile, WebAutofill* webAutofill) { string16 fullName = getStringFieldAsString16(env, autoFillProfile, gFieldIds->mAutoFillProfileFullName); string16 emailAddress = getStringFieldAsString16(env, autoFillProfile, gFieldIds->mAutoFillProfileEmailAddress); @@ -306,7 +306,7 @@ void syncAutoFillProfile(JNIEnv* env, jobject autoFillProfile, WebAutoFill* webA string16 country = getStringFieldAsString16(env, autoFillProfile, gFieldIds->mAutoFillProfileCountry); string16 phoneNumber = getStringFieldAsString16(env, autoFillProfile, gFieldIds->mAutoFillProfilePhoneNumber); - webAutoFill->setProfile(fullName, emailAddress, companyName, addressLine1, addressLine2, city, state, zipCode, country, phoneNumber); + webAutofill->setProfile(fullName, emailAddress, companyName, addressLine1, addressLine2, city, state, zipCode, country, phoneNumber); } #endif @@ -554,16 +554,16 @@ public: if (flag) { EditorClientAndroid* editorC = static_cast<EditorClientAndroid*>(pFrame->page()->editorClient()); - WebAutoFill* webAutoFill = editorC->getAutoFill(); - // Set the active AutoFillProfile data. + WebAutofill* webAutofill = editorC->getAutofill(); + // Set the active AutofillProfile data. jobject autoFillProfile = env->GetObjectField(obj, gFieldIds->mAutoFillProfile); if (autoFillProfile) - syncAutoFillProfile(env, autoFillProfile, webAutoFill); + syncAutoFillProfile(env, autoFillProfile, webAutofill); else { // The autofill profile is null. We need to tell Chromium about this because // this may be because the user just deleted their profile but left the // autofill feature setting enabled. - webAutoFill->clearProfiles(); + webAutofill->clearProfiles(); } } #endif diff --git a/Source/WebKit/android/jni/WebViewCore.cpp b/Source/WebKit/android/jni/WebViewCore.cpp index 96045c6..966a540 100644 --- a/Source/WebKit/android/jni/WebViewCore.cpp +++ b/Source/WebKit/android/jni/WebViewCore.cpp @@ -117,7 +117,7 @@ #include "WebFrameView.h" #include "WindowsKeyboardCodes.h" #include "android_graphics.h" -#include "autofill/WebAutoFill.h" +#include "autofill/WebAutofill.h" #include "htmlediting.h" #include "markup.h" @@ -3279,7 +3279,7 @@ bool WebViewCore::handleMouseClick(WebCore::Frame* framePtr, WebCore::Node* node #if ENABLE(WEB_AUTOFILL) if (renderer->isTextField()) { EditorClientAndroid* editorC = static_cast<EditorClientAndroid*>(framePtr->page()->editorClient()); - WebAutoFill* autoFill = editorC->getAutoFill(); + WebAutofill* autoFill = editorC->getAutofill(); autoFill->formFieldFocused(static_cast<HTMLFormControlElement*>(focusNode)); } #endif @@ -4566,7 +4566,7 @@ static void AutoFillForm(JNIEnv* env, jobject obj, jint queryId) WebCore::Frame* frame = viewImpl->mainFrame(); if (frame) { EditorClientAndroid* editorC = static_cast<EditorClientAndroid*>(frame->page()->editorClient()); - WebAutoFill* autoFill = editorC->getAutoFill(); + WebAutofill* autoFill = editorC->getAutofill(); autoFill->fillFormFields(queryId); } #endif diff --git a/Source/WebKit/android/nav/CacheBuilder.cpp b/Source/WebKit/android/nav/CacheBuilder.cpp index a31169b..3ec15f3 100644 --- a/Source/WebKit/android/nav/CacheBuilder.cpp +++ b/Source/WebKit/android/nav/CacheBuilder.cpp @@ -2893,7 +2893,7 @@ bool CacheBuilder::setData(CachedFrame* cachedFrame) if ((x | y) != 0) viewBounds.setLocation(WebCore::IntPoint(x, y)); cachedFrame->setLocalViewBounds(viewBounds); - cachedFrame->setContentsSize(layer->width(), layer->height()); + cachedFrame->setContentsSize(layer->scrollWidth(), layer->scrollHeight()); if (cachedFrame->childCount() == 0) return true; CachedFrame* lastCachedFrame = cachedFrame->lastChild(); diff --git a/Source/WebKit/android/nav/CachedLayer.cpp b/Source/WebKit/android/nav/CachedLayer.cpp index 299f2d1..f6dfb88 100644 --- a/Source/WebKit/android/nav/CachedLayer.cpp +++ b/Source/WebKit/android/nav/CachedLayer.cpp @@ -102,7 +102,7 @@ IntRect CachedLayer::adjustBounds(const LayerAndroid* root, FloatPoint CachedLayer::getGlobalPosition(const LayerAndroid* aLayer) const { SkPoint result = aLayer->getPosition(); - const SkLayer* parent = aLayer->getParent(); + const Layer* parent = aLayer->getParent(); while (parent) { result += parent->getPosition(); DBG_NAV_LOGV("result=(%g,%g) parent=%p [%d]", result.fX, result.fY, |