diff options
author | John Reck <jreck@google.com> | 2012-01-25 09:20:19 -0800 |
---|---|---|
committer | John Reck <jreck@google.com> | 2012-01-30 17:26:58 -0800 |
commit | dea0c131566f424923425970fe5621305d136e5a (patch) | |
tree | 0bec1b7dce4e813f367a4952ac9eb3938c3dc163 /Source/WebCore/platform/graphics/android | |
parent | a7b12d27ee68ff4de7d56bb494f31bb9ca7c39a0 (diff) | |
download | external_webkit-dea0c131566f424923425970fe5621305d136e5a.zip external_webkit-dea0c131566f424923425970fe5621305d136e5a.tar.gz external_webkit-dea0c131566f424923425970fe5621305d136e5a.tar.bz2 |
Webkit text selection
Change-Id: I8e2e400940c7c84055aeb2624958aaf47804900b
Diffstat (limited to 'Source/WebCore/platform/graphics/android')
9 files changed, 33 insertions, 35 deletions
diff --git a/Source/WebCore/platform/graphics/android/GLExtras.cpp b/Source/WebCore/platform/graphics/android/GLExtras.cpp index 9ad369a..37f598e 100644 --- a/Source/WebCore/platform/graphics/android/GLExtras.cpp +++ b/Source/WebCore/platform/graphics/android/GLExtras.cpp @@ -52,10 +52,10 @@ // Touch ring border width. This is doubled if the ring is not pressed #define RING_BORDER_WIDTH 1 -// Color of the ring is 0x6633b5e5 (copied from framework's holo_light) -#define COLOR_HOLO_LIGHT &m_lightRingTexture, 0x33, 0xb5, 0xe5, 0.4f -// Color of the ring is 0x660099cc (copied from framework's holo_dark) -#define COLOR_HOLO_DARK &m_darkRingTexture, 0x00, 0x99, 0xcc, 0.6f +// Color of the ring copied from framework's holo_light +#define COLOR_HOLO_LIGHT 0xFF33b5e5, .4f +// Color of the ring copied from framework's holo_dark +#define COLOR_HOLO_DARK 0xFF0099cc, .4f // Put a cap on the number of matches to draw. If the current page has more // matches than this, only draw the focused match. This both prevents clutter // on the page and keeps the performance happy @@ -65,8 +65,6 @@ GLExtras::GLExtras() : m_findOnPage(0) , m_ring(0) , m_drawExtra(0) - , m_lightRingTexture(-1) - , m_darkRingTexture(-1) , m_viewport() { } @@ -75,22 +73,20 @@ GLExtras::~GLExtras() { } -void GLExtras::drawRing(SkRect& srcRect, int* texture, int r, int g, int b, float a, +void GLExtras::drawRing(SkRect& srcRect, Color color, float alpha, const TransformationMatrix* drawMat) { - if (*texture == -1) - *texture = GLUtils::createSampleColorTexture(r, g, b); - if (srcRect.fRight <= srcRect.fLeft || srcRect.fBottom <= srcRect.fTop) { // Invalid rect, reject it return; } XLOG("drawQuad [%fx%f, %f, %f]", srcRect.fLeft, srcRect.fTop, srcRect.width(), srcRect.height()); - if (drawMat) - TilesManager::instance()->shader()->drawLayerQuad(*drawMat, srcRect, *texture, a); - else - TilesManager::instance()->shader()->drawQuad(srcRect, *texture, a); + if (drawMat) { + TilesManager::instance()->shader()->drawLayerQuad(*drawMat, srcRect, 0, + alpha, false, 0, color); + } else + TilesManager::instance()->shader()->drawQuad(srcRect, 0, alpha, color); } void GLExtras::drawRegion(const SkRegion& region, bool fill, @@ -234,7 +230,6 @@ void GLExtras::drawGL(const LayerAndroid* layer) else if (m_drawExtra == m_findOnPage) drawFindOnPage(layer); else - XLOGC("m_drawExtra %p is unknown! (cursor: %p, find: %p", - m_drawExtra, m_ring, m_findOnPage); + m_drawExtra->drawGL(this, layer); } } diff --git a/Source/WebCore/platform/graphics/android/GLExtras.h b/Source/WebCore/platform/graphics/android/GLExtras.h index 5ccf4cc..09e346c 100644 --- a/Source/WebCore/platform/graphics/android/GLExtras.h +++ b/Source/WebCore/platform/graphics/android/GLExtras.h @@ -26,6 +26,7 @@ #ifndef GLExtras_h #define GLExtras_h +#include "Color.h" #include "SkRect.h" #include "SkRegion.h" @@ -53,19 +54,18 @@ public: 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, - const TransformationMatrix* drawMat); void drawRegion(const SkRegion& region, bool fill, bool drawBorder, const TransformationMatrix* drawMat, bool useDark = false); + +private: + void drawRing(SkRect& srcRect, Color color, float alpha, + const TransformationMatrix* drawMat); 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; }; diff --git a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.h b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.h index c34aed8..4c049cd 100644 --- a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.h +++ b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.h @@ -25,6 +25,7 @@ #include "GraphicsLayerClient.h" #include "LayerAndroid.h" #include "RefPtr.h" +#include "ScrollableLayerAndroid.h" #include "SkBitmapRef.h" #include "Vector.h" @@ -122,6 +123,7 @@ public: void notifyClientAnimationStarted(); LayerAndroid* contentLayer() { return m_contentLayer; } + ScrollableLayerAndroid* foregroundLayer() { return m_foregroundLayer; } static int instancesCount(); diff --git a/Source/WebCore/platform/graphics/android/Layer.cpp b/Source/WebCore/platform/graphics/android/Layer.cpp index 9280461..f58d648 100644 --- a/Source/WebCore/platform/graphics/android/Layer.cpp +++ b/Source/WebCore/platform/graphics/android/Layer.cpp @@ -158,13 +158,13 @@ void Layer::localToAncestor(const Layer* ancestor, SkMatrix* matrix) const { /////////////////////////////////////////////////////////////////////////////// -void Layer::onDraw(SkCanvas*, SkScalar opacity) { +void Layer::onDraw(SkCanvas*, SkScalar opacity, android::DrawExtra* extra) { // SkDebugf("----- no onDraw for %p\n", this); } #include "SkString.h" -void Layer::draw(SkCanvas* canvas, SkScalar opacity) { +void Layer::draw(SkCanvas* canvas, android::DrawExtra* extra, SkScalar opacity) { #if 0 SkString str1, str2; // getMatrix().toDumpString(&str1); @@ -193,7 +193,7 @@ void Layer::draw(SkCanvas* canvas, SkScalar opacity) { canvas->concat(tmp); } - onDraw(canvas, opacity); + onDraw(canvas, opacity, extra); #ifdef DEBUG_DRAW_LAYER_BOUNDS { @@ -213,7 +213,7 @@ void Layer::draw(SkCanvas* canvas, SkScalar opacity) { if (count > 0) { canvas->concat(getChildrenMatrix()); for (int i = 0; i < count; i++) { - getChild(i)->draw(canvas, opacity); + getChild(i)->draw(canvas, extra, opacity); } } } diff --git a/Source/WebCore/platform/graphics/android/Layer.h b/Source/WebCore/platform/graphics/android/Layer.h index 5200a3d..876ca24 100644 --- a/Source/WebCore/platform/graphics/android/Layer.h +++ b/Source/WebCore/platform/graphics/android/Layer.h @@ -17,6 +17,7 @@ #ifndef Layer_DEFINED #define Layer_DEFINED +#include "DrawExtra.h" #include "TestExport.h" #include "SkRefCnt.h" #include "SkTDArray.h" @@ -165,17 +166,14 @@ public: // paint method virtual bool drawCanvas(SkCanvas*) { return false; } - void draw(SkCanvas*, SkScalar opacity); - void draw(SkCanvas* canvas) { - this->draw(canvas, SK_Scalar1); - } + void draw(SkCanvas*, android::DrawExtra* extra, SkScalar opacity = SK_Scalar1); void setHasOverflowChildren(bool value) { m_hasOverflowChildren = value; } virtual bool contentIsScrollable() const { return false; } protected: - virtual void onDraw(SkCanvas*, SkScalar opacity); + virtual void onDraw(SkCanvas*, SkScalar opacity, android::DrawExtra* extra); bool m_hasOverflowChildren; diff --git a/Source/WebCore/platform/graphics/android/LayerAndroid.cpp b/Source/WebCore/platform/graphics/android/LayerAndroid.cpp index 88e419d..79c02eb 100644 --- a/Source/WebCore/platform/graphics/android/LayerAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/LayerAndroid.cpp @@ -1022,7 +1022,7 @@ bool LayerAndroid::drawCanvas(SkCanvas* canvas) layerRect.fTop = 0; layerRect.fRight = getWidth(); layerRect.fBottom = getHeight(); - onDraw(canvas, m_drawOpacity); + onDraw(canvas, m_drawOpacity, 0); } // When the layer is dirty, the UI thread should be notified to redraw. @@ -1133,7 +1133,7 @@ void LayerAndroid::contentDraw(SkCanvas* canvas) } } -void LayerAndroid::onDraw(SkCanvas* canvas, SkScalar opacity) +void LayerAndroid::onDraw(SkCanvas* canvas, SkScalar opacity, android::DrawExtra* extra) { if (m_haveClip) { SkRect r; @@ -1163,6 +1163,8 @@ void LayerAndroid::onDraw(SkCanvas* canvas, SkScalar opacity) ImagesManager::instance()->releaseImage(m_imageCRC); } contentDraw(canvas); + if (extra) + extra->draw(canvas, this); } SkPicture* LayerAndroid::recordContext() diff --git a/Source/WebCore/platform/graphics/android/LayerAndroid.h b/Source/WebCore/platform/graphics/android/LayerAndroid.h index 578c2ff..d33eea1 100644 --- a/Source/WebCore/platform/graphics/android/LayerAndroid.h +++ b/Source/WebCore/platform/graphics/android/LayerAndroid.h @@ -199,6 +199,7 @@ public: setShouldInheritFromRootTransform(true); } + const IntPoint& scrollOffset() const { return m_offset; } void setScrollOffset(IntPoint offset) { m_offset = offset; } void setBackgroundColor(SkColor color); void setMaskLayer(LayerAndroid*); @@ -315,7 +316,7 @@ public: bool isReady(); protected: - virtual void onDraw(SkCanvas*, SkScalar opacity); + virtual void onDraw(SkCanvas*, SkScalar opacity, android::DrawExtra* extra); IntPoint m_offset; TransformationMatrix m_drawTransform; diff --git a/Source/WebCore/platform/graphics/android/android_graphics.cpp b/Source/WebCore/platform/graphics/android/android_graphics.cpp index 6b8725e..d76d581 100644 --- a/Source/WebCore/platform/graphics/android/android_graphics.cpp +++ b/Source/WebCore/platform/graphics/android/android_graphics.cpp @@ -57,7 +57,7 @@ CursorRing::CursorRing(WebViewCore* core) // 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, IntRect* inval) +void CursorRing::drawLegacy(SkCanvas* canvas, LayerAndroid* layer, IntRect* inval) { if (!m_lastBounds.isEmpty()) { *inval = m_lastBounds; diff --git a/Source/WebCore/platform/graphics/android/android_graphics.h b/Source/WebCore/platform/graphics/android/android_graphics.h index bd08a6e..68207d7 100644 --- a/Source/WebCore/platform/graphics/android/android_graphics.h +++ b/Source/WebCore/platform/graphics/android/android_graphics.h @@ -54,7 +54,7 @@ class CursorRing : public DrawExtra { public: CursorRing(WebViewCore* core); virtual ~CursorRing() {} - virtual void draw(SkCanvas* , LayerAndroid* , IntRect* ); + virtual void drawLegacy(SkCanvas* , LayerAndroid* , IntRect* ); void setIsButton(const CachedNode* ); bool setup(); WTF::Vector<IntRect>& rings() { return m_rings; } |