diff options
Diffstat (limited to 'Source/WebCore')
11 files changed, 83 insertions, 48 deletions
diff --git a/Source/WebCore/platform/graphics/android/context/GraphicsOperation.h b/Source/WebCore/platform/graphics/android/context/GraphicsOperation.h index 4a27fe9..978e087 100644 --- a/Source/WebCore/platform/graphics/android/context/GraphicsOperation.h +++ b/Source/WebCore/platform/graphics/android/context/GraphicsOperation.h @@ -105,7 +105,7 @@ public: virtual ~Operation() {} virtual OperationType type() { return UndefinedOperation; } virtual String parameters() { return ""; } - String name() + const char* name() { switch (type()) { TYPE_CASE(UndefinedOperation) diff --git a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContext.cpp b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContext.cpp index 3b37693..f9d7f21 100644 --- a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContext.cpp +++ b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContext.cpp @@ -246,22 +246,31 @@ void PlatformGraphicsContext::setCompositeOperation(CompositeOperator op) m_state->mode = WebCoreCompositeToSkiaComposite(op); } -void PlatformGraphicsContext::setFillColor(const Color& c) +bool PlatformGraphicsContext::setFillColor(const Color& c) { - m_state->fillColor = c.rgb(); - setFillShader(0); + bool dirty = false; + if (m_state->fillColor != c.rgb()) { + m_state->fillColor = c.rgb(); + dirty = true; + } + return setFillShader(0) || dirty; } -void PlatformGraphicsContext::setFillShader(SkShader* fillShader) +bool PlatformGraphicsContext::setFillShader(SkShader* fillShader) { - if (fillShader) + bool dirty = false; + if (fillShader && m_state->fillColor != Color::black) { m_state->fillColor = Color::black; + dirty = true; + } if (fillShader != m_state->fillShader) { SkSafeUnref(m_state->fillShader); m_state->fillShader = fillShader; SkSafeRef(m_state->fillShader); + dirty = true; } + return dirty; } void PlatformGraphicsContext::setLineCap(LineCap cap) @@ -333,22 +342,31 @@ void PlatformGraphicsContext::setShouldAntialias(bool useAA) m_state->useAA = useAA; } -void PlatformGraphicsContext::setStrokeColor(const Color& c) +bool PlatformGraphicsContext::setStrokeColor(const Color& c) { - m_state->strokeColor = c.rgb(); - setStrokeShader(0); + bool dirty = false; + if (m_state->strokeColor != c.rgb()) { + m_state->strokeColor = c.rgb(); + dirty = true; + } + return setStrokeShader(0) || dirty; } -void PlatformGraphicsContext::setStrokeShader(SkShader* strokeShader) +bool PlatformGraphicsContext::setStrokeShader(SkShader* strokeShader) { - if (strokeShader) + bool dirty = false; + if (strokeShader && m_state->strokeColor != Color::black) { m_state->strokeColor = Color::black; + dirty = true; + } if (strokeShader != m_state->strokeShader) { SkSafeUnref(m_state->strokeShader); m_state->strokeShader = strokeShader; SkSafeRef(m_state->strokeShader); + dirty = true; } + return dirty; } void PlatformGraphicsContext::setStrokeStyle(StrokeStyle style) diff --git a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContext.h b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContext.h index 1916014..69ccdaf 100644 --- a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContext.h +++ b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContext.h @@ -61,16 +61,16 @@ public: virtual void setAlpha(float alpha); int getNormalizedAlpha() const; virtual void setCompositeOperation(CompositeOperator op); - virtual void setFillColor(const Color& c); - virtual void setFillShader(SkShader* fillShader); + virtual bool setFillColor(const Color& c); + virtual bool setFillShader(SkShader* fillShader); virtual void setLineCap(LineCap cap); virtual void setLineDash(const DashArray& dashes, float dashOffset); virtual void setLineJoin(LineJoin join); virtual void setMiterLimit(float limit); virtual void setShadow(int radius, int dx, int dy, SkColor c); virtual void setShouldAntialias(bool useAA); - virtual void setStrokeColor(const Color& c); - virtual void setStrokeShader(SkShader* strokeShader); + virtual bool setStrokeColor(const Color& c); + virtual bool setStrokeShader(SkShader* strokeShader); virtual void setStrokeStyle(StrokeStyle style); virtual void setStrokeThickness(float f); diff --git a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp index d96124d..39194a0 100644 --- a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp +++ b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp @@ -88,16 +88,22 @@ void PlatformGraphicsContextRecording::setCompositeOperation(CompositeOperator o mGraphicsOperationCollection->append(new GraphicsOperation::SetCompositeOperation(op)); } -void PlatformGraphicsContextRecording::setFillColor(const Color& c) +bool PlatformGraphicsContextRecording::setFillColor(const Color& c) { - PlatformGraphicsContext::setFillColor(c); - mGraphicsOperationCollection->append(new GraphicsOperation::SetFillColor(c)); + if (PlatformGraphicsContext::setFillColor(c)) { + mGraphicsOperationCollection->append(new GraphicsOperation::SetFillColor(c)); + return true; + } + return false; } -void PlatformGraphicsContextRecording::setFillShader(SkShader* fillShader) +bool PlatformGraphicsContextRecording::setFillShader(SkShader* fillShader) { - PlatformGraphicsContext::setFillShader(fillShader); - mGraphicsOperationCollection->append(new GraphicsOperation::SetFillShader(fillShader)); + if (PlatformGraphicsContext::setFillShader(fillShader)) { + mGraphicsOperationCollection->append(new GraphicsOperation::SetFillShader(fillShader)); + return true; + } + return false; } void PlatformGraphicsContextRecording::setLineCap(LineCap cap) @@ -137,16 +143,22 @@ void PlatformGraphicsContextRecording::setShouldAntialias(bool useAA) mGraphicsOperationCollection->append(new GraphicsOperation::SetShouldAntialias(useAA)); } -void PlatformGraphicsContextRecording::setStrokeColor(const Color& c) +bool PlatformGraphicsContextRecording::setStrokeColor(const Color& c) { - PlatformGraphicsContext::setStrokeColor(c); - mGraphicsOperationCollection->append(new GraphicsOperation::SetStrokeColor(c)); + if (PlatformGraphicsContext::setStrokeColor(c)) { + mGraphicsOperationCollection->append(new GraphicsOperation::SetStrokeColor(c)); + return true; + } + return false; } -void PlatformGraphicsContextRecording::setStrokeShader(SkShader* strokeShader) +bool PlatformGraphicsContextRecording::setStrokeShader(SkShader* strokeShader) { - PlatformGraphicsContext::setStrokeShader(strokeShader); - mGraphicsOperationCollection->append(new GraphicsOperation::SetStrokeShader(strokeShader)); + if (PlatformGraphicsContext::setStrokeShader(strokeShader)) { + mGraphicsOperationCollection->append(new GraphicsOperation::SetStrokeShader(strokeShader)); + return true; + } + return false; } void PlatformGraphicsContextRecording::setStrokeStyle(StrokeStyle style) diff --git a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h index ebb0075..82f9446 100644 --- a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h +++ b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h @@ -55,16 +55,16 @@ public: // State values virtual void setAlpha(float alpha); virtual void setCompositeOperation(CompositeOperator op); - virtual void setFillColor(const Color& c); - virtual void setFillShader(SkShader* fillShader); + virtual bool setFillColor(const Color& c); + virtual bool setFillShader(SkShader* fillShader); virtual void setLineCap(LineCap cap); virtual void setLineDash(const DashArray& dashes, float dashOffset); virtual void setLineJoin(LineJoin join); virtual void setMiterLimit(float limit); virtual void setShadow(int radius, int dx, int dy, SkColor c); virtual void setShouldAntialias(bool useAA); - virtual void setStrokeColor(const Color& c); - virtual void setStrokeShader(SkShader* strokeShader); + virtual bool setStrokeColor(const Color& c); + virtual bool setStrokeShader(SkShader* strokeShader); virtual void setStrokeStyle(StrokeStyle style); virtual void setStrokeThickness(float f); diff --git a/Source/WebCore/platform/graphics/android/rendering/GLUtils.cpp b/Source/WebCore/platform/graphics/android/rendering/GLUtils.cpp index a68c01a..d5a701b 100644 --- a/Source/WebCore/platform/graphics/android/rendering/GLUtils.cpp +++ b/Source/WebCore/platform/graphics/android/rendering/GLUtils.cpp @@ -446,7 +446,7 @@ bool GLUtils::skipTransferForPureColor(const TileRenderInfo* renderInfo, } void GLUtils::paintTextureWithBitmap(const TileRenderInfo* renderInfo, - const SkBitmap& bitmap) + SkBitmap& bitmap) { if (!renderInfo) return; @@ -472,7 +472,7 @@ void GLUtils::paintTextureWithBitmap(const TileRenderInfo* renderInfo, } } -void GLUtils::updateQueueWithBitmap(const TileRenderInfo* renderInfo, const SkBitmap& bitmap) +void GLUtils::updateQueueWithBitmap(const TileRenderInfo* renderInfo, SkBitmap& bitmap) { if (!renderInfo || !renderInfo->textureInfo diff --git a/Source/WebCore/platform/graphics/android/rendering/GLUtils.h b/Source/WebCore/platform/graphics/android/rendering/GLUtils.h index c2dec7d..3b093d1 100644 --- a/Source/WebCore/platform/graphics/android/rendering/GLUtils.h +++ b/Source/WebCore/platform/graphics/android/rendering/GLUtils.h @@ -80,8 +80,8 @@ public: static void createEGLImageFromTexture(GLuint texture, EGLImageKHR* image); static void createTextureFromEGLImage(GLuint texture, EGLImageKHR image, GLint filter = GL_LINEAR); - static void paintTextureWithBitmap(const TileRenderInfo* renderInfo, const SkBitmap& bitmap); - static void updateQueueWithBitmap(const TileRenderInfo* , const SkBitmap& bitmap); + static void paintTextureWithBitmap(const TileRenderInfo* renderInfo, SkBitmap& bitmap); + static void updateQueueWithBitmap(const TileRenderInfo* , SkBitmap& bitmap); static bool updateSharedSurfaceTextureWithBitmap(ANativeWindow* anw, const SkBitmap& bitmap); static void convertToTransformationMatrix(const float* matrix, TransformationMatrix& transformMatrix); diff --git a/Source/WebCore/platform/graphics/android/rendering/GaneshRenderer.cpp b/Source/WebCore/platform/graphics/android/rendering/GaneshRenderer.cpp index d779af4..8b5e30a 100644 --- a/Source/WebCore/platform/graphics/android/rendering/GaneshRenderer.cpp +++ b/Source/WebCore/platform/graphics/android/rendering/GaneshRenderer.cpp @@ -94,7 +94,8 @@ void GaneshRenderer::renderingComplete(const TileRenderInfo& renderInfo, SkCanva // tile's ANativeWindow (i.e. SurfaceTexture) buffer TransferQueue* tileQueue = TilesManager::instance()->transferQueue(); eglSwapBuffers(eglGetCurrentDisplay(), tileQueue->m_eglSurface); - tileQueue->addItemInTransferQueue(&renderInfo, GpuUpload, 0); + SkBitmap dummyBitmap; + tileQueue->addItemInTransferQueue(&renderInfo, GpuUpload, dummyBitmap); tileQueue->unlockQueue(); } diff --git a/Source/WebCore/platform/graphics/android/rendering/RasterRenderer.cpp b/Source/WebCore/platform/graphics/android/rendering/RasterRenderer.cpp index a67a890..5c78ad9 100644 --- a/Source/WebCore/platform/graphics/android/rendering/RasterRenderer.cpp +++ b/Source/WebCore/platform/graphics/android/rendering/RasterRenderer.cpp @@ -97,6 +97,7 @@ void RasterRenderer::setupCanvas(const TileRenderInfo& renderInfo, SkCanvas* can void RasterRenderer::renderingComplete(const TileRenderInfo& renderInfo, SkCanvas* canvas) { + // We may swap the content of m_bitmap with the bitmap in the transfer queue. GLUtils::paintTextureWithBitmap(&renderInfo, m_bitmap); } diff --git a/Source/WebCore/platform/graphics/android/rendering/TransferQueue.cpp b/Source/WebCore/platform/graphics/android/rendering/TransferQueue.cpp index e329191..b15fa6d 100644 --- a/Source/WebCore/platform/graphics/android/rendering/TransferQueue.cpp +++ b/Source/WebCore/platform/graphics/android/rendering/TransferQueue.cpp @@ -390,7 +390,7 @@ void TransferQueue::updateDirtyTiles() } void TransferQueue::updateQueueWithBitmap(const TileRenderInfo* renderInfo, - const SkBitmap& bitmap) + SkBitmap& bitmap) { TRACE_METHOD(); if (!tryUpdateQueueWithBitmap(renderInfo, bitmap)) { @@ -403,7 +403,7 @@ void TransferQueue::updateQueueWithBitmap(const TileRenderInfo* renderInfo, } bool TransferQueue::tryUpdateQueueWithBitmap(const TileRenderInfo* renderInfo, - const SkBitmap& bitmap) + SkBitmap& bitmap) { // This lock need to cover the full update since it is possible that queue // will be cleaned up in the middle of this update without the lock. @@ -429,7 +429,7 @@ bool TransferQueue::tryUpdateQueueWithBitmap(const TileRenderInfo* renderInfo, } // b) After update the Surface Texture, now udpate the transfer queue info. - addItemInTransferQueue(renderInfo, currentUploadType, &bitmap); + addItemInTransferQueue(renderInfo, currentUploadType, bitmap); ALOGV("Bitmap updated x, y %d %d, baseTile %p", renderInfo->x, renderInfo->y, renderInfo->baseTile); @@ -475,7 +475,7 @@ void TransferQueue::addItemCommon(const TileRenderInfo* renderInfo, // Currently only called by GLUtils::updateSharedSurfaceTextureWithBitmap. void TransferQueue::addItemInTransferQueue(const TileRenderInfo* renderInfo, TextureUploadType type, - const SkBitmap* bitmap) + SkBitmap& bitmap) { m_transferQueueIndex = (m_transferQueueIndex + 1) % m_transferQueueSize; @@ -487,15 +487,18 @@ void TransferQueue::addItemInTransferQueue(const TileRenderInfo* renderInfo, TileTransferData* data = &m_transferQueue[index]; addItemCommon(renderInfo, type, data); - if (type == CpuUpload && bitmap) { + if (type == CpuUpload) { // Lazily create the bitmap if (!m_transferQueue[index].bitmap) { m_transferQueue[index].bitmap = new SkBitmap(); - int w = bitmap->width(); - int h = bitmap->height(); - m_transferQueue[index].bitmap->setConfig(bitmap->config(), w, h); + int w = bitmap.width(); + int h = bitmap.height(); + m_transferQueue[index].bitmap->setConfig(bitmap.config(), w, h); + m_transferQueue[index].bitmap->allocPixels(); } - bitmap->copyTo(m_transferQueue[index].bitmap, bitmap->config()); + SkBitmap temp = (*m_transferQueue[index].bitmap); + (*m_transferQueue[index].bitmap) = bitmap; + bitmap = temp; } m_emptyItemCount--; diff --git a/Source/WebCore/platform/graphics/android/rendering/TransferQueue.h b/Source/WebCore/platform/graphics/android/rendering/TransferQueue.h index c0835d7..55011b0 100644 --- a/Source/WebCore/platform/graphics/android/rendering/TransferQueue.h +++ b/Source/WebCore/platform/graphics/android/rendering/TransferQueue.h @@ -115,11 +115,11 @@ public: // insert the bitmap into the queue, mark the tile dirty if failing void updateQueueWithBitmap(const TileRenderInfo* renderInfo, - const SkBitmap& bitmap); + SkBitmap& bitmap); void addItemInTransferQueue(const TileRenderInfo* info, TextureUploadType type, - const SkBitmap* bitmap); + SkBitmap& bitmap); // Check if the item @ index is ready for update. // The lock will be done when returning true. bool readyForUpdate(); @@ -145,7 +145,7 @@ public: private: // return true if successfully inserted into queue bool tryUpdateQueueWithBitmap(const TileRenderInfo* renderInfo, - const SkBitmap& bitmap); + SkBitmap& bitmap); bool getHasGLContext(); void setHasGLContext(bool hasContext); void emptyAndAbandonQueue(); |