aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/pipe/SkGPipeWrite.cpp
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-12-12 19:02:53 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-12-12 19:02:53 +0000
commit68d61ed83ec7b6e98e9623c2f5c9e7b1a32d25bb (patch)
tree1462843b0770736314438d38676b3dd542bd9d1a /src/pipe/SkGPipeWrite.cpp
parent8cdf0f52ff395d4053f7ed5c20861c42eba25d31 (diff)
make RRect and Oval first-class drawing primitives in SkCanvas.
add RRect as a first-class clip primitive. Review URL: https://codereview.appspot.com/6923058 git-svn-id: http://skia.googlecode.com/svn/trunk@6762 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/pipe/SkGPipeWrite.cpp')
-rw-r--r--src/pipe/SkGPipeWrite.cpp40
1 files changed, 38 insertions, 2 deletions
diff --git a/src/pipe/SkGPipeWrite.cpp b/src/pipe/SkGPipeWrite.cpp
index f0b4e0aee6..cfd1e7ceef 100644
--- a/src/pipe/SkGPipeWrite.cpp
+++ b/src/pipe/SkGPipeWrite.cpp
@@ -21,12 +21,17 @@
#include "SkPathEffect.h"
#include "SkPictureFlat.h"
#include "SkRasterizer.h"
+#include "SkRRect.h"
#include "SkShader.h"
#include "SkStream.h"
#include "SkTSearch.h"
#include "SkTypeface.h"
#include "SkWriter32.h"
+enum {
+ kSizeOfFlatRRect = sizeof(SkRect) + 4 * sizeof(SkVector)
+};
+
static bool isCrossProcess(uint32_t flags) {
return SkToBool(flags & SkGPipeWriter::kCrossProcess_Flag);
}
@@ -208,8 +213,8 @@ public:
virtual bool skew(SkScalar sx, SkScalar sy) SK_OVERRIDE;
virtual bool concat(const SkMatrix& matrix) SK_OVERRIDE;
virtual void setMatrix(const SkMatrix& matrix) SK_OVERRIDE;
- virtual bool clipRect(const SkRect& rect, SkRegion::Op op,
- bool doAntiAlias = false) SK_OVERRIDE;
+ virtual bool clipRect(const SkRect&, SkRegion::Op op, bool doAntiAlias = false) SK_OVERRIDE;
+ virtual bool clipRRect(const SkRRect&, SkRegion::Op op, bool doAntiAlias = false) SK_OVERRIDE;
virtual bool clipPath(const SkPath& path, SkRegion::Op op,
bool doAntiAlias = false) SK_OVERRIDE;
virtual bool clipRegion(const SkRegion& region, SkRegion::Op op) SK_OVERRIDE;
@@ -217,7 +222,9 @@ public:
virtual void drawPaint(const SkPaint& paint) SK_OVERRIDE;
virtual void drawPoints(PointMode, size_t count, const SkPoint pts[],
const SkPaint&) SK_OVERRIDE;
+ virtual void drawOval(const SkRect&, const SkPaint&) SK_OVERRIDE;
virtual void drawRect(const SkRect& rect, const SkPaint&) SK_OVERRIDE;
+ virtual void drawRRect(const SkRRect&, const SkPaint&) SK_OVERRIDE;
virtual void drawPath(const SkPath& path, const SkPaint&) SK_OVERRIDE;
virtual void drawBitmap(const SkBitmap&, SkScalar left, SkScalar top,
const SkPaint*) SK_OVERRIDE;
@@ -625,6 +632,17 @@ bool SkGPipeCanvas::clipRect(const SkRect& rect, SkRegion::Op rgnOp,
return this->INHERITED::clipRect(rect, rgnOp, doAntiAlias);
}
+bool SkGPipeCanvas::clipRRect(const SkRRect& rrect, SkRegion::Op rgnOp,
+ bool doAntiAlias) {
+ NOTIFY_SETUP(this);
+ if (this->needOpBytes(kSizeOfFlatRRect)) {
+ unsigned flags = doAntiAlias & kClip_HasAntiAlias_DrawOpFlag;
+ this->writeOp(kClipRRect_DrawOp, flags, rgnOp);
+ fWriter.writeRRect(rrect);
+ }
+ return this->INHERITED::clipRRect(rrect, rgnOp, doAntiAlias);
+}
+
bool SkGPipeCanvas::clipPath(const SkPath& path, SkRegion::Op rgnOp,
bool doAntiAlias) {
NOTIFY_SETUP(this);
@@ -683,6 +701,15 @@ void SkGPipeCanvas::drawPoints(PointMode mode, size_t count,
}
}
+void SkGPipeCanvas::drawOval(const SkRect& rect, const SkPaint& paint) {
+ NOTIFY_SETUP(this);
+ this->writePaint(paint);
+ if (this->needOpBytes(sizeof(SkRect))) {
+ this->writeOp(kDrawOval_DrawOp);
+ fWriter.writeRect(rect);
+ }
+}
+
void SkGPipeCanvas::drawRect(const SkRect& rect, const SkPaint& paint) {
NOTIFY_SETUP(this);
this->writePaint(paint);
@@ -692,6 +719,15 @@ void SkGPipeCanvas::drawRect(const SkRect& rect, const SkPaint& paint) {
}
}
+void SkGPipeCanvas::drawRRect(const SkRRect& rrect, const SkPaint& paint) {
+ NOTIFY_SETUP(this);
+ this->writePaint(paint);
+ if (this->needOpBytes(kSizeOfFlatRRect)) {
+ this->writeOp(kDrawRRect_DrawOp);
+ fWriter.writeRRect(rrect);
+ }
+}
+
void SkGPipeCanvas::drawPath(const SkPath& path, const SkPaint& paint) {
NOTIFY_SETUP(this);
this->writePaint(paint);