summaryrefslogtreecommitdiffstats
path: root/WebKit/android/nav/FindCanvas.cpp
diff options
context:
space:
mode:
authorCary Clark <cary@android.com>2010-02-23 10:46:08 -0500
committerCary Clark <cary@android.com>2010-02-24 16:04:13 -0500
commit87962ce00229855c098ba12cee8d5c015a835289 (patch)
treec6e9990575cad9cc687cf0c79573c13ac4d02f1b /WebKit/android/nav/FindCanvas.cpp
parent4175d59b46f96005f0c64978b1a94e3fe60f1e8e (diff)
downloadexternal_webkit-87962ce00229855c098ba12cee8d5c015a835289.zip
external_webkit-87962ce00229855c098ba12cee8d5c015a835289.tar.gz
external_webkit-87962ce00229855c098ba12cee8d5c015a835289.tar.bz2
refactor drawing to support layers
Drawing elements that appear atop or below layers need to be drawn both in the proper order and with the correct canvas to respect clipping and the matrix. Drawing the find results, text selection, or the cursor ring, interleaves with any layers that may be drawn. The main picture is treated as owned by a LayerAndroid so each component can decide when to draw. This change leave the main picture in WebViewCore.cpp, and draws everything else in WebView.cpp -- in the future, additional refactoring can put all drawing in one place. The logic of what to draw is still in WebView.java, but the actual drawing calls are now triggered inside the layer code. Android.mk - Add rule to trigger building without layers from buildspec.mk. LayerAndroid.* - Replace FindOnPage reference with abstract DrawExtra class to draw adornments in the layers' canvas context. - Add a LayerAndroid constructor to create a dummy layer with a SkPicture* and a uniqueId==-1 so that extras can detect when they are drawn by the main picture. android_graphics.* - Move cursor ring drawing out of WebView.cpp to here. - Separate cursor ring setup from actual drawing. - Get the cursor ring metrics in local coordinates. ChromeClientAndroid.cpp - Fix compiler warnings. WebViewCore.* - Move updateCursorBounds from WebView.cpp. This permits it to be called from CursorRing::setup. CachedFrame.* CachedNode.* CachedLayer.* - Add local bounds getters. CachedRoot.h - Move class FindCanvas to the android namespace. DrawExtra.h - Add an abstract class called by LayerAndroid to optionally draw extra elements in its canvas context. FindCanvas.* SelectText.* - Refactor drawing to draw in layers context. WebView.cpp - Move drawing from WebView.java. - Remove selection code to SelectText.cpp. - Use inverseScale to simplify viewPort metrics. - Simplify layer root so java doesn't need to know about it. Requires companion change in frameworks/base http://b/2457316 http://b/2454127 http://b/2454149
Diffstat (limited to 'WebKit/android/nav/FindCanvas.cpp')
-rw-r--r--WebKit/android/nav/FindCanvas.cpp28
1 files changed, 20 insertions, 8 deletions
diff --git a/WebKit/android/nav/FindCanvas.cpp b/WebKit/android/nav/FindCanvas.cpp
index b917eb9..3a0ef33 100644
--- a/WebKit/android/nav/FindCanvas.cpp
+++ b/WebKit/android/nav/FindCanvas.cpp
@@ -35,6 +35,8 @@
#include <utils/Log.h>
+namespace android {
+
// MatchInfo methods
////////////////////////////////////////////////////////////////////////////////
@@ -227,7 +229,7 @@ SkRect FindCanvas::addMatchPosH(int index,
return r;
}
-void FindCanvas::drawLayers(WebCore::LayerAndroid* layer) {
+void FindCanvas::drawLayers(LayerAndroid* layer) {
#if USE(ACCELERATED_COMPOSITING)
SkPicture* picture = layer->picture();
if (picture) {
@@ -509,10 +511,15 @@ void FindOnPage::setUpFindPaint() {
m_isFindPaintSetUp = true;
}
-WebCore::IntRect FindOnPage::currentMatchBounds() const {
+IntRect FindOnPage::currentMatchBounds() const {
+ IntRect noBounds = IntRect(0, 0, 0, 0);
if (!m_matches || !m_matches->size())
- return WebCore::IntRect(0, 0, 0, 0);
- return (*m_matches)[m_findIndex].getLocation().getBounds();
+ return noBounds;
+ MatchInfo& info = (*m_matches)[m_findIndex];
+ // FIXME: this should test if the match in the layer is visible
+ if (info.isInLayer())
+ return noBounds;
+ return info.getLocation().getBounds();
}
// This function is only used by findNext and setMatches. In it, we store
@@ -529,10 +536,10 @@ void FindOnPage::storeCurrentMatchLocation() {
// matches than this, only draw the focused match.
#define MAX_NUMBER_OF_MATCHES_TO_DRAW 101
-void FindOnPage::drawLayer(SkCanvas* canvas, const WebCore::IntRect* visRect,
- int layerId) {
+void FindOnPage::draw(SkCanvas* canvas, LayerAndroid* layer) {
if (!m_matches || !m_matches->size())
return;
+ int layerId = layer->uniqueId();
if (m_findIndex >= m_matches->size())
m_findIndex = 0;
const MatchInfo& matchInfo = (*m_matches)[m_findIndex];
@@ -561,8 +568,11 @@ void FindOnPage::drawLayer(SkCanvas* canvas, const WebCore::IntRect* visRect,
const SkRegion& region = (*m_matches)[i].getLocation();
// Do not draw matches which intersect the current one, or if it is
// offscreen
- if (currentMatchRegion.intersects(region)
- || (visRect && !region.intersects(*visRect)))
+ if (currentMatchRegion.intersects(region))
+ continue;
+ SkRect bounds;
+ bounds.set(region.getBounds());
+ if (canvas->quickReject(bounds, SkCanvas::kAA_EdgeType))
continue;
drawMatch(region, canvas, false);
}
@@ -648,3 +658,5 @@ void FindOnPage::setMatches(WTF::Vector<MatchInfo>* matches)
}
}
+}
+