summaryrefslogtreecommitdiffstats
path: root/WebCore/platform
diff options
context:
space:
mode:
authorCary Clark <cary@android.com>2010-11-19 14:23:02 -0500
committerCary Clark <cary@android.com>2010-11-23 15:58:09 -0500
commiteabb311cd2b57ff80b4cf632078cf078d789b563 (patch)
treeb16e6af4e3b973aa223e113e6d063dd6c0dea08c /WebCore/platform
parent9a193fae103e41510ec598934ec912e0575c8e19 (diff)
downloadexternal_webkit-eabb311cd2b57ff80b4cf632078cf078d789b563.zip
external_webkit-eabb311cd2b57ff80b4cf632078cf078d789b563.tar.gz
external_webkit-eabb311cd2b57ff80b4cf632078cf078d789b563.tar.bz2
reenable draw extras when GL is turned on
This captures the drawing in the UI thread, then passes the drawing to the tile imaging thread. The draw extras interface now takes an additional rectangle, and each draw extra fills in the inval area formed as that part is drawn. The old extra implementation in GLWebViewState has been removed. The inval portion of the setBaseLayer call has been split out so it can be called directly. bug:3161294 Change-Id: I28d3e6879059770b973e7c0f7c0796909f7359aa
Diffstat (limited to 'WebCore/platform')
-rw-r--r--WebCore/platform/graphics/android/BaseLayerAndroid.cpp11
-rw-r--r--WebCore/platform/graphics/android/BaseLayerAndroid.h3
-rw-r--r--WebCore/platform/graphics/android/GLWebViewState.cpp48
-rw-r--r--WebCore/platform/graphics/android/GLWebViewState.h10
-rw-r--r--WebCore/platform/graphics/android/LayerAndroid.cpp6
-rw-r--r--WebCore/platform/graphics/android/android_graphics.cpp17
-rw-r--r--WebCore/platform/graphics/android/android_graphics.h3
7 files changed, 58 insertions, 40 deletions
diff --git a/WebCore/platform/graphics/android/BaseLayerAndroid.cpp b/WebCore/platform/graphics/android/BaseLayerAndroid.cpp
index 4d00f1c..7f85899 100644
--- a/WebCore/platform/graphics/android/BaseLayerAndroid.cpp
+++ b/WebCore/platform/graphics/android/BaseLayerAndroid.cpp
@@ -95,6 +95,14 @@ void BaseLayerAndroid::setContent(const PictureSet& src)
setSize(src.width(), src.height());
}
+void BaseLayerAndroid::setExtra(SkPicture& src)
+{
+#if USE(ACCELERATED_COMPOSITING)
+ android::Mutex::Autolock lock(m_drawLock);
+#endif
+ m_extra.swap(src);
+}
+
void BaseLayerAndroid::drawCanvas(SkCanvas* canvas)
{
#if USE(ACCELERATED_COMPOSITING)
@@ -102,6 +110,9 @@ void BaseLayerAndroid::drawCanvas(SkCanvas* canvas)
#endif
if (!m_content.isEmpty())
m_content.draw(canvas);
+ // TODO : replace with !m_extra.isEmpty() once such a call exists
+ if (m_extra.width() > 0)
+ m_extra.draw(canvas);
}
#if USE(ACCELERATED_COMPOSITING)
diff --git a/WebCore/platform/graphics/android/BaseLayerAndroid.h b/WebCore/platform/graphics/android/BaseLayerAndroid.h
index 2e0646e..08a601e 100644
--- a/WebCore/platform/graphics/android/BaseLayerAndroid.h
+++ b/WebCore/platform/graphics/android/BaseLayerAndroid.h
@@ -31,6 +31,7 @@
#include "IntRect.h"
#include "PictureSet.h"
#include "SkLayer.h"
+#include "SkPicture.h"
namespace WebCore {
@@ -48,6 +49,7 @@ public:
void setBackgroundColor(Color& color) { m_color = color; }
#endif
void setContent(const android::PictureSet& src);
+ void setExtra(SkPicture& extra);
android::PictureSet* content() { return &m_content; }
// This method will paint using the current PictureSet onto
// the passed canvas. We used it to paint the GL tiles as well as
@@ -67,6 +69,7 @@ private:
Color m_color;
#endif
android::PictureSet m_content;
+ SkPicture m_extra;
SkRect m_previousVisible;
};
diff --git a/WebCore/platform/graphics/android/GLWebViewState.cpp b/WebCore/platform/graphics/android/GLWebViewState.cpp
index d0d054f..145bd89 100644
--- a/WebCore/platform/graphics/android/GLWebViewState.cpp
+++ b/WebCore/platform/graphics/android/GLWebViewState.cpp
@@ -72,8 +72,6 @@ GLWebViewState::GLWebViewState()
, m_baseLayer(0)
, m_currentPictureCounter(0)
, m_usePageA(true)
- , m_extra(0)
- , m_navLayer(0)
{
m_viewport.setEmpty();
m_viewportTileBounds.setEmpty();
@@ -90,58 +88,48 @@ GLWebViewState::~GLWebViewState()
{
delete m_tiledPageA;
delete m_tiledPageB;
- delete m_navLayer;
#ifdef DEBUG_COUNT
gGLWebViewStateCount--;
#endif
}
-void GLWebViewState::setBaseLayer(BaseLayerAndroid* layer, IntRect& rect)
+void GLWebViewState::setBaseLayer(BaseLayerAndroid* layer, const IntRect& rect)
{
android::Mutex::Autolock lock(m_baseLayerLock);
m_baseLayer = layer;
- m_extra = 0;
- delete m_navLayer;
- m_navLayer = 0;
if (m_baseLayer) {
m_baseLayer->setGLWebViewState(this);
- m_currentPictureCounter++;
-
- if (!rect.isEmpty()) {
- // find which tiles fall within the invalRect and mark them as dirty
- m_tiledPageA->invalidateRect(rect, m_currentPictureCounter);
- m_tiledPageB->invalidateRect(rect, m_currentPictureCounter);
- }
+ inval(rect);
}
}
-void GLWebViewState::setExtra(android::DrawExtra* extra, LayerAndroid* navLayer)
+void GLWebViewState::setExtra(BaseLayerAndroid* layer, SkPicture& picture,
+ const IntRect& rect)
{
android::Mutex::Autolock lock(m_baseLayerLock);
- m_extra = extra;
- delete m_navLayer;
- m_navLayer = navLayer;
- m_currentPictureCounter++;
+ layer->setExtra(picture);
+ if (!rect.isEmpty())
+ inval(rect);
+ else if (!m_lastInval.isEmpty())
+ inval(m_lastInval);
+ m_lastInval = rect;
}
-void GLWebViewState::resetExtra(bool repaint)
+void GLWebViewState::inval(const IntRect& rect)
{
- android::Mutex::Autolock lock(m_baseLayerLock);
- if (m_extra && repaint)
- m_currentPictureCounter++;
- m_extra = 0;
- delete m_navLayer;
- m_navLayer = 0;
+ m_currentPictureCounter++;
+ if (!rect.isEmpty()) {
+ // find which tiles fall within the invalRect and mark them as dirty
+ m_tiledPageA->invalidateRect(rect, m_currentPictureCounter);
+ m_tiledPageB->invalidateRect(rect, m_currentPictureCounter);
+ }
}
unsigned int GLWebViewState::paintBaseLayerContent(SkCanvas* canvas)
{
android::Mutex::Autolock lock(m_baseLayerLock);
- if (m_baseLayer) {
+ if (m_baseLayer)
m_baseLayer->drawCanvas(canvas);
- if (m_extra && m_navLayer)
- m_extra->draw(canvas, m_navLayer);
- }
return m_currentPictureCounter;
}
diff --git a/WebCore/platform/graphics/android/GLWebViewState.h b/WebCore/platform/graphics/android/GLWebViewState.h
index cc1834d..e50c5f4 100644
--- a/WebCore/platform/graphics/android/GLWebViewState.h
+++ b/WebCore/platform/graphics/android/GLWebViewState.h
@@ -167,10 +167,8 @@ public:
void resetTransitionTime() { m_transitionTime = -1; }
unsigned int paintBaseLayerContent(SkCanvas* canvas);
- void setBaseLayer(BaseLayerAndroid* layer, IntRect& rect);
- void setExtra(android::DrawExtra* extra, LayerAndroid* navLayer);
- void resetExtra(bool repaint);
-
+ void setBaseLayer(BaseLayerAndroid* layer, const IntRect& rect);
+ void setExtra(BaseLayerAndroid* , SkPicture& , const IntRect& );
void scheduleUpdate(const double& currentTime, float scale);
TiledPage* frontPage();
@@ -194,6 +192,7 @@ public:
bool hasContent();
private:
+ void inval(const IntRect& rect); // caller must hold m_baseLayerLock
// Delay between scheduling a new page when the scale
// factor changes (i.e. zooming in or out)
@@ -221,8 +220,7 @@ private:
bool m_usePageA;
TiledPage* m_tiledPageA;
TiledPage* m_tiledPageB;
- android::DrawExtra* m_extra;
- LayerAndroid* m_navLayer;
+ SkIRect m_lastInval;
};
} // namespace WebCore
diff --git a/WebCore/platform/graphics/android/LayerAndroid.cpp b/WebCore/platform/graphics/android/LayerAndroid.cpp
index f443004..0a6d3e2 100644
--- a/WebCore/platform/graphics/android/LayerAndroid.cpp
+++ b/WebCore/platform/graphics/android/LayerAndroid.cpp
@@ -459,8 +459,10 @@ void LayerAndroid::onDraw(SkCanvas* canvas, SkScalar opacity) {
canvas->restore();
}
}
- if (m_extra)
- m_extra->draw(canvas, this);
+ if (m_extra) {
+ IntRect dummy; // inval area, unused for now
+ m_extra->draw(canvas, this, &dummy);
+ }
#ifdef LAYER_DEBUG
float w = getSize().width();
diff --git a/WebCore/platform/graphics/android/android_graphics.cpp b/WebCore/platform/graphics/android/android_graphics.cpp
index a584f0b..c046858 100644
--- a/WebCore/platform/graphics/android/android_graphics.cpp
+++ b/WebCore/platform/graphics/android/android_graphics.cpp
@@ -40,8 +40,12 @@ namespace android {
// The CSS values for the inner and outer widths may be specified as fractions
#define WIDTH_SCALE 0.0625f // 1/16, to offset the scale in CSSStyleSelector
-void CursorRing::draw(SkCanvas* canvas, LayerAndroid* layer)
+void CursorRing::draw(SkCanvas* canvas, LayerAndroid* layer, IntRect* inval)
{
+ if (!m_lastBounds.isEmpty()) {
+ *inval = m_lastBounds;
+ m_lastBounds = IntRect(0, 0, 0, 0);
+ }
#if USE(ACCELERATED_COMPOSITING)
int layerId = m_node->isInLayer() ? m_frame->layer(m_node)->uniqueId() : -1;
if (layer->uniqueId() != layerId)
@@ -92,6 +96,17 @@ void CursorRing::draw(SkCanvas* canvas, LayerAndroid* layer)
paint.setStrokeWidth(colors.innerWidth() * WIDTH_SCALE);
paint.setColor(inner);
canvas->drawPath(path, paint);
+ SkRect localBounds, globalBounds;
+ localBounds = path.getBounds();
+ float width = std::max(colors.innerWidth(), colors.outerWidth());
+ width *= WIDTH_SCALE;
+ localBounds.inset(-width, -width);
+ const SkMatrix& matrix = canvas->getTotalMatrix();
+ matrix.mapRect(&globalBounds, localBounds);
+ SkIRect globalIBounds;
+ globalBounds.round(&globalIBounds);
+ m_lastBounds = globalIBounds;
+ inval->unite(m_lastBounds);
}
bool CursorRing::setup()
diff --git a/WebCore/platform/graphics/android/android_graphics.h b/WebCore/platform/graphics/android/android_graphics.h
index e147634..9f52a27 100644
--- a/WebCore/platform/graphics/android/android_graphics.h
+++ b/WebCore/platform/graphics/android/android_graphics.h
@@ -53,7 +53,7 @@ class CursorRing : public DrawExtra {
public:
CursorRing(WebViewCore* core) : m_viewImpl(core) {}
virtual ~CursorRing() {}
- virtual void draw(SkCanvas* , LayerAndroid* );
+ virtual void draw(SkCanvas* , LayerAndroid* , IntRect* );
bool setup();
private:
friend class WebView;
@@ -61,6 +61,7 @@ private:
WTF::Vector<IntRect> m_rings;
IntRect m_bounds;
IntRect m_absBounds;
+ IntRect m_lastBounds;
const CachedRoot* m_root;
const CachedFrame* m_frame;
const CachedNode* m_node;