diff options
author | Chris Craik <ccraik@google.com> | 2012-07-19 10:39:31 -0700 |
---|---|---|
committer | Chris Craik <ccraik@google.com> | 2012-07-19 14:18:38 -0700 |
commit | f899e6e3a8952453ea79363d36a4d171eebb0fbb (patch) | |
tree | aabddfb4a019dd9a51cf7abbc69ad87bbd6a4abd /Source/WebKit/android/jni | |
parent | cbf95b35591b40a9424e54d765694b378ef11966 (diff) | |
download | external_webkit-f899e6e3a8952453ea79363d36a4d171eebb0fbb.zip external_webkit-f899e6e3a8952453ea79363d36a4d171eebb0fbb.tar.gz external_webkit-f899e6e3a8952453ea79363d36a4d171eebb0fbb.tar.bz2 |
Perform check for text/content on recording context PicturePiles
Only implemented for now when USE_RECORDING_CONTEXT is enabled. Standard
SkPicture PicturePile implementation defaults to hasText = hasContent = true.
Change-Id: I535b53151963bf8c415e420c1d5a789954e98cbf
Diffstat (limited to 'Source/WebKit/android/jni')
-rw-r--r-- | Source/WebKit/android/jni/PicturePile.cpp | 32 | ||||
-rw-r--r-- | Source/WebKit/android/jni/PicturePile.h | 6 |
2 files changed, 36 insertions, 2 deletions
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 a8175d9..f60a4b6 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); |