aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar sugoi@google.com <sugoi@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-12-17 21:16:45 +0000
committerGravatar sugoi@google.com <sugoi@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-12-17 21:16:45 +0000
commit5f74cf8c49701f514b69dc6f1a8b5c0ffd78af0a (patch)
tree3cec664355e570c921cd903dda21146806279185 /src/core
parent9f6a557548b4aec8aa0d3345488089b3d75f471c (diff)
Follow up on the previous patch :
- Moved the SkStrokeRec class in its own file - Replaced SkStroke by SkStrokeRec in Ganesh - Moved path stroking to the Ganesh level in some cases (everytime it isn't required to do it directly in SkGpuDevice). PathEffect and MaskFilter still require path stroking at the SkGpuDevice for now. - Renamed static functions in SkPath with proper names * No functionality shold have changed with this patch. This is a step towards enabling Ganesh Path Renderers to decide whether or not to stroke the path rather than always receiving the stroked path as an input argument. BUG=chromium:135111 TEST=Try path rendering tests from the gm Review URL: https://codereview.appspot.com/6946072 git-svn-id: http://skia.googlecode.com/svn/trunk@6861 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkPathEffect.cpp98
-rw-r--r--src/core/SkPicturePlayback.cpp2
-rw-r--r--src/core/SkStroke.h1
-rw-r--r--src/core/SkStrokeRec.cpp106
4 files changed, 107 insertions, 100 deletions
diff --git a/src/core/SkPathEffect.cpp b/src/core/SkPathEffect.cpp
index 9e84b2f2bc..8fbe5bfa87 100644
--- a/src/core/SkPathEffect.cpp
+++ b/src/core/SkPathEffect.cpp
@@ -6,107 +6,9 @@
* found in the LICENSE file.
*/
-
#include "SkPathEffect.h"
#include "SkPath.h"
#include "SkFlattenableBuffers.h"
-#include "SkPaintDefaults.h"
-
-// must be < 0, since ==0 means hairline, and >0 means normal stroke
-#define kStrokeRec_FillStyleWidth (-SK_Scalar1)
-
-SkStrokeRec::SkStrokeRec(InitStyle s) {
- fWidth = (kFill_InitStyle == s) ? kStrokeRec_FillStyleWidth : 0;
- fMiterLimit = SkPaintDefaults_MiterLimit;
- fCap = SkPaint::kDefault_Cap;
- fJoin = SkPaint::kDefault_Join;
- fStrokeAndFill = false;
-}
-
-SkStrokeRec::SkStrokeRec(const SkStrokeRec& src) {
- memcpy(this, &src, sizeof(src));
-}
-
-SkStrokeRec::SkStrokeRec(const SkPaint& paint) {
- switch (paint.getStyle()) {
- case SkPaint::kFill_Style:
- fWidth = kStrokeRec_FillStyleWidth;
- fStrokeAndFill = false;
- break;
- case SkPaint::kStroke_Style:
- fWidth = paint.getStrokeWidth();
- fStrokeAndFill = false;
- break;
- case SkPaint::kStrokeAndFill_Style:
- if (0 == paint.getStrokeWidth()) {
- // hairline+fill == fill
- fWidth = kStrokeRec_FillStyleWidth;
- fStrokeAndFill = false;
- } else {
- fWidth = paint.getStrokeWidth();
- fStrokeAndFill = true;
- }
- break;
- default:
- SkASSERT(!"unknown paint style");
- // fall back on just fill
- fWidth = kStrokeRec_FillStyleWidth;
- fStrokeAndFill = false;
- break;
- }
-
- // copy these from the paint, regardless of our "style"
- fMiterLimit = paint.getStrokeMiter();
- fCap = paint.getStrokeCap();
- fJoin = paint.getStrokeJoin();
-}
-
-SkStrokeRec::Style SkStrokeRec::getStyle() const {
- if (fWidth < 0) {
- return kFill_Style;
- } else if (0 == fWidth) {
- return kHairline_Style;
- } else {
- return fStrokeAndFill ? kStrokeAndFill_Style : kStroke_Style;
- }
-}
-
-void SkStrokeRec::setFillStyle() {
- fWidth = kStrokeRec_FillStyleWidth;
- fStrokeAndFill = false;
-}
-
-void SkStrokeRec::setHairlineStyle() {
- fWidth = 0;
- fStrokeAndFill = false;
-}
-
-void SkStrokeRec::setStrokeStyle(SkScalar width, bool strokeAndFill) {
- if (strokeAndFill && (0 == width)) {
- // hairline+fill == fill
- this->setFillStyle();
- } else {
- fWidth = width;
- fStrokeAndFill = strokeAndFill;
- }
-}
-
-#include "SkStroke.h"
-
-bool SkStrokeRec::applyToPath(SkPath* dst, const SkPath& src) const {
- if (fWidth <= 0) { // hairline or fill
- return false;
- }
-
- SkStroke stroker;
- stroker.setCap(fCap);
- stroker.setJoin(fJoin);
- stroker.setMiterLimit(fMiterLimit);
- stroker.setWidth(fWidth);
- stroker.setDoFill(fStrokeAndFill);
- stroker.strokePath(src, dst);
- return true;
-}
///////////////////////////////////////////////////////////////////////////////
diff --git a/src/core/SkPicturePlayback.cpp b/src/core/SkPicturePlayback.cpp
index 31ee3ece3a..e7f5ce8f85 100644
--- a/src/core/SkPicturePlayback.cpp
+++ b/src/core/SkPicturePlayback.cpp
@@ -643,7 +643,7 @@ void SkPicturePlayback::draw(SkCanvas& canvas) {
// kDrawComplete will be the signal that we have reached the end of
// the command stream
- static const int kDrawComplete = SK_MaxU32;
+ static const uint32_t kDrawComplete = SK_MaxU32;
SkReader32 reader(fOpData->bytes(), fOpData->size());
TextContainer text;
diff --git a/src/core/SkStroke.h b/src/core/SkStroke.h
index 33a7ecba5c..48805165cb 100644
--- a/src/core/SkStroke.h
+++ b/src/core/SkStroke.h
@@ -32,7 +32,6 @@ public:
void setMiterLimit(SkScalar);
void setWidth(SkScalar);
- SkScalar getWidthIfStroked() const { return fDoFill ? -SK_Scalar1 : fWidth; }
bool getDoFill() const { return SkToBool(fDoFill); }
void setDoFill(bool doFill) { fDoFill = SkToU8(doFill); }
diff --git a/src/core/SkStrokeRec.cpp b/src/core/SkStrokeRec.cpp
new file mode 100644
index 0000000000..756872bdfb
--- /dev/null
+++ b/src/core/SkStrokeRec.cpp
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2012 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkStrokeRec.h"
+#include "SkPaintDefaults.h"
+
+// must be < 0, since ==0 means hairline, and >0 means normal stroke
+#define kStrokeRec_FillStyleWidth (-SK_Scalar1)
+
+SkStrokeRec::SkStrokeRec(InitStyle s) {
+ fWidth = (kFill_InitStyle == s) ? kStrokeRec_FillStyleWidth : 0;
+ fMiterLimit = SkPaintDefaults_MiterLimit;
+ fCap = SkPaint::kDefault_Cap;
+ fJoin = SkPaint::kDefault_Join;
+ fStrokeAndFill = false;
+}
+
+SkStrokeRec::SkStrokeRec(const SkStrokeRec& src) {
+ memcpy(this, &src, sizeof(src));
+}
+
+SkStrokeRec::SkStrokeRec(const SkPaint& paint) {
+ switch (paint.getStyle()) {
+ case SkPaint::kFill_Style:
+ fWidth = kStrokeRec_FillStyleWidth;
+ fStrokeAndFill = false;
+ break;
+ case SkPaint::kStroke_Style:
+ fWidth = paint.getStrokeWidth();
+ fStrokeAndFill = false;
+ break;
+ case SkPaint::kStrokeAndFill_Style:
+ if (0 == paint.getStrokeWidth()) {
+ // hairline+fill == fill
+ fWidth = kStrokeRec_FillStyleWidth;
+ fStrokeAndFill = false;
+ } else {
+ fWidth = paint.getStrokeWidth();
+ fStrokeAndFill = true;
+ }
+ break;
+ default:
+ SkASSERT(!"unknown paint style");
+ // fall back on just fill
+ fWidth = kStrokeRec_FillStyleWidth;
+ fStrokeAndFill = false;
+ break;
+ }
+
+ // copy these from the paint, regardless of our "style"
+ fMiterLimit = paint.getStrokeMiter();
+ fCap = paint.getStrokeCap();
+ fJoin = paint.getStrokeJoin();
+}
+
+SkStrokeRec::Style SkStrokeRec::getStyle() const {
+ if (fWidth < 0) {
+ return kFill_Style;
+ } else if (0 == fWidth) {
+ return kHairline_Style;
+ } else {
+ return fStrokeAndFill ? kStrokeAndFill_Style : kStroke_Style;
+ }
+}
+
+void SkStrokeRec::setFillStyle() {
+ fWidth = kStrokeRec_FillStyleWidth;
+ fStrokeAndFill = false;
+}
+
+void SkStrokeRec::setHairlineStyle() {
+ fWidth = 0;
+ fStrokeAndFill = false;
+}
+
+void SkStrokeRec::setStrokeStyle(SkScalar width, bool strokeAndFill) {
+ if (strokeAndFill && (0 == width)) {
+ // hairline+fill == fill
+ this->setFillStyle();
+ } else {
+ fWidth = width;
+ fStrokeAndFill = strokeAndFill;
+ }
+}
+
+#include "SkStroke.h"
+
+bool SkStrokeRec::applyToPath(SkPath* dst, const SkPath& src) const {
+ if (fWidth <= 0) { // hairline or fill
+ return false;
+ }
+
+ SkStroke stroker;
+ stroker.setCap(fCap);
+ stroker.setJoin(fJoin);
+ stroker.setMiterLimit(fMiterLimit);
+ stroker.setWidth(fWidth);
+ stroker.setDoFill(fStrokeAndFill);
+ stroker.strokePath(src, dst);
+ return true;
+}
+