diff options
author | Chris Craik <ccraik@google.com> | 2012-07-19 15:23:14 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-07-19 15:23:15 -0700 |
commit | f6e85179ce1bea972c8fb4860f2f14fb107195cb (patch) | |
tree | e471c0dca840d79515baa766bce810279c18bac2 /Source/WebKit/android | |
parent | 6fda3e621352a695b3b6a02c6008d372b7c6febc (diff) | |
parent | f899e6e3a8952453ea79363d36a4d171eebb0fbb (diff) | |
download | external_webkit-f6e85179ce1bea972c8fb4860f2f14fb107195cb.zip external_webkit-f6e85179ce1bea972c8fb4860f2f14fb107195cb.tar.gz external_webkit-f6e85179ce1bea972c8fb4860f2f14fb107195cb.tar.bz2 |
Merge "Perform check for text/content on recording context PicturePiles"
Diffstat (limited to 'Source/WebKit/android')
-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 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); |