diff options
author | Victoria Lease <violets@google.com> | 2011-12-27 15:38:05 -0800 |
---|---|---|
committer | Victoria Lease <violets@google.com> | 2012-01-09 15:11:12 -0800 |
commit | 7c564d38504faf606e8965c2bd77653745dc45b9 (patch) | |
tree | 0275201ec71b25bc3f15a31139efca54e34748b1 /Source/WebCore/platform/graphics/android | |
parent | 5568a9850c798bc4d30002485666c70c055e3457 (diff) | |
download | external_webkit-7c564d38504faf606e8965c2bd77653745dc45b9.zip external_webkit-7c564d38504faf606e8965c2bd77653745dc45b9.tar.gz external_webkit-7c564d38504faf606e8965c2bd77653745dc45b9.tar.bz2 |
Draw GLExtras for each layer.
Bug: 5747765
Moved the GLExtras::drawGL() call out of GLWebViewState into
LayerAndroid and BaseLayerAndroid. This allows us to apply per-layer
transforms, ensuring that find-on-page highlights are positioned
correctly on their layers.
Change-Id: I65b950875eb736601f8afec1770e5cc0201c0450
Diffstat (limited to 'Source/WebCore/platform/graphics/android')
5 files changed, 58 insertions, 30 deletions
diff --git a/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp index 6ab9226..a3c92cd 100644 --- a/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp @@ -361,6 +361,7 @@ bool BaseLayerAndroid::drawGL(IntRect& viewRect, SkRect& visibleRect, // TODO: consider moving drawBackground outside of prepare (into tree manager) m_state->drawBackground(m_color); drawBasePictureInGL(); + m_state->glExtras()->drawGL(0); bool needsRedraw = false; diff --git a/Source/WebCore/platform/graphics/android/GLExtras.cpp b/Source/WebCore/platform/graphics/android/GLExtras.cpp index 873ea33..bf489c9 100644 --- a/Source/WebCore/platform/graphics/android/GLExtras.cpp +++ b/Source/WebCore/platform/graphics/android/GLExtras.cpp @@ -67,6 +67,7 @@ GLExtras::GLExtras() , m_drawExtra(0) , m_lightRingTexture(-1) , m_darkRingTexture(-1) + , m_viewport() { } @@ -74,7 +75,8 @@ GLExtras::~GLExtras() { } -void GLExtras::drawRing(SkRect& srcRect, int* texture, int r, int g, int b, float a) +void GLExtras::drawRing(SkRect& srcRect, int* texture, int r, int g, int b, float a, + const TransformationMatrix* drawMat) { if (*texture == -1) *texture = GLUtils::createSampleColorTexture(r, g, b); @@ -85,11 +87,15 @@ void GLExtras::drawRing(SkRect& srcRect, int* texture, int r, int g, int b, floa } XLOG("drawQuad [%fx%f, %f, %f]", srcRect.fLeft, srcRect.fTop, srcRect.width(), srcRect.height()); - TilesManager::instance()->shader()->drawQuad(srcRect, *texture, a); + if (drawMat) + TilesManager::instance()->shader()->drawLayerQuad(*drawMat, srcRect, *texture, a); + else + TilesManager::instance()->shader()->drawQuad(srcRect, *texture, a); } void GLExtras::drawRegion(const SkRegion& region, bool fill, - bool drawBorder, bool useDark) + bool drawBorder, const TransformationMatrix* drawMat, + bool useDark) { if (region.isEmpty()) return; @@ -100,9 +106,9 @@ void GLExtras::drawRegion(const SkRegion& region, bool fill, SkRect r; r.set(ir.fLeft, ir.fTop, ir.fRight, ir.fBottom); if (useDark) - drawRing(r, COLOR_HOLO_DARK); + drawRing(r, COLOR_HOLO_DARK, drawMat); else - drawRing(r, COLOR_HOLO_LIGHT); + drawRing(r, COLOR_HOLO_LIGHT, drawMat); rgnIter.next(); } } @@ -144,9 +150,9 @@ void GLExtras::drawRegion(const SkRegion& region, bool fill, } r.set(line.fLeft, line.fTop, line.fRight, line.fBottom); if (useDark) - drawRing(r, COLOR_HOLO_DARK); + drawRing(r, COLOR_HOLO_DARK, drawMat); else - drawRing(r, COLOR_HOLO_LIGHT); + drawRing(r, COLOR_HOLO_LIGHT, drawMat); if (startRect.isEmpty()) { startRect.set(line.fLeft, line.fTop, line.fRight, line.fBottom); } @@ -157,7 +163,7 @@ void GLExtras::drawRegion(const SkRegion& region, bool fill, } } -void GLExtras::drawCursorRings() +void GLExtras::drawCursorRings(const LayerAndroid* layer) { SkRegion region; for (size_t i = 0; i < m_ring->rings().size(); i++) { @@ -167,26 +173,41 @@ void GLExtras::drawCursorRings() else region.op(rect, SkRegion::kUnion_Op); } - drawRegion(region, m_ring->m_isPressed, !m_ring->m_isButton, false); + drawRegion(region, m_ring->m_isPressed, !m_ring->m_isButton, + layer ? layer->drawTransform() : 0, false); } -void GLExtras::drawFindOnPage(SkRect& viewport) +void GLExtras::drawFindOnPage(const LayerAndroid* layer) { WTF::Vector<MatchInfo>* matches = m_findOnPage->matches(); XLOG("drawFindOnPage, matches: %p", matches); if (!matches || !m_findOnPage->isCurrentLocationValid()) return; + std::pair<unsigned, unsigned> matchRange = + m_findOnPage->getLayerMatchRange(layer ? layer->uniqueId() : -1); + if (matchRange.first >= matchRange.second) + return; + int count = matches->size(); - int current = m_findOnPage->currentMatchIndex(); + unsigned current = m_findOnPage->currentMatchIndex(); XLOG("match count: %d", count); + const TransformationMatrix* drawTransform = + layer ? layer->drawTransform() : 0; if (count < MAX_NUMBER_OF_MATCHES_TO_DRAW) - for (int i = 0; i < count; i++) { + for (unsigned i = matchRange.first; i < matchRange.second; i++) { MatchInfo& info = matches->at(i); const SkRegion& region = info.getLocation(); SkIRect rect = region.getBounds(); - if (rect.intersect(viewport.fLeft, viewport.fTop, - viewport.fRight, viewport.fBottom)) - drawRegion(region, i == current, false, true); + if (drawTransform) { + IntRect intRect(rect.fLeft, rect.fTop, rect.width(), + rect.height()); + IntRect transformedRect = drawTransform->mapRect(intRect); + rect.setXYWH(transformedRect.x(), transformedRect.y(), + transformedRect.width(), transformedRect.height()); + } + if (rect.intersect(m_viewport.fLeft, m_viewport.fTop, + m_viewport.fRight, m_viewport.fBottom)) + drawRegion(region, i == current, false, drawTransform, true); #ifdef DEBUG else XLOG("Quick rejecting [%dx%d, %d, %d", rect.fLeft, rect.fTop, @@ -194,18 +215,20 @@ void GLExtras::drawFindOnPage(SkRect& viewport) #endif // DEBUG } else { - MatchInfo& info = matches->at(current); - drawRegion(info.getLocation(), true, false, true); + if (matchRange.first <= current && current < matchRange.second) { + MatchInfo& info = matches->at(current); + drawRegion(info.getLocation(), true, false, drawTransform, true); + } } } -void GLExtras::drawGL(IntRect& webViewRect, SkRect& viewport, int titleBarHeight) +void GLExtras::drawGL(const LayerAndroid* layer) { if (m_drawExtra) { if (m_drawExtra == m_ring) - drawCursorRings(); + drawCursorRings(layer); else if (m_drawExtra == m_findOnPage) - drawFindOnPage(viewport); + drawFindOnPage(layer); else XLOGC("m_drawExtra %p is unknown! (cursor: %p, find: %p", m_drawExtra, m_ring, m_findOnPage); diff --git a/Source/WebCore/platform/graphics/android/GLExtras.h b/Source/WebCore/platform/graphics/android/GLExtras.h index c52e951..5ccf4cc 100644 --- a/Source/WebCore/platform/graphics/android/GLExtras.h +++ b/Source/WebCore/platform/graphics/android/GLExtras.h @@ -37,30 +37,36 @@ namespace android { namespace WebCore { +class LayerAndroid; +class TransformationMatrix; + class GLExtras { public: GLExtras(); virtual ~GLExtras(); - void drawGL(IntRect& webViewRect, SkRect& viewport, int titleBarHeight); + void drawGL(const LayerAndroid* layer); void setFindOnPageExtra(android::FindOnPage* findOnPage) { m_findOnPage = findOnPage; } void setCursorRingExtra(android::CursorRing* ring) { m_ring = ring; } void setDrawExtra(android::DrawExtra* extra) { m_drawExtra = extra; } + void setViewport(const SkRect & viewport) { m_viewport = viewport; } private: - void drawRing(SkRect& srcRect, int* texture, int r, int g, int b, float a); + void drawRing(SkRect& srcRect, int* texture, int r, int g, int b, float a, + const TransformationMatrix* drawMat); void drawRegion(const SkRegion& region, bool fill, bool drawBorder, - bool useDark = false); - void drawCursorRings(); - void drawFindOnPage(SkRect& viewport); + const TransformationMatrix* drawMat, bool useDark = false); + void drawCursorRings(const LayerAndroid* layer); + void drawFindOnPage(const LayerAndroid* layer); android::FindOnPage* m_findOnPage; android::CursorRing* m_ring; android::DrawExtra* m_drawExtra; int m_lightRingTexture; int m_darkRingTexture; + SkRect m_viewport; }; } // namespace WebCore diff --git a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp index bcb85bc..d8ad1c5 100644 --- a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp +++ b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp @@ -514,6 +514,7 @@ bool GLWebViewState::drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect, TexturesResult nbTexturesNeeded; bool fastSwap = isScrolling() || m_layersRenderingMode == kSingleSurfaceRendering; + m_glExtras.setViewport(viewport); ret |= m_treeManager.drawGL(currentTime, rect, viewport, scale, fastSwap, treesSwappedPtr, newTreeHasAnimPtr, @@ -530,11 +531,6 @@ bool GLWebViewState::drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect, nbTexturesNeeded.clipped += nbTexturesForImages; ret |= setLayersRenderingMode(nbTexturesNeeded); - FloatRect extrasclip(0, 0, rect.width(), rect.height()); - TilesManager::instance()->shader()->clip(extrasclip); - - m_glExtras.drawGL(webViewRect, viewport, titleBarHeight); - glBindBuffer(GL_ARRAY_BUFFER, 0); // Clean up GL textures for video layer. diff --git a/Source/WebCore/platform/graphics/android/LayerAndroid.cpp b/Source/WebCore/platform/graphics/android/LayerAndroid.cpp index 342a541..88e419d 100644 --- a/Source/WebCore/platform/graphics/android/LayerAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/LayerAndroid.cpp @@ -1055,6 +1055,8 @@ bool LayerAndroid::drawGL() } } + m_state->glExtras()->drawGL(this); + // When the layer is dirty, the UI thread should be notified to redraw. askScreenUpdate |= drawChildrenGL(); m_atomicSync.lock(); |