diff options
9 files changed, 60 insertions, 18 deletions
diff --git a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp index df0ffd6..f11154d 100644 --- a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp +++ b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp @@ -162,6 +162,8 @@ PlatformGraphicsContextRecording::PlatformGraphicsContextRecording(Recording* re , mRecording(recording) , mOperationState(0) , mOperationMatrix(0) + , m_hasText(false) + , m_isEmpty(true) { pushMatrix(); if (mRecording) @@ -188,6 +190,8 @@ void PlatformGraphicsContextRecording::endRecording(const SkRect& bounds) GraphicsOperation::DrawComplexText* text = new GraphicsOperation::DrawComplexText(mPicture); appendDrawingOperation(text, bounds); mPicture = 0; + + m_hasText = true; } //************************************** @@ -599,6 +603,7 @@ void PlatformGraphicsContextRecording::appendDrawingOperation( ALOGW("Empty bounds for %s(%s)!", operation->name(), operation->parameters().ascii().data()); return; } + m_isEmpty = false; SkRect bounds; mCurrentMatrix->mapRect(&bounds, untranslatedBounds); if (mRecordingStateStack.size()) { diff --git a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h index 6c51852..89f9bbb 100644 --- a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h +++ b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h @@ -136,6 +136,8 @@ public: virtual void strokePath(const Path& pathToStroke); virtual void strokeRect(const FloatRect& rect, float lineWidth); + bool hasText() { return m_hasText; } + bool isEmpty() { return m_isEmpty; } private: virtual bool shadowsIgnoreTransforms() const { @@ -194,6 +196,9 @@ private: Vector<SkMatrix> mMatrixStack; State* mOperationState; SkMatrix* mOperationMatrix; + + bool m_hasText; + bool m_isEmpty; }; } diff --git a/Source/WebCore/platform/graphics/android/layers/LayerContent.h b/Source/WebCore/platform/graphics/android/layers/LayerContent.h index 10b6507..a18e4c8 100644 --- a/Source/WebCore/platform/graphics/android/layers/LayerContent.h +++ b/Source/WebCore/platform/graphics/android/layers/LayerContent.h @@ -42,7 +42,7 @@ class LayerContent : public SkRefCnt { public: virtual int width() = 0; virtual int height() = 0; - virtual bool isEmpty() { return !width() || !height(); } + bool isEmpty() { return !width() || !height(); } virtual void setCheckForOptimisations(bool check) = 0; virtual void checkForOptimisations() = 0; virtual bool hasText() = 0; diff --git a/Source/WebCore/platform/graphics/android/layers/PictureLayerContent.cpp b/Source/WebCore/platform/graphics/android/layers/PictureLayerContent.cpp index f012c42..e40c9b6 100644 --- a/Source/WebCore/platform/graphics/android/layers/PictureLayerContent.cpp +++ b/Source/WebCore/platform/graphics/android/layers/PictureLayerContent.cpp @@ -45,16 +45,6 @@ int PictureLayerContent::height() return m_picture->height(); } -bool PictureLayerContent::isEmpty() -{ - if (!m_picture) - return true; - if (m_picture->width() == 0 - || m_picture->height() == 0) - return true; - return false; -} - void PictureLayerContent::checkForOptimisations() { if (!m_checkedContent) diff --git a/Source/WebCore/platform/graphics/android/layers/PictureLayerContent.h b/Source/WebCore/platform/graphics/android/layers/PictureLayerContent.h index 1567f44..cf633cb 100644 --- a/Source/WebCore/platform/graphics/android/layers/PictureLayerContent.h +++ b/Source/WebCore/platform/graphics/android/layers/PictureLayerContent.h @@ -38,7 +38,6 @@ public: virtual int width(); virtual int height(); - virtual bool isEmpty(); virtual void setCheckForOptimisations(bool check) { m_checkedContent = !check; } virtual void checkForOptimisations(); virtual bool hasText(); diff --git a/Source/WebCore/platform/graphics/android/layers/PicturePileLayerContent.cpp b/Source/WebCore/platform/graphics/android/layers/PicturePileLayerContent.cpp index 5d516af..1167bda 100644 --- a/Source/WebCore/platform/graphics/android/layers/PicturePileLayerContent.cpp +++ b/Source/WebCore/platform/graphics/android/layers/PicturePileLayerContent.cpp @@ -12,6 +12,8 @@ namespace WebCore { PicturePileLayerContent::PicturePileLayerContent(const PicturePile& picturePile) : m_picturePile(picturePile) + , m_hasText(picturePile.hasText()) + , m_hasContent(!picturePile.isEmpty()) { } @@ -20,6 +22,9 @@ void PicturePileLayerContent::draw(SkCanvas* canvas) TRACE_METHOD(); android::Mutex::Autolock lock(m_drawLock); m_picturePile.draw(canvas); + + if (CC_UNLIKELY(!m_hasContent)) + ALOGW("Warning: painting PicturePile without content!"); } void PicturePileLayerContent::serialize(SkWStream* stream) diff --git a/Source/WebCore/platform/graphics/android/layers/PicturePileLayerContent.h b/Source/WebCore/platform/graphics/android/layers/PicturePileLayerContent.h index f2b7c61..9f3a263 100644 --- a/Source/WebCore/platform/graphics/android/layers/PicturePileLayerContent.h +++ b/Source/WebCore/platform/graphics/android/layers/PicturePileLayerContent.h @@ -35,11 +35,13 @@ class PicturePileLayerContent : public LayerContent { public: PicturePileLayerContent(const PicturePile& picturePile); - virtual int width() { return m_picturePile.size().width(); } - virtual int height() { return m_picturePile.size().height(); } + // return 0 when no content, so don't have to paint + virtual int width() { return m_hasContent ? m_picturePile.size().width() : 0; } + virtual int height() { return m_hasContent ? m_picturePile.size().height() : 0; } + virtual void setCheckForOptimisations(bool check) {} - virtual void checkForOptimisations() {} - virtual bool hasText() { return true; } + virtual void checkForOptimisations() {} // already performed, stored in m_hasText/m_hasContent + virtual bool hasText() { return m_hasText; } virtual void draw(SkCanvas* canvas); virtual void serialize(SkWStream* stream); virtual PrerenderedInval* prerenderForRect(const IntRect& dirty); @@ -48,6 +50,8 @@ public: private: PicturePile m_picturePile; + bool m_hasText; + bool m_hasContent; }; } // WebCore diff --git a/Source/WebKit/android/jni/PicturePile.cpp b/Source/WebKit/android/jni/PicturePile.cpp index b69c131..554bd1b 100644 --- a/Source/WebKit/android/jni/PicturePile.cpp +++ b/Source/WebKit/android/jni/PicturePile.cpp @@ -277,6 +277,24 @@ PrerenderedInval* PicturePile::prerenderedInvalForArea(const IntRect& area) return 0; } +bool PicturePile::hasText() const +{ + for (size_t i = 0; i < m_pile.size(); i++) { + if (m_pile[i].hasText) + return true; + } + return false; +} + +bool PicturePile::isEmpty() const +{ + for (size_t i = 0; i < m_pile.size(); i++) { + if (m_pile[i].picture) + return false; + } + return true; +} + #if USE_RECORDING_CONTEXT void PicturePile::drawPicture(SkCanvas* canvas, PictureContainer& pc) { @@ -286,12 +304,18 @@ void PicturePile::drawPicture(SkCanvas* canvas, PictureContainer& pc) Picture* PicturePile::recordPicture(PicturePainter* painter, PictureContainer& pc) { - // TODO: Support? Not needed? - pc.prerendered.clear(); + pc.prerendered.clear(); // TODO: Support? Not needed? + Recording* picture = new Recording(); WebCore::PlatformGraphicsContextRecording pgc(picture); WebCore::GraphicsContext gc(&pgc); painter->paintContents(&gc, pc.area); + pc.hasText = pgc.hasText(); + if (pgc.isEmpty()) { + SkSafeUnref(picture); + picture = 0; + } + return picture; } #else @@ -336,6 +360,10 @@ Picture* PicturePile::recordPicture(PicturePainter* painter, PictureContainer& p WebCore::GraphicsContext gc(&pgc); ALOGV("painting picture: " INT_RECT_FORMAT, INT_RECT_ARGS(drawArea)); painter->paintContents(&gc, drawArea); + + // TODO: consider paint-time checking for these with SkPicture painting? + pc.hasText = true; + SkSafeUnref(canvas); picture->endRecording(); return picture; diff --git a/Source/WebKit/android/jni/PicturePile.h b/Source/WebKit/android/jni/PicturePile.h index 05f5d01..6e3e46d 100644 --- a/Source/WebKit/android/jni/PicturePile.h +++ b/Source/WebKit/android/jni/PicturePile.h @@ -71,11 +71,13 @@ public: IntRect area; bool dirty; RefPtr<PrerenderedInval> prerendered; + bool hasText; PictureContainer(const IntRect& area) : picture(0) , area(area) , dirty(true) + , hasText(false) {} PictureContainer(const PictureContainer& other); @@ -102,6 +104,10 @@ public: SkRegion& dirtyRegion() { return m_dirtyRegion; } PrerenderedInval* prerenderedInvalForArea(const IntRect& area); + // UI-side methods used to check content, after construction/updates are complete + bool hasText() const; + bool isEmpty() const; + private: void applyWebkitInvals(); void updatePicture(PicturePainter* painter, PictureContainer& container); |