diff options
author | bsalomon <bsalomon@google.com> | 2016-05-10 09:14:17 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-05-10 09:14:17 -0700 |
commit | 6663acff010ce752e4bf778da81fa97448c9db31 (patch) | |
tree | ba48f7716f7ef948d9faac90599b8a555c0f51d3 /include | |
parent | 44d427e048b2e290e086dc2c9f9227818388ef17 (diff) |
Replace GrStrokeInfo with GrStyle.
A side effect is that arbitrary path effects can no be pushed deeper into the Ganesh flow for paths. They may be applied by path renderers.
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1957363002
Committed: https://skia.googlesource.com/skia/+/33595bdf4b64a745f6340338d307e806e96c587f
Review-Url: https://codereview.chromium.org/1957363002
Diffstat (limited to 'include')
-rw-r--r-- | include/gpu/GrContext.h | 1 | ||||
-rw-r--r-- | include/gpu/GrDrawContext.h | 31 | ||||
-rw-r--r-- | include/gpu/GrTestUtils.h | 35 |
3 files changed, 43 insertions, 24 deletions
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h index 1c9a27e25f..44dfda65ee 100644 --- a/include/gpu/GrContext.h +++ b/include/gpu/GrContext.h @@ -43,7 +43,6 @@ class GrTextBlobCache; class GrTextContext; class GrTextureParams; class GrVertexBuffer; -class GrStrokeInfo; class GrSwizzle; class SkTraceMemoryDump; diff --git a/include/gpu/GrDrawContext.h b/include/gpu/GrDrawContext.h index 7bb9aafc78..458ee4f539 100644 --- a/include/gpu/GrDrawContext.h +++ b/include/gpu/GrDrawContext.h @@ -28,7 +28,7 @@ class GrPaint; class GrPathProcessor; class GrPipelineBuilder; class GrRenderTarget; -class GrStrokeInfo; +class GrStyle; class GrSurface; class SkDrawFilter; struct SkIPoint; @@ -53,7 +53,7 @@ public: // TODO: it is odd that we need both the SkPaint in the following 3 methods. // We should extract the text parameters from SkPaint and pass them separately - // akin to GrStrokeInfo (GrTextInfo?) + // akin to GrStyle (GrTextInfo?) virtual void drawText(const GrClip&, const GrPaint&, const SkPaint&, const SkMatrix& viewMatrix, const char text[], size_t byteLength, SkScalar x, SkScalar y, const SkIRect& clipBounds); @@ -90,19 +90,15 @@ public: * Draw the rect using a paint. * @param paint describes how to color pixels. * @param viewMatrix transformation matrix - * @param strokeInfo the stroke information (width, join, cap), and. - * the dash information (intervals, count, phase). - * If strokeInfo == NULL, then the rect is filled. - * Otherwise, if stroke width == 0, then the stroke - * is always a single pixel thick, else the rect is - * mitered/beveled stroked based on stroke width. + * @param style The style to apply. Null means fill. Currently path effects are not + * allowed. * The rects coords are used to access the paint (through texture matrix) */ void drawRect(const GrClip&, const GrPaint& paint, const SkMatrix& viewMatrix, const SkRect&, - const GrStrokeInfo* strokeInfo = nullptr); + const GrStyle* style = nullptr); /** * Maps a rectangle of shader coordinates to a rectangle and fills that rectangle. @@ -133,14 +129,13 @@ public: * @param paint describes how to color pixels. * @param viewMatrix transformation matrix * @param rrect the roundrect to draw - * @param strokeInfo the stroke information (width, join, cap) and - * the dash information (intervals, count, phase). + * @param style style to apply to the rrect. Currently path effects are not allowed. */ void drawRRect(const GrClip&, const GrPaint&, const SkMatrix& viewMatrix, const SkRRect& rrect, - const GrStrokeInfo&); + const GrStyle& style); /** * Shortcut for drawing an SkPath consisting of nested rrects using a paint. @@ -164,14 +159,13 @@ public: * @param paint describes how to color pixels. * @param viewMatrix transformation matrix * @param path the path to draw - * @param strokeInfo the stroke information (width, join, cap) and - * the dash information (intervals, count, phase). + * @param style style to apply to the path. */ void drawPath(const GrClip&, const GrPaint&, const SkMatrix& viewMatrix, const SkPath&, - const GrStrokeInfo&); + const GrStyle& style); /** * Draws vertices with a paint. @@ -226,14 +220,13 @@ public: * @param paint describes how to color pixels. * @param viewMatrix transformation matrix * @param oval the bounding rect of the oval. - * @param strokeInfo the stroke information (width, join, cap) and - * the dash information (intervals, count, phase). + * @param style style to apply to the oval. Currently path effects are not allowed. */ void drawOval(const GrClip&, const GrPaint& paint, const SkMatrix& viewMatrix, const SkRect& oval, - const GrStrokeInfo& strokeInfo); + const GrStyle& style); /** * Draw the image stretched differentially to fit into dst. @@ -318,7 +311,7 @@ private: const GrPaint& paint, const SkMatrix& viewMatrix, const SkPath& path, - const GrStrokeInfo& strokeInfo); + const GrStyle& style); // This entry point allows the GrTextContext-derived classes to add their batches to // the drawTarget. diff --git a/include/gpu/GrTestUtils.h b/include/gpu/GrTestUtils.h index 475e38a6a1..caaf5d9785 100644 --- a/include/gpu/GrTestUtils.h +++ b/include/gpu/GrTestUtils.h @@ -13,10 +13,12 @@ #ifdef GR_TEST_UTILS #include "GrColor.h" +#include "SkPathEffect.h" #include "SkRandom.h" #include "SkStrokeRec.h" +#include "../private/SkTemplates.h" -class GrStrokeInfo; +class GrStyle; class SkMatrix; class SkPath; class SkRRect; @@ -24,7 +26,7 @@ struct SkRect; namespace GrTest { /** - * A helper for use in Test functions. + * Helpers for use in Test functions. */ const SkMatrix& TestMatrix(SkRandom*); const SkMatrix& TestMatrixPreservesRightAngles(SkRandom*); @@ -36,9 +38,34 @@ const SkRRect& TestRRectSimple(SkRandom*); const SkPath& TestPath(SkRandom*); const SkPath& TestPathConvex(SkRandom*); SkStrokeRec TestStrokeRec(SkRandom*); -GrStrokeInfo TestStrokeInfo(SkRandom*); +/** Creates styles with dash path effects and null path effects */ +void TestStyle(SkRandom*, GrStyle*); -} +// We have a simplified dash path effect here to avoid relying on SkDashPathEffect which +// is in the optional build target effects. +class TestDashPathEffect : public SkPathEffect { +public: + static sk_sp<SkPathEffect> Make(const SkScalar* intervals, int count, SkScalar phase) { + return sk_sp<SkPathEffect>(new TestDashPathEffect(intervals, count, phase)); + } + + bool filterPath(SkPath* dst, const SkPath&, SkStrokeRec* , const SkRect*) const override; + DashType asADash(DashInfo* info) const override; + Factory getFactory() const override { return nullptr; } + void toString(SkString*) const override {} + +private: + TestDashPathEffect(const SkScalar* intervals, int count, SkScalar phase); + + int fCount; + SkAutoTArray<SkScalar> fIntervals; + SkScalar fPhase; + SkScalar fInitialDashLength; + int fInitialDashIndex; + SkScalar fIntervalLength; +}; + +} // namespace GrTest static inline GrColor GrRandomColor(SkRandom* random) { // There are only a few cases of random colors which interest us |