#include "BaseLayerAndroid.h"
#include "ClassTracker.h"
+#include "GLUtils.h"
#include "LayerAndroid.h"
#include "TilesManager.h"
#include <wtf/CurrentTime.h>
, m_baseLayerUpdate(true)
, m_backgroundColor(SK_ColorWHITE)
, m_prevDrawTime(0)
+ , m_displayRings(false)
+ , m_focusRingTexture(-1)
{
m_viewport.setEmpty();
m_previousViewport.setEmpty();
SkSafeUnref(m_currentBaseLayer);
m_currentBaseLayer = layer;
}
+ m_displayRings = false;
invalRegion(inval);
#ifdef MEASURES_PERF
TilesManager::instance()->setShowVisualIndicator(showVisualIndicator);
}
+void GLWebViewState::setRings(Vector<IntRect>& rings, bool isPressed)
+{
+ android::Mutex::Autolock lock(m_baseLayerLock);
+ m_displayRings = true;
+ m_rings = rings;
+ m_ringsIsPressed = isPressed;
+}
+
void GLWebViewState::invalRegion(const SkRegion& region)
{
SkRegion::Iterator iterator(region);
if (!m_lastInval.isEmpty())
inval(m_lastInval);
m_lastInval = rect;
+ m_displayRings = false;
}
void GLWebViewState::inval(const IntRect& rect)
}
}
+void GLWebViewState::resetRings()
+{
+ m_displayRings = false;
+}
+
+void GLWebViewState::drawFocusRing(IntRect& srcRect)
+{
+ // TODO: use a 9-patch texture to draw the focus ring
+ // instead of plain colors
+ const float alpha = 0.3;
+ float borderAlpha = 0.40;
+
+ const int r = 104;
+ const int g = 153;
+ const int b = 255;
+
+ int padding = 4;
+ int border = 1;
+ int fuzzyBorder = border * 2;
+ if (!m_ringsIsPressed) {
+ padding = 0;
+ border = 2;
+ fuzzyBorder = 3;
+ borderAlpha = 0.2;
+ }
+ if (m_focusRingTexture == -1)
+ m_focusRingTexture = GLUtils::createSampleColorTexture(r, g, b);
+
+ SkRect rLeft, rTop, rRight, rBottom, rOverlay;
+
+ IntRect rect(srcRect.x() - padding, srcRect.y() - padding,
+ srcRect.width() + (padding * 2), srcRect.height() + (padding * 2));
+ rLeft.set(rect.x() - border, rect.y(),
+ rect.x(), rect.y() + rect.height());
+ rTop.set(rect.x() - border, rect.y() - border,
+ rect.x() + rect.width() + border, rect.y());
+ rRight.set(rect.x() + rect.width(), rect.y(),
+ rect.x() + rect.width() + border,
+ rect.y() + rect.height());
+ rBottom.set(rect.x() - border, rect.y() + rect.height(),
+ rect.x() + rect.width() + border,
+ rect.y() + rect.height() + border);
+ rOverlay.set(rect.x() - fuzzyBorder, rect.y() - fuzzyBorder,
+ rect.x() + rect.width() + fuzzyBorder,
+ rect.y() + rect.height() + fuzzyBorder);
+
+ TilesManager::instance()->shader()->drawQuad(rLeft, m_focusRingTexture, borderAlpha);
+ TilesManager::instance()->shader()->drawQuad(rTop, m_focusRingTexture, borderAlpha);
+ TilesManager::instance()->shader()->drawQuad(rRight, m_focusRingTexture, borderAlpha);
+ TilesManager::instance()->shader()->drawQuad(rBottom, m_focusRingTexture, borderAlpha);
+ if (m_ringsIsPressed) {
+ TilesManager::instance()->shader()->drawQuad(rOverlay, m_focusRingTexture, alpha);
+ } else {
+ rLeft.set(rect.x() - fuzzyBorder, rect.y(),
+ rect.x(), rect.y() + rect.height());
+ rTop.set(rect.x() - fuzzyBorder, rect.y() - fuzzyBorder,
+ rect.x() + rect.width() + fuzzyBorder, rect.y());
+ rRight.set(rect.x() + rect.width(), rect.y(),
+ rect.x() + rect.width() + fuzzyBorder,
+ rect.y() + rect.height());
+ rBottom.set(rect.x() - fuzzyBorder, rect.y() + rect.height(),
+ rect.x() + rect.width() + fuzzyBorder,
+ rect.y() + rect.height() + fuzzyBorder);
+ TilesManager::instance()->shader()->drawQuad(rLeft, m_focusRingTexture, alpha);
+ TilesManager::instance()->shader()->drawQuad(rTop, m_focusRingTexture, alpha);
+ TilesManager::instance()->shader()->drawQuad(rRight, m_focusRingTexture, alpha);
+ TilesManager::instance()->shader()->drawQuad(rBottom, m_focusRingTexture, alpha);
+ }
+}
+
+void GLWebViewState::paintExtras()
+{
+ if (m_displayRings) {
+ // TODO: handles correctly the multi-rings case
+ for (int i=0; i<m_rings.size(); i++) {
+ IntRect rect = m_rings.at(i);
+ drawFocusRing(rect);
+ }
+ }
+}
+
unsigned int GLWebViewState::paintBaseLayerContent(SkCanvas* canvas)
{
android::Mutex::Autolock lock(m_baseLayerLock);
SkPicture picture;
IntRect rect(0, 0, 0, 0);
bool allowSame = false;
+ m_glWebViewState->resetRings();
if (extra) {
- LayerAndroid mainPicture(m_navPictureUI);
- PictureSet* content = m_baseLayer->content();
- SkCanvas* canvas = picture.beginRecording(content->width(),
- content->height());
- extra->draw(canvas, &mainPicture, &rect);
- picture.endRecording();
+ if (extra == &m_ring) {
+ m_glWebViewState->setRings(m_ring.rings(), m_ring.m_isPressed);
+ } else {
+ LayerAndroid mainPicture(m_navPictureUI);
+ PictureSet* content = m_baseLayer->content();
+ SkCanvas* canvas = picture.beginRecording(content->width(),
+ content->height());
+ extra->draw(canvas, &mainPicture, &rect);
+ picture.endRecording();
+ }
} else if (extras == DrawExtrasCursorRing && m_ring.m_isButton) {
const CachedFrame* cachedFrame;
const CachedNode* cachedCursor = root->currentCursor(&cachedFrame);