Chromium Code Reviews| Index: src/gpu/gl/GrGLPath.cpp |
| diff --git a/src/gpu/gl/GrGLPath.cpp b/src/gpu/gl/GrGLPath.cpp |
| index c5a4425dcd5eef136986cc4afdacc844d3d528fd..62c6ddabf77803572375a0888e6141b79ecbb134 100644 |
| --- a/src/gpu/gl/GrGLPath.cpp |
| +++ b/src/gpu/gl/GrGLPath.cpp |
| @@ -8,6 +8,7 @@ |
| #include "GrGLPath.h" |
| #include "GrGpuGL.h" |
| +#include "SkStrokeRec.h" |
| #define GPUGL static_cast<GrGpuGL*>(this->getGpu()) |
| @@ -54,11 +55,39 @@ inline int num_pts(const SkPath::Verb verb) { |
| return gTable[verb]; |
| } |
| #endif |
| + |
| +inline GrGLenum sk_join_to_gr_gl_join(const SkPaint::Join& join) { |
|
bsalomon
2013/09/19 18:14:48
can just call this .._to_gl_join (no need for _gr)
Kimmo Kinnunen
2013/10/08 12:15:36
Done.
|
| + static GrGLenum gSkJoinsToGrGLJoins[] = { |
| + GR_GL_MITER_REVERT, |
| + GR_GL_ROUND, |
| + GR_GL_BEVEL |
| + }; |
| + return gSkJoinsToGrGLJoins[join]; |
| + GR_STATIC_ASSERT(0 == SkPaint::kMiter_Join); |
| + GR_STATIC_ASSERT(1 == SkPaint::kRound_Join); |
| + GR_STATIC_ASSERT(2 == SkPaint::kBevel_Join); |
| + GR_STATIC_ASSERT(GR_ARRAY_COUNT(gSkJoinsToGrGLJoins) == SkPaint::kJoinCount); |
| +} |
| + |
| +inline GrGLenum sk_cap_to_gr_gl_cap(const SkPaint::Cap& cap) { |
| + static GrGLenum gSkCapsToGrGLCaps[] = { |
| + GR_GL_FLAT, |
| + GR_GL_ROUND, |
| + GR_GL_SQUARE |
| + }; |
| + return gSkCapsToGrGLCaps[cap]; |
| + GR_STATIC_ASSERT(0 == SkPaint::kButt_Cap); |
| + GR_STATIC_ASSERT(1 == SkPaint::kRound_Cap); |
| + GR_STATIC_ASSERT(2 == SkPaint::kSquare_Cap); |
| + GR_STATIC_ASSERT(GR_ARRAY_COUNT(gSkCapsToGrGLCaps) == SkPaint::kCapCount); |
| +} |
| + |
| } |
| static const bool kIsWrapped = false; // The constructor creates the GL path object. |
| -GrGLPath::GrGLPath(GrGpuGL* gpu, const SkPath& path) : INHERITED(gpu, kIsWrapped) { |
| +GrGLPath::GrGLPath(GrGpuGL* gpu, const SkPath& path, const SkStrokeRec& stroke) |
| + : INHERITED(gpu, kIsWrapped) { |
| #ifndef SK_SCALAR_IS_FLOAT |
| GrCrash("Assumes scalar is float."); |
| #endif |
| @@ -90,6 +119,19 @@ GrGLPath::GrGLPath(GrGpuGL* gpu, const SkPath& path) : INHERITED(gpu, kIsWrapped |
| verbCnt, &pathCommands[0], |
| 2 * pointCnt, GR_GL_FLOAT, &pathPoints[0])); |
| fBounds = path.getBounds(); |
| + |
| + if (stroke.needToApply()) { |
| + GL_CALL(PathParameterf(fPathID, GR_GL_PATH_STROKE_WIDTH, SkScalarToFloat(stroke.getWidth()))); |
| + GL_CALL(PathParameterf(fPathID, GR_GL_PATH_MITER_LIMIT, SkScalarToFloat(stroke.getMiter()))); |
| + GrGLenum join = sk_join_to_gr_gl_join(stroke.getJoin()); |
| + GL_CALL(PathParameteri(fPathID, GR_GL_PATH_JOIN_STYLE, join)); |
| + GrGLenum cap = sk_cap_to_gr_gl_cap(stroke.getCap()); |
| + GL_CALL(PathParameteri(fPathID, GR_GL_PATH_INITIAL_END_CAP, cap)); |
| + GL_CALL(PathParameteri(fPathID, GR_GL_PATH_TERMINAL_END_CAP, cap)); |
| + |
| + // FIXME: try to account for stroking, without rasterizing the stroke. |
| + fBounds.outset(SkScalarToFloat(stroke.getWidth()), SkScalarToFloat(stroke.getWidth())); |
| + } |
| } |
| GrGLPath::~GrGLPath() { |