summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
Diffstat (limited to 'libs')
-rw-r--r--libs/hwui/Canvas.h7
-rw-r--r--libs/hwui/DisplayListCanvas.h2
-rw-r--r--libs/hwui/SkiaCanvas.cpp28
3 files changed, 13 insertions, 24 deletions
diff --git a/libs/hwui/Canvas.h b/libs/hwui/Canvas.h
index 7ad0683..aa24673 100644
--- a/libs/hwui/Canvas.h
+++ b/libs/hwui/Canvas.h
@@ -29,7 +29,7 @@ class ANDROID_API Canvas {
public:
virtual ~Canvas() {};
- static Canvas* create_canvas(SkBitmap* bitmap);
+ static Canvas* create_canvas(const SkBitmap& bitmap);
/**
* Create a new Canvas object which delegates to an SkCanvas.
@@ -52,7 +52,7 @@ public:
*/
virtual SkCanvas* asSkCanvas() = 0;
- virtual void setBitmap(SkBitmap* bitmap, bool copyState) = 0;
+ virtual void setBitmap(const SkBitmap& bitmap) = 0;
virtual bool isOpaque() = 0;
virtual int width() = 0;
@@ -87,7 +87,8 @@ public:
virtual bool quickRejectRect(float left, float top, float right, float bottom) const = 0;
virtual bool quickRejectPath(const SkPath& path) const = 0;
- virtual bool clipRect(float left, float top, float right, float bottom, SkRegion::Op op) = 0;
+ virtual bool clipRect(float left, float top, float right, float bottom,
+ SkRegion::Op op = SkRegion::kIntersect_Op) = 0;
virtual bool clipPath(const SkPath* path, SkRegion::Op op) = 0;
virtual bool clipRegion(const SkRegion* region, SkRegion::Op op) = 0;
diff --git a/libs/hwui/DisplayListCanvas.h b/libs/hwui/DisplayListCanvas.h
index a9ac57d..2b0b6b2 100644
--- a/libs/hwui/DisplayListCanvas.h
+++ b/libs/hwui/DisplayListCanvas.h
@@ -136,7 +136,7 @@ public:
// ----------------------------------------------------------------------------
virtual SkCanvas* asSkCanvas() override;
- virtual void setBitmap(SkBitmap* bitmap, bool copyState) override {
+ virtual void setBitmap(const SkBitmap& bitmap) override {
LOG_ALWAYS_FATAL("DisplayListCanvas is not backed by a bitmap.");
}
diff --git a/libs/hwui/SkiaCanvas.cpp b/libs/hwui/SkiaCanvas.cpp
index 8b11757..a323065 100644
--- a/libs/hwui/SkiaCanvas.cpp
+++ b/libs/hwui/SkiaCanvas.cpp
@@ -31,7 +31,7 @@ namespace android {
// Holds an SkCanvas reference plus additional native data.
class SkiaCanvas : public Canvas {
public:
- explicit SkiaCanvas(SkBitmap* bitmap);
+ explicit SkiaCanvas(const SkBitmap& bitmap);
/**
* Create a new SkiaCanvas.
@@ -49,7 +49,7 @@ public:
return mCanvas.get();
}
- virtual void setBitmap(SkBitmap* bitmap, bool copyState) override;
+ virtual void setBitmap(const SkBitmap& bitmap) override;
virtual bool isOpaque() override;
virtual int width() override;
@@ -145,19 +145,7 @@ private:
SkAutoTDelete<SkDeque> mSaveStack; // lazily allocated, tracks partial saves.
};
-// Construct an SkCanvas from the bitmap.
-static SkCanvas* createCanvas(SkBitmap* bitmap) {
- if (bitmap) {
- return SkNEW_ARGS(SkCanvas, (*bitmap));
- }
-
- // Create an empty bitmap device to prevent callers from crashing
- // if they attempt to draw into this canvas.
- SkBitmap emptyBitmap;
- return new SkCanvas(emptyBitmap);
-}
-
-Canvas* Canvas::create_canvas(SkBitmap* bitmap) {
+Canvas* Canvas::create_canvas(const SkBitmap& bitmap) {
return new SkiaCanvas(bitmap);
}
@@ -165,8 +153,8 @@ Canvas* Canvas::create_canvas(SkCanvas* skiaCanvas) {
return new SkiaCanvas(skiaCanvas);
}
-SkiaCanvas::SkiaCanvas(SkBitmap* bitmap) {
- mCanvas.reset(createCanvas(bitmap));
+SkiaCanvas::SkiaCanvas(const SkBitmap& bitmap) {
+ mCanvas.reset(new SkCanvas(bitmap));
}
// ----------------------------------------------------------------------------
@@ -191,11 +179,11 @@ private:
SkCanvas* m_dstCanvas;
};
-void SkiaCanvas::setBitmap(SkBitmap* bitmap, bool copyState) {
- SkCanvas* newCanvas = createCanvas(bitmap);
+void SkiaCanvas::setBitmap(const SkBitmap& bitmap) {
+ SkCanvas* newCanvas = new SkCanvas(bitmap);
SkASSERT(newCanvas);
- if (copyState) {
+ if (!bitmap.isNull()) {
// Copy the canvas matrix & clip state.
newCanvas->setMatrix(mCanvas->getTotalMatrix());
if (NULL != mCanvas->getDevice() && NULL != newCanvas->getDevice()) {