summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/platform/graphics/android/context
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2012-08-03 16:00:32 -0700
committerJohn Reck <jreck@google.com>2012-08-06 17:46:09 -0700
commit3718b58e4da76b7025aa5316a51264c5e38f2569 (patch)
tree862c59605fa3e2bd61ae279930f1d6cf70edb1f3 /Source/WebCore/platform/graphics/android/context
parent6228f1617d7525d64a23edd3b497791c6a06e842 (diff)
downloadexternal_webkit-3718b58e4da76b7025aa5316a51264c5e38f2569.zip
external_webkit-3718b58e4da76b7025aa5316a51264c5e38f2569.tar.gz
external_webkit-3718b58e4da76b7025aa5316a51264c5e38f2569.tar.bz2
Remove usages of getCanvas
Everything goes through either PlatformGraphicsContext or recordingCanvas() Change-Id: I375a4294d2e8d4b467b70c6b8a7f0b96f402f252
Diffstat (limited to 'Source/WebCore/platform/graphics/android/context')
-rw-r--r--Source/WebCore/platform/graphics/android/context/GraphicsContextAndroid.cpp10
-rw-r--r--Source/WebCore/platform/graphics/android/context/GraphicsOperation.h30
-rw-r--r--Source/WebCore/platform/graphics/android/context/PlatformGraphicsContext.h11
-rw-r--r--Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp8
-rw-r--r--Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h11
-rw-r--r--Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextSkia.cpp13
-rw-r--r--Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextSkia.h10
-rw-r--r--Source/WebCore/platform/graphics/android/context/RecordingContextCanvasProxy.cpp2
-rw-r--r--Source/WebCore/platform/graphics/android/context/android_graphics.h42
9 files changed, 74 insertions, 63 deletions
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