From 3718b58e4da76b7025aa5316a51264c5e38f2569 Mon Sep 17 00:00:00 2001 From: John Reck Date: Fri, 3 Aug 2012 16:00:32 -0700 Subject: Remove usages of getCanvas Everything goes through either PlatformGraphicsContext or recordingCanvas() Change-Id: I375a4294d2e8d4b467b70c6b8a7f0b96f402f252 --- .../platform/android/RenderThemeAndroid.cpp | 64 +++++++--------------- .../platform/graphics/android/ImageAndroid.cpp | 1 - .../graphics/android/ImageBufferAndroid.cpp | 20 +++++-- .../graphics/android/ImageBufferDataAndroid.h | 5 ++ .../platform/graphics/android/PathAndroid.cpp | 1 - .../platform/graphics/android/PatternAndroid.cpp | 1 - .../android/context/GraphicsContextAndroid.cpp | 10 +--- .../graphics/android/context/GraphicsOperation.h | 30 +++++++++- .../android/context/PlatformGraphicsContext.h | 11 +++- .../context/PlatformGraphicsContextRecording.cpp | 8 +++ .../context/PlatformGraphicsContextRecording.h | 11 ++-- .../context/PlatformGraphicsContextSkia.cpp | 13 +++++ .../android/context/PlatformGraphicsContextSkia.h | 10 +++- .../context/RecordingContextCanvasProxy.cpp | 2 +- .../graphics/android/context/android_graphics.h | 42 -------------- .../graphics/android/layers/CanvasTexture.cpp | 7 +-- .../graphics/android/layers/VideoLayerManager.cpp | 5 +- .../graphics/android/layers/VideoLayerManager.h | 3 +- .../graphics/android/rendering/GLExtras.cpp | 1 - .../WebCore/plugins/android/PluginViewAndroid.cpp | 8 +-- Source/WebKit/android/RenderSkinMediaButton.cpp | 14 ++--- Source/WebKit/android/RenderSkinMediaButton.h | 34 +++++++++--- .../WebCoreSupport/FrameLoaderClientAndroid.cpp | 1 - .../WebCoreSupport/MediaPlayerPrivateAndroid.cpp | 5 +- Source/WebKit/android/jni/WebCoreFrameBridge.cpp | 1 - Source/WebKit/android/jni/WebFrameView.cpp | 1 - Source/WebKit/android/jni/WebViewCore.cpp | 1 - Source/WebKit/android/nav/WebView.cpp | 1 - .../WebKit/android/plugins/ANPSurfaceInterface.cpp | 1 - .../WebKit/android/plugins/PluginWidgetAndroid.cpp | 8 +-- .../WebKit/android/plugins/PluginWidgetAndroid.h | 3 +- 31 files changed, 162 insertions(+), 161 deletions(-) delete mode 100644 Source/WebCore/platform/graphics/android/context/android_graphics.h diff --git a/Source/WebCore/platform/android/RenderThemeAndroid.cpp b/Source/WebCore/platform/android/RenderThemeAndroid.cpp index 86380e7..eaf4593 100644 --- a/Source/WebCore/platform/android/RenderThemeAndroid.cpp +++ b/Source/WebCore/platform/android/RenderThemeAndroid.cpp @@ -39,6 +39,7 @@ #endif #include "RenderSkinAndroid.h" #include "RenderSkinMediaButton.h" +#include "RenderSlider.h" #include "RoundedIntRect.h" #include "SkCanvas.h" #include "UserAgentStyleSheets.h" @@ -85,12 +86,6 @@ const float scaleFactor[RenderSkinAndroid::ResolutionCount] = { 2.0f // extra high res }; - -static SkCanvas* getCanvasFromInfo(const PaintInfo& info) -{ - return info.context->platformContext()->getCanvas(); -} - static android::WebFrame* getWebFrame(const Node* node) { if (!node) @@ -341,9 +336,7 @@ bool RenderThemeAndroid::paintMediaFullscreenButton(RenderObject* o, const Paint bool translucent = false; if (o && toParentMediaElement(o) && toParentMediaElement(o)->hasTagName(HTMLNames::videoTag)) translucent = true; - if (!getCanvasFromInfo(paintInfo)) - return true; - RenderSkinMediaButton::Draw(getCanvasFromInfo(paintInfo), rect, RenderSkinMediaButton::FULLSCREEN, translucent); + paintInfo.context->platformContext()->drawMediaButton(rect, RenderSkinMediaButton::FULLSCREEN, translucent); return false; } @@ -352,9 +345,7 @@ bool RenderThemeAndroid::paintMediaMuteButton(RenderObject* o, const PaintInfo& bool translucent = false; if (o && toParentMediaElement(o) && toParentMediaElement(o)->hasTagName(HTMLNames::videoTag)) translucent = true; - if (!getCanvasFromInfo(paintInfo)) - return true; - RenderSkinMediaButton::Draw(getCanvasFromInfo(paintInfo), rect, RenderSkinMediaButton::MUTE, translucent); + paintInfo.context->platformContext()->drawMediaButton(rect, RenderSkinMediaButton::MUTE, translucent); return false; } @@ -364,12 +355,10 @@ bool RenderThemeAndroid::paintMediaPlayButton(RenderObject* o, const PaintInfo& if (o && toParentMediaElement(o) && toParentMediaElement(o)->hasTagName(HTMLNames::videoTag)) translucent = true; if (MediaControlPlayButtonElement* btn = static_cast(o->node())) { - if (!getCanvasFromInfo(paintInfo)) - return true; if (btn->displayType() == MediaPlayButton) - RenderSkinMediaButton::Draw(getCanvasFromInfo(paintInfo), rect, RenderSkinMediaButton::PLAY, translucent); + paintInfo.context->platformContext()->drawMediaButton(rect, RenderSkinMediaButton::PLAY, translucent); else - RenderSkinMediaButton::Draw(getCanvasFromInfo(paintInfo), rect, RenderSkinMediaButton::PAUSE, translucent); + paintInfo.context->platformContext()->drawMediaButton(rect, RenderSkinMediaButton::PAUSE, translucent); return false; } return true; @@ -380,9 +369,7 @@ bool RenderThemeAndroid::paintMediaSeekBackButton(RenderObject* o, const PaintIn bool translucent = false; if (o && toParentMediaElement(o) && toParentMediaElement(o)->hasTagName(HTMLNames::videoTag)) translucent = true; - if (!getCanvasFromInfo(paintInfo)) - return true; - RenderSkinMediaButton::Draw(getCanvasFromInfo(paintInfo), rect, RenderSkinMediaButton::REWIND, translucent); + paintInfo.context->platformContext()->drawMediaButton(rect, RenderSkinMediaButton::REWIND, translucent); return false; } @@ -391,9 +378,7 @@ bool RenderThemeAndroid::paintMediaSeekForwardButton(RenderObject* o, const Pain bool translucent = false; if (o && toParentMediaElement(o) && toParentMediaElement(o)->hasTagName(HTMLNames::videoTag)) translucent = true; - if (!getCanvasFromInfo(paintInfo)) - return true; - RenderSkinMediaButton::Draw(getCanvasFromInfo(paintInfo), rect, RenderSkinMediaButton::FORWARD, translucent); + paintInfo.context->platformContext()->drawMediaButton(rect, RenderSkinMediaButton::FORWARD, translucent); return false; } @@ -402,11 +387,9 @@ bool RenderThemeAndroid::paintMediaControlsBackground(RenderObject* o, const Pai bool translucent = false; if (o && toParentMediaElement(o) && toParentMediaElement(o)->hasTagName(HTMLNames::videoTag)) translucent = true; - if (!getCanvasFromInfo(paintInfo)) - return true; - RenderSkinMediaButton::Draw(getCanvasFromInfo(paintInfo), rect, + paintInfo.context->platformContext()->drawMediaButton(rect, RenderSkinMediaButton::BACKGROUND_SLIDER, - translucent, 0, false); + translucent, false); return false; } @@ -415,10 +398,11 @@ bool RenderThemeAndroid::paintMediaSliderTrack(RenderObject* o, const PaintInfo& bool translucent = false; if (o && toParentMediaElement(o) && toParentMediaElement(o)->hasTagName(HTMLNames::videoTag)) translucent = true; - if (!getCanvasFromInfo(paintInfo)) - return true; - RenderSkinMediaButton::Draw(getCanvasFromInfo(paintInfo), rect, - RenderSkinMediaButton::SLIDER_TRACK, translucent, o); + IntRect thumb; + if (o && o->isSlider()) + thumb = toRenderSlider(o)->thumbRect(); + paintInfo.context->platformContext()->drawMediaButton(rect, + RenderSkinMediaButton::SLIDER_TRACK, translucent, true, thumb); return false; } @@ -427,11 +411,9 @@ bool RenderThemeAndroid::paintMediaSliderThumb(RenderObject* o, const PaintInfo& bool translucent = false; if (o && toParentMediaElement(o) && toParentMediaElement(o)->hasTagName(HTMLNames::videoTag)) translucent = true; - if (!getCanvasFromInfo(paintInfo)) - return true; - RenderSkinMediaButton::Draw(getCanvasFromInfo(paintInfo), rect, + paintInfo.context->platformContext()->drawMediaButton(rect, RenderSkinMediaButton::SLIDER_THUMB, - translucent, 0, false); + translucent, false); return false; } @@ -647,25 +629,19 @@ bool RenderThemeAndroid::paintMenuListButton(RenderObject* obj, const PaintInfo& bool RenderThemeAndroid::paintSliderTrack(RenderObject* o, const PaintInfo& i, const IntRect& r) { - SkCanvas* canvas = getCanvasFromInfo(i); - if (!canvas) - return true; static const bool translucent = true; - RenderSkinMediaButton::Draw(canvas, r, + i.context->platformContext()->drawMediaButton(r, RenderSkinMediaButton::SLIDER_TRACK, - translucent, o, false); + translucent, false); return false; } bool RenderThemeAndroid::paintSliderThumb(RenderObject* o, const PaintInfo& i, const IntRect& r) { - SkCanvas* canvas = getCanvasFromInfo(i); - if (!canvas) - return true; static const bool translucent = true; - RenderSkinMediaButton::Draw(canvas, r, + i.context->platformContext()->drawMediaButton(r, RenderSkinMediaButton::SLIDER_THUMB, - translucent, 0, false); + translucent, false); return false; } diff --git a/Source/WebCore/platform/graphics/android/ImageAndroid.cpp b/Source/WebCore/platform/graphics/android/ImageAndroid.cpp index 08f72e0..4958622 100644 --- a/Source/WebCore/platform/graphics/android/ImageAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/ImageAndroid.cpp @@ -34,7 +34,6 @@ #include "PlatformString.h" #include "SharedBuffer.h" -#include "android_graphics.h" #include "SkBitmapRef.h" #include "SkCanvas.h" #include "SkColorPriv.h" diff --git a/Source/WebCore/platform/graphics/android/ImageBufferAndroid.cpp b/Source/WebCore/platform/graphics/android/ImageBufferAndroid.cpp index e56f424..f36200d 100644 --- a/Source/WebCore/platform/graphics/android/ImageBufferAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/ImageBufferAndroid.cpp @@ -33,6 +33,7 @@ #include "NotImplemented.h" #include "PlatformBridge.h" #include "PlatformGraphicsContext.h" +#include "PlatformGraphicsContextSkia.h" #include "SkBitmapRef.h" #include "SkCanvas.h" #include "SkColorPriv.h" @@ -41,12 +42,21 @@ #include "SkImageEncoder.h" #include "SkStream.h" #include "SkUnPreMultiply.h" -#include "android_graphics.h" using namespace std; namespace WebCore { +SkCanvas* imageBufferCanvas(const ImageBuffer* buffer) +{ + // We know that our PlatformGraphicsContext is a PlatformGraphicsContextSkia + // because that is what we create in GraphicsContext::createOffscreenContext + if (!buffer || !buffer->context()) + return 0; + PlatformGraphicsContext* pc = buffer->context()->platformContext(); + return static_cast(pc)->canvas(); +} + ImageBufferData::ImageBufferData(const IntSize&) { } @@ -82,7 +92,7 @@ PassRefPtr ImageBuffer::copyImage() const { ASSERT(context()); - SkCanvas* canvas = context()->platformContext()->getCanvas(); + SkCanvas* canvas = imageBufferCanvas(this); if (!canvas) return 0; @@ -123,7 +133,7 @@ PassRefPtr ImageBuffer::getUnmultipliedImageData(const IntRect& rect) return 0; } - const SkBitmap& src = android_gc2canvas(gc)->getDevice()->accessBitmap(false); + const SkBitmap& src = imageBufferCanvas(this)->getDevice()->accessBitmap(false); SkAutoLockPixels alp(src); if (!src.getPixels()) { return 0; @@ -185,7 +195,7 @@ void ImageBuffer::putUnmultipliedImageData(ByteArray* source, const IntSize& sou return; } - const SkBitmap& dst = android_gc2canvas(gc)->getDevice()->accessBitmap(true); + const SkBitmap& dst = imageBufferCanvas(this)->getDevice()->accessBitmap(true); SkAutoLockPixels alp(dst); if (!dst.getPixels()) { return; @@ -240,7 +250,7 @@ String ImageBuffer::toDataURL(const String&, const double*) const { // Encode the image into a vector. SkDynamicMemoryWStream pngStream; - const SkBitmap& dst = android_gc2canvas(context())->getDevice()->accessBitmap(true); + const SkBitmap& dst = imageBufferCanvas(this)->getDevice()->accessBitmap(true); SkImageEncoder::EncodeStream(&pngStream, dst, SkImageEncoder::kPNG_Type, 100); // Convert it into base64. diff --git a/Source/WebCore/platform/graphics/android/ImageBufferDataAndroid.h b/Source/WebCore/platform/graphics/android/ImageBufferDataAndroid.h index 80cf79f..eeade6e 100644 --- a/Source/WebCore/platform/graphics/android/ImageBufferDataAndroid.h +++ b/Source/WebCore/platform/graphics/android/ImageBufferDataAndroid.h @@ -26,9 +26,14 @@ #ifndef ImageBufferDataAndroid_h #define ImageBufferDataAndroid_h +class SkCanvas; + namespace WebCore { class IntSize; +class ImageBuffer; + +SkCanvas* imageBufferCanvas(const ImageBuffer* buffer); class ImageBufferData { public: diff --git a/Source/WebCore/platform/graphics/android/PathAndroid.cpp b/Source/WebCore/platform/graphics/android/PathAndroid.cpp index 554e187..e70f983 100644 --- a/Source/WebCore/platform/graphics/android/PathAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/PathAndroid.cpp @@ -37,7 +37,6 @@ #include "SkRegion.h" #include "StrokeStyleApplier.h" #include "TransformationMatrix.h" -#include "android_graphics.h" namespace WebCore { diff --git a/Source/WebCore/platform/graphics/android/PatternAndroid.cpp b/Source/WebCore/platform/graphics/android/PatternAndroid.cpp index 568036c..721029c 100644 --- a/Source/WebCore/platform/graphics/android/PatternAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/PatternAndroid.cpp @@ -26,7 +26,6 @@ #include "config.h" #include "Pattern.h" -#include "android_graphics.h" #include "GraphicsContext.h" #include "SkBitmapRef.h" #include "SkCanvas.h" diff --git a/Source/WebCore/platform/graphics/android/context/GraphicsContextAndroid.cpp b/Source/WebCore/platform/graphics/android/context/GraphicsContextAndroid.cpp index aceb82b..970b04b 100644 --- a/Source/WebCore/platform/graphics/android/context/GraphicsContextAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/context/GraphicsContextAndroid.cpp @@ -46,7 +46,6 @@ #include "SkString.h" #include "SkiaUtils.h" #include "TransformationMatrix.h" -#include "android_graphics.h" using namespace std; @@ -104,7 +103,7 @@ GraphicsContext* GraphicsContext::createOffscreenContext(int width, int height) bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height); bitmap.allocPixels(); bitmap.eraseColor(0); - pgc->getCanvas()->setBitmapDevice(bitmap); + pgc->canvas()->setBitmapDevice(bitmap); GraphicsContext* ctx = new GraphicsContext(pgc); return ctx; @@ -656,10 +655,3 @@ void GraphicsContext::drawHighlightForText(const Font& font, const TextRun& run, } } // namespace WebCore - -/////////////////////////////////////////////////////////////////////////////// - -SkCanvas* android_gc2canvas(WebCore::GraphicsContext* gc) -{ - return gc->platformContext()->getCanvas(); -} diff --git a/Source/WebCore/platform/graphics/android/context/GraphicsOperation.h b/Source/WebCore/platform/graphics/android/context/GraphicsOperation.h index 9bbf6b9..b1d91fb 100644 --- a/Source/WebCore/platform/graphics/android/context/GraphicsOperation.h +++ b/Source/WebCore/platform/graphics/android/context/GraphicsOperation.h @@ -113,6 +113,7 @@ public: , StrokeArcOperation , StrokePathOperation , StrokeRectOperation + , DrawMediaButtonOperation // Text , DrawPosTextOperation } OperationType; @@ -148,6 +149,7 @@ public: TYPE_CASE(StrokeArcOperation) TYPE_CASE(StrokePathOperation) TYPE_CASE(StrokeRectOperation) + TYPE_CASE(DrawMediaButtonOperation) // Text TYPE_CASE(DrawPosTextOperation) } @@ -535,6 +537,30 @@ private: float m_lineWidth; }; +class DrawMediaButton : public Operation { +public: + DrawMediaButton(const IntRect& rect, RenderSkinMediaButton::MediaButton buttonType, + bool translucent, bool drawBackground, + const IntRect& thumb) + : m_rect(rect) + , m_thumb(thumb) + , m_buttonType(buttonType) + , m_translucent(translucent) + , m_drawBackground(drawBackground) + {} + virtual bool applyImpl(PlatformGraphicsContext* context) { + context->drawMediaButton(m_rect, m_buttonType, m_translucent, m_drawBackground, m_thumb); + return true; + } + TYPE(DrawMediaButtonOperation) +private: + IntRect m_rect; + IntRect m_thumb; + RenderSkinMediaButton::MediaButton m_buttonType; + bool m_translucent : 1; + bool m_drawBackground : 1; +}; + //************************************** // Text //************************************** @@ -554,9 +580,7 @@ public: } ~DrawPosText() { delete m_pos; free(m_text); } virtual bool applyImpl(PlatformGraphicsContext* context) { - if (!context->getCanvas()) - return true; - context->getCanvas()->drawPosText(m_text, m_byteLength, m_pos, m_paint); + context->drawPosText(m_text, m_byteLength, m_pos, m_paint); return true; } TYPE(DrawPosTextOperation) diff --git a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContext.h b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContext.h index 595d2ab..56aceff 100644 --- a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContext.h +++ b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContext.h @@ -29,6 +29,7 @@ #include "IntRect.h" #include "GraphicsContext.h" #include "RenderSkinAndroid.h" +#include "RenderSkinMediaButton.h" #include "SkCanvas.h" #include "SkPicture.h" #include "SkTDArray.h" @@ -45,7 +46,6 @@ public: PlatformGraphicsContext(); virtual ~PlatformGraphicsContext(); virtual bool isPaintingDisabled() = 0; - virtual SkCanvas* getCanvas() = 0; void setGraphicsContext(GraphicsContext* gc) { m_gc = gc; } virtual bool deleteUs() const { return false; } @@ -100,13 +100,14 @@ public: virtual bool clipOut(const IntRect& r) = 0; virtual bool clipOut(const Path& p) = 0; virtual bool clipPath(const Path& pathToClip, WindRule clipRule) = 0; + virtual SkIRect getTotalClipBounds() = 0; // Drawing virtual void clearRect(const FloatRect& rect) = 0; virtual void drawBitmapPattern(const SkBitmap& bitmap, const SkMatrix& matrix, CompositeOperator compositeOp, const FloatRect& destRect) = 0; virtual void drawBitmapRect(const SkBitmap& bitmap, const SkIRect* src, - const SkRect& dst, CompositeOperator op) = 0; + const SkRect& dst, CompositeOperator op = CompositeSourceOver) = 0; virtual void drawConvexPolygon(size_t numPoints, const FloatPoint* points, bool shouldAntialias) = 0; virtual void drawEllipse(const IntRect& rect) = 0; @@ -140,6 +141,12 @@ public: virtual void strokePath(const Path& pathToStroke) = 0; virtual void strokeRect(const FloatRect& rect, float lineWidth) = 0; + virtual void drawPosText(const void* text, size_t byteLength, + const SkPoint pos[], const SkPaint& paint) = 0; + virtual void drawMediaButton(const IntRect& rect, RenderSkinMediaButton::MediaButton buttonType, + bool translucent = false, bool drawBackground = true, + const IntRect& thumb = IntRect()) = 0; + virtual SkCanvas* recordingCanvas() = 0; void setRawState(State* state) { m_state = state; } diff --git a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp index b0ab3ac..ec4c72a 100644 --- a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp +++ b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp @@ -752,6 +752,14 @@ void PlatformGraphicsContextRecording::drawPosText(const void* text, size_t byte appendDrawingOperation(NEW_OP(DrawPosText)(text, byteLength, pos, paint), bounds); } +void PlatformGraphicsContextRecording::drawMediaButton(const IntRect& rect, RenderSkinMediaButton::MediaButton buttonType, + bool translucent, bool drawBackground, + const IntRect& thumb) +{ + appendDrawingOperation(NEW_OP(DrawMediaButton)(rect, buttonType, + translucent, drawBackground, thumb), rect); +} + void PlatformGraphicsContextRecording::clipState(const FloatRect& clip) { if (mRecordingStateStack.size()) { diff --git a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h index 991e13f..17906d8 100644 --- a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h +++ b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h @@ -60,7 +60,6 @@ public: PlatformGraphicsContextRecording(Recording* picture); virtual ~PlatformGraphicsContextRecording() {} virtual bool isPaintingDisabled(); - virtual SkCanvas* getCanvas() { return 0; } virtual SkCanvas* recordingCanvas(); @@ -104,13 +103,14 @@ public: virtual bool clipOut(const IntRect& r); virtual bool clipOut(const Path& p); virtual bool clipPath(const Path& pathToClip, WindRule clipRule); + virtual SkIRect getTotalClipBounds() { return enclosingIntRect(mRecordingStateStack.last().mBounds); } // Drawing virtual void clearRect(const FloatRect& rect); virtual void drawBitmapPattern(const SkBitmap& bitmap, const SkMatrix& matrix, CompositeOperator compositeOp, const FloatRect& destRect); virtual void drawBitmapRect(const SkBitmap& bitmap, const SkIRect* src, - const SkRect& dst, CompositeOperator op); + const SkRect& dst, CompositeOperator op = CompositeSourceOver); virtual void drawConvexPolygon(size_t numPoints, const FloatPoint* points, bool shouldAntialias); virtual void drawEllipse(const IntRect& rect); @@ -135,8 +135,11 @@ public: virtual void strokePath(const Path& pathToStroke); virtual void strokeRect(const FloatRect& rect, float lineWidth); - void drawPosText(const void* text, size_t byteLength, - const SkPoint pos[], const SkPaint& paint); + virtual void drawPosText(const void* text, size_t byteLength, + const SkPoint pos[], const SkPaint& paint); + virtual void drawMediaButton(const IntRect& rect, RenderSkinMediaButton::MediaButton buttonType, + bool translucent = false, bool drawBackground = true, + const IntRect& thumb = IntRect()); bool hasText() { return m_hasText; } bool isEmpty() { return m_isEmpty; } diff --git a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextSkia.cpp b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextSkia.cpp index 2fa3805..fcd9ade 100644 --- a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextSkia.cpp +++ b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextSkia.cpp @@ -607,4 +607,17 @@ void PlatformGraphicsContextSkia::strokeRect(const FloatRect& rect, float lineWi mCanvas->drawRect(rect, paint); } +void PlatformGraphicsContextSkia::drawPosText(const void* text, size_t byteLength, + const SkPoint pos[], const SkPaint& paint) +{ + mCanvas->drawPosText(text, byteLength, pos, paint); +} + +void PlatformGraphicsContextSkia::drawMediaButton(const IntRect& rect, RenderSkinMediaButton::MediaButton buttonType, + bool translucent, bool drawBackground, + const IntRect& thumb) +{ + RenderSkinMediaButton::Draw(mCanvas, rect, buttonType, translucent, drawBackground, thumb); +} + } // WebCore diff --git a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextSkia.h b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextSkia.h index 32249c3..6bf53d7 100644 --- a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextSkia.h +++ b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextSkia.h @@ -35,7 +35,7 @@ public: PlatformGraphicsContextSkia(SkCanvas* canvas, bool takeCanvasOwnership = false); virtual ~PlatformGraphicsContextSkia(); virtual bool isPaintingDisabled(); - virtual SkCanvas* getCanvas() { return mCanvas; } + SkCanvas* canvas() { return mCanvas; } virtual ContextType type() { return PaintingContext; } virtual SkCanvas* recordingCanvas() { return mCanvas; } @@ -67,13 +67,14 @@ public: virtual bool clipOut(const IntRect& r); virtual bool clipOut(const Path& p); virtual bool clipPath(const Path& pathToClip, WindRule clipRule); + virtual SkIRect getTotalClipBounds() { return mCanvas->getTotalClip().getBounds(); } // Drawing virtual void clearRect(const FloatRect& rect); virtual void drawBitmapPattern(const SkBitmap& bitmap, const SkMatrix& matrix, CompositeOperator compositeOp, const FloatRect& destRect); virtual void drawBitmapRect(const SkBitmap& bitmap, const SkIRect* src, - const SkRect& dst, CompositeOperator op); + const SkRect& dst, CompositeOperator op = CompositeSourceOver); virtual void drawConvexPolygon(size_t numPoints, const FloatPoint* points, bool shouldAntialias); virtual void drawEllipse(const IntRect& rect); @@ -97,6 +98,11 @@ public: virtual void strokeArc(const IntRect& r, int startAngle, int angleSpan); virtual void strokePath(const Path& pathToStroke); virtual void strokeRect(const FloatRect& rect, float lineWidth); + virtual void drawPosText(const void* text, size_t byteLength, + const SkPoint pos[], const SkPaint& paint); + virtual void drawMediaButton(const IntRect& rect, RenderSkinMediaButton::MediaButton buttonType, + bool translucent = false, bool drawBackground = true, + const IntRect& thumb = IntRect()); private: diff --git a/Source/WebCore/platform/graphics/android/context/RecordingContextCanvasProxy.cpp b/Source/WebCore/platform/graphics/android/context/RecordingContextCanvasProxy.cpp index ea3b1a2..838e450 100644 --- a/Source/WebCore/platform/graphics/android/context/RecordingContextCanvasProxy.cpp +++ b/Source/WebCore/platform/graphics/android/context/RecordingContextCanvasProxy.cpp @@ -55,7 +55,7 @@ void RecordingContextCanvasProxy::drawBitmapRect(const SkBitmap& bitmap, const SkRect& dst, const SkPaint*) { - m_pgc->drawBitmapRect(bitmap, src, dst, CompositeSourceOver); + m_pgc->drawBitmapRect(bitmap, src, dst); } // Return value is unused by FontAndroid diff --git a/Source/WebCore/platform/graphics/android/context/android_graphics.h b/Source/WebCore/platform/graphics/android/context/android_graphics.h deleted file mode 100644 index 7faa781..0000000 --- a/Source/WebCore/platform/graphics/android/context/android_graphics.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2007, The Android Open Source Project - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef android_graphics_DEFINED -#define android_graphics_DEFINED - -namespace WebCore { - class GraphicsContext; -} -class SkCanvas; - -// TODO: Move this somewhere else. The implementation for this is actually in -// GraphicsContextAndroid.cpp, but this is used by a handful of other files -SkCanvas* android_gc2canvas(WebCore::GraphicsContext* gc); - -// used to inflate node cache entry -#define CURSOR_RING_HIT_TEST_RADIUS 5 - - -#endif diff --git a/Source/WebCore/platform/graphics/android/layers/CanvasTexture.cpp b/Source/WebCore/platform/graphics/android/layers/CanvasTexture.cpp index e4b2bc6..aacb0bc 100644 --- a/Source/WebCore/platform/graphics/android/layers/CanvasTexture.cpp +++ b/Source/WebCore/platform/graphics/android/layers/CanvasTexture.cpp @@ -31,7 +31,6 @@ #if USE(ACCELERATED_COMPOSITING) -#include "android_graphics.h" #include "AndroidLog.h" #include "GLUtils.h" #include "Image.h" @@ -134,10 +133,10 @@ bool CanvasTexture::uploadImageBuffer(ImageBuffer* imageBuffer) // Size mismatch, early abort (will fall back to software) if (imageBuffer->size() != m_size) return false; - GraphicsContext* gc = imageBuffer ? imageBuffer->context() : 0; - if (!gc) + SkCanvas* canvas = imageBufferCanvas(imageBuffer); + if (!canvas) return false; - const SkBitmap& bitmap = android_gc2canvas(gc)->getDevice()->accessBitmap(false); + const SkBitmap& bitmap = canvas->getDevice()->accessBitmap(false); if (!GLUtils::updateSharedSurfaceTextureWithBitmap(anw, bitmap)) return false; m_hasValidTexture = true; diff --git a/Source/WebCore/platform/graphics/android/layers/VideoLayerManager.cpp b/Source/WebCore/platform/graphics/android/layers/VideoLayerManager.cpp index a7b3184..1f28cdf 100644 --- a/Source/WebCore/platform/graphics/android/layers/VideoLayerManager.cpp +++ b/Source/WebCore/platform/graphics/android/layers/VideoLayerManager.cpp @@ -73,7 +73,7 @@ int VideoLayerManager::getButtonSize() return VIDEO_BUTTON_SIZE; } -GLuint VideoLayerManager::createTextureFromImage(int buttonType) +GLuint VideoLayerManager::createTextureFromImage(RenderSkinMediaButton::MediaButton buttonType) { SkRect rect = SkRect(m_buttonRect); SkBitmap bitmap; @@ -83,8 +83,7 @@ GLuint VideoLayerManager::createTextureFromImage(int buttonType) SkCanvas canvas(bitmap); canvas.drawARGB(0, 0, 0, 0, SkXfermode::kClear_Mode); - RenderSkinMediaButton::Draw(&canvas, m_buttonRect, buttonType, true, 0, - false); + RenderSkinMediaButton::Draw(&canvas, m_buttonRect, buttonType, true, false); GLuint texture; glGenTextures(1, &texture); diff --git a/Source/WebCore/platform/graphics/android/layers/VideoLayerManager.h b/Source/WebCore/platform/graphics/android/layers/VideoLayerManager.h index adce0f4..346afe4 100644 --- a/Source/WebCore/platform/graphics/android/layers/VideoLayerManager.h +++ b/Source/WebCore/platform/graphics/android/layers/VideoLayerManager.h @@ -28,6 +28,7 @@ #include "GLUtils.h" #include "IntRect.h" +#include "RenderSkinMediaButton.h" #include #include #include @@ -122,7 +123,7 @@ private: Vector m_retiredTextures; android::Mutex m_retiredTexturesLock; - GLuint createTextureFromImage(int buttonType); + GLuint createTextureFromImage(RenderSkinMediaButton::MediaButton buttonType); // Texture for showing the static image will be created at native side. bool m_createdTexture; diff --git a/Source/WebCore/platform/graphics/android/rendering/GLExtras.cpp b/Source/WebCore/platform/graphics/android/rendering/GLExtras.cpp index 2c114d6..175c552 100644 --- a/Source/WebCore/platform/graphics/android/rendering/GLExtras.cpp +++ b/Source/WebCore/platform/graphics/android/rendering/GLExtras.cpp @@ -35,7 +35,6 @@ #include "IntRect.h" #include "SkPath.h" #include "TilesManager.h" -#include "android_graphics.h" // Touch ring border width. This is doubled if the ring is not pressed #define RING_BORDER_WIDTH 1 diff --git a/Source/WebCore/plugins/android/PluginViewAndroid.cpp b/Source/WebCore/plugins/android/PluginViewAndroid.cpp index 2cc95b1..24a14aa 100644 --- a/Source/WebCore/plugins/android/PluginViewAndroid.cpp +++ b/Source/WebCore/plugins/android/PluginViewAndroid.cpp @@ -55,7 +55,6 @@ #include "Touch.h" #include "TouchEvent.h" #include "TouchList.h" -#include "android_graphics.h" #include "SkCanvas.h" #include "npruntime_impl.h" // #include "runtime_root.h" @@ -690,15 +689,12 @@ void PluginView::paint(GraphicsContext* context, const IntRect& rect) notification of its global position change. */ updatePluginWidget(); - SkCanvas* canvas = context->platformContext()->getCanvas(); - if (!canvas) - return; - m_window->setSurfaceClip(canvas->getTotalClip().getBounds()); + m_window->setSurfaceClip(context->platformContext()->getTotalClipBounds()); } else { m_window->inval(rect, false); context->save(); context->translate(frame.x(), frame.y()); - m_window->draw(android_gc2canvas(context)); + m_window->draw(context->platformContext()); context->restore(); } diff --git a/Source/WebKit/android/RenderSkinMediaButton.cpp b/Source/WebKit/android/RenderSkinMediaButton.cpp index b3aa57d..a2f19c3 100644 --- a/Source/WebKit/android/RenderSkinMediaButton.cpp +++ b/Source/WebKit/android/RenderSkinMediaButton.cpp @@ -26,12 +26,13 @@ #define LOG_TAG "WebCore" #include "config.h" -#include "android_graphics.h" +#include "RenderSkinMediaButton.h" + #include "Document.h" #include "IntRect.h" #include "Node.h" #include "RenderObject.h" -#include "RenderSkinMediaButton.h" +#include "RenderSkinAndroid.h" #include "RenderSlider.h" #include "SkCanvas.h" #include "SkNinePatch.h" @@ -88,8 +89,9 @@ void RenderSkinMediaButton::Decode() } } -void RenderSkinMediaButton::Draw(SkCanvas* canvas, const IntRect& r, int buttonType, - bool translucent, RenderObject* o, bool drawBackground) +void RenderSkinMediaButton::Draw(SkCanvas* canvas, const IntRect& r, + MediaButton buttonType, bool translucent, + bool drawBackground, const IntRect& thumb) { if (!gDecoded) { Decode(); @@ -179,9 +181,7 @@ void RenderSkinMediaButton::Draw(SkCanvas* canvas, const IntRect& r, int buttonT SkScalar quarterHeight = SkScalarHalf(SkScalarHalf(bounds.height())); bounds.fTop += quarterHeight + SkScalarHalf(3); bounds.fBottom += -quarterHeight + SK_ScalarHalf; - if (o && o->isSlider()) { - RenderSlider* slider = toRenderSlider(o); - IntRect thumb = slider->thumbRect(); + if (!thumb.isEmpty()) { // Inset the track by half the width of the thumb, so the track // does not appear to go beyond the space where the thumb can // be. diff --git a/Source/WebKit/android/RenderSkinMediaButton.h b/Source/WebKit/android/RenderSkinMediaButton.h index 484b90c..98c9e04 100644 --- a/Source/WebKit/android/RenderSkinMediaButton.h +++ b/Source/WebKit/android/RenderSkinMediaButton.h @@ -26,27 +26,43 @@ #ifndef RenderSkinMediaButton_h #define RenderSkinMediaButton_h -#include "RenderSkinAndroid.h" +#include "IntRect.h" class SkCanvas; namespace WebCore { -class IntRect; -class RenderObject; class RenderSkinMediaButton { public: static void Decode(); + /** - * Draw the skin to the canvas, using the rectangle for its bounds and the - * State to determine which skin to use, i.e. focused or not focused. + * Button types */ - static void Draw(SkCanvas* , const IntRect& , int buttonType, bool translucent = false, - RenderObject* o = 0, bool drawBackground = true); + typedef enum + { + PAUSE, + PLAY, + MUTE, + REWIND, + FORWARD, + FULLSCREEN, + SPINNER_OUTER, + SPINNER_INNER, + VIDEO, + BACKGROUND_SLIDER, + SLIDER_TRACK, + SLIDER_THUMB + } MediaButton; + /** - * Button types + * Draw the skin to the canvas, using the rectangle for its bounds and the + * State to determine which skin to use, i.e. focused or not focused. */ - enum { PAUSE, PLAY, MUTE, REWIND, FORWARD, FULLSCREEN, SPINNER_OUTER, SPINNER_INNER , VIDEO, BACKGROUND_SLIDER, SLIDER_TRACK, SLIDER_THUMB }; + static void Draw(SkCanvas* canvas, const IntRect& rect, MediaButton buttonType, + bool translucent = false, bool drawBackground = true, + const IntRect& thumb = IntRect()); + /** * Slider dimensions */ diff --git a/Source/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp b/Source/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp index ac5cd9d..f62b2d1 100644 --- a/Source/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp +++ b/Source/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp @@ -76,7 +76,6 @@ #include "WebViewClientError.h" #include "WebViewCore.h" #include "autofill/WebAutofill.h" -#include "android_graphics.h" #include #include diff --git a/Source/WebKit/android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp b/Source/WebKit/android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp index 409eff6..de91766 100644 --- a/Source/WebKit/android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp +++ b/Source/WebKit/android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp @@ -286,9 +286,6 @@ public: if (!m_poster || (!m_poster->getPixels() && !m_poster->pixelRef())) return; - SkCanvas* canvas = ctxt->platformContext()->getCanvas(); - if (!canvas) - return; // We paint with the following rules in mind: // - only downscale the poster, never upscale // - maintain the natural aspect ratio of the poster @@ -299,7 +296,7 @@ public: int posterX = ((r.width() - posterWidth) / 2) + r.x(); int posterY = ((r.height() - posterHeight) / 2) + r.y(); IntRect targetRect(posterX, posterY, posterWidth, posterHeight); - canvas->drawBitmapRect(*m_poster, 0, targetRect, 0); + ctxt->platformContext()->drawBitmapRect(*m_poster, 0, targetRect); } void onPosterFetched(SkBitmap* poster) diff --git a/Source/WebKit/android/jni/WebCoreFrameBridge.cpp b/Source/WebKit/android/jni/WebCoreFrameBridge.cpp index 4cd39f6..39ae07e 100644 --- a/Source/WebKit/android/jni/WebCoreFrameBridge.cpp +++ b/Source/WebKit/android/jni/WebCoreFrameBridge.cpp @@ -89,7 +89,6 @@ #include "WebFrameView.h" #include "WebUrlLoaderClient.h" #include "WebViewCore.h" -#include "android_graphics.h" #include "jni.h" #include "wds/DebugServer.h" diff --git a/Source/WebKit/android/jni/WebFrameView.cpp b/Source/WebKit/android/jni/WebFrameView.cpp index 10e31dc..ed332aa 100644 --- a/Source/WebKit/android/jni/WebFrameView.cpp +++ b/Source/WebKit/android/jni/WebFrameView.cpp @@ -28,7 +28,6 @@ #include #include "WebFrameView.h" -#include "android_graphics.h" #include "GraphicsContext.h" #include "Frame.h" #include "FrameTree.h" diff --git a/Source/WebKit/android/jni/WebViewCore.cpp b/Source/WebKit/android/jni/WebViewCore.cpp index 79019cb..3324bfd 100644 --- a/Source/WebKit/android/jni/WebViewCore.cpp +++ b/Source/WebKit/android/jni/WebViewCore.cpp @@ -131,7 +131,6 @@ #include "WebCoreJni.h" #include "WebFrameView.h" #include "WindowsKeyboardCodes.h" -#include "android_graphics.h" #include "autofill/WebAutofill.h" #include "htmlediting.h" #include "markup.h" diff --git a/Source/WebKit/android/nav/WebView.cpp b/Source/WebKit/android/nav/WebView.cpp index c708c25..66dbdc1 100644 --- a/Source/WebKit/android/nav/WebView.cpp +++ b/Source/WebKit/android/nav/WebView.cpp @@ -58,7 +58,6 @@ #include "WebCoreJni.h" #include "WebRequestContext.h" #include "WebViewCore.h" -#include "android_graphics.h" #ifdef GET_NATIVE_VIEW #undef GET_NATIVE_VIEW diff --git a/Source/WebKit/android/plugins/ANPSurfaceInterface.cpp b/Source/WebKit/android/plugins/ANPSurfaceInterface.cpp index 92dbbcd..2b593e2 100644 --- a/Source/WebKit/android/plugins/ANPSurfaceInterface.cpp +++ b/Source/WebKit/android/plugins/ANPSurfaceInterface.cpp @@ -30,7 +30,6 @@ #include "PluginView.h" #include "PluginWidgetAndroid.h" #include "SkANP.h" -#include "android_graphics.h" #include #include #include diff --git a/Source/WebKit/android/plugins/PluginWidgetAndroid.cpp b/Source/WebKit/android/plugins/PluginWidgetAndroid.cpp index 09bb24e..2fd2ef4 100644 --- a/Source/WebKit/android/plugins/PluginWidgetAndroid.cpp +++ b/Source/WebKit/android/plugins/PluginWidgetAndroid.cpp @@ -42,7 +42,6 @@ #include "SkString.h" #include "SkTime.h" #include "WebViewCore.h" -#include "android_graphics.h" #include //#define PLUGIN_DEBUG_LOCAL // controls the printing of log messages @@ -225,7 +224,7 @@ void PluginWidgetAndroid::viewInvalidate() { m_core->viewInvalidate(rect); } -void PluginWidgetAndroid::draw(SkCanvas* canvas) { +void PluginWidgetAndroid::draw(PlatformGraphicsContext* context) { if (NULL == m_flipPixelRef || !m_flipPixelRef->isDirty()) { return; } @@ -249,10 +248,11 @@ void PluginWidgetAndroid::draw(SkCanvas* canvas) { bitmap) && pkg->pluginFuncs()->event(instance, &event)) { - if (canvas && m_pluginWindow) { + if (context && m_pluginWindow) { SkBitmap bm(bitmap); bm.setPixelRef(m_flipPixelRef); - canvas->drawBitmap(bm, 0, 0); + IntRect dst(0, 0, bm.width(), bm.height()); + context->drawBitmapRect(bm, 0, dst); } } break; diff --git a/Source/WebKit/android/plugins/PluginWidgetAndroid.h b/Source/WebKit/android/plugins/PluginWidgetAndroid.h index 87612dd..73b116b 100644 --- a/Source/WebKit/android/plugins/PluginWidgetAndroid.h +++ b/Source/WebKit/android/plugins/PluginWidgetAndroid.h @@ -28,6 +28,7 @@ #include "android_npapi.h" #include "ANPSystem_npapi.h" +#include "GraphicsContext.h" #include "IntPoint.h" #include "IntRect.h" #include "MediaLayer.h" @@ -98,7 +99,7 @@ struct PluginWidgetAndroid { /* Called to draw into the plugin's bitmap. If canvas is non-null, the bitmap itself is then drawn into the canvas. */ - void draw(SkCanvas* canvas = NULL); + void draw(PlatformGraphicsContext* context = NULL); /* Send this event to the plugin instance. A non-zero value will be returned if the plugin handled the event. -- cgit v1.1