| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include "GrGLPath.h" | 9 #include "GrGLPath.h" |
| 10 #include "GrGpuGL.h" | 10 #include "GrGpuGL.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 0xFF, // conic | 23 0xFF, // conic |
| 24 GR_GL_CUBIC_CURVE_TO, | 24 GR_GL_CUBIC_CURVE_TO, |
| 25 GR_GL_CLOSE_PATH, | 25 GR_GL_CLOSE_PATH, |
| 26 }; | 26 }; |
| 27 GR_STATIC_ASSERT(0 == SkPath::kMove_Verb); | 27 GR_STATIC_ASSERT(0 == SkPath::kMove_Verb); |
| 28 GR_STATIC_ASSERT(1 == SkPath::kLine_Verb); | 28 GR_STATIC_ASSERT(1 == SkPath::kLine_Verb); |
| 29 GR_STATIC_ASSERT(2 == SkPath::kQuad_Verb); | 29 GR_STATIC_ASSERT(2 == SkPath::kQuad_Verb); |
| 30 GR_STATIC_ASSERT(4 == SkPath::kCubic_Verb); | 30 GR_STATIC_ASSERT(4 == SkPath::kCubic_Verb); |
| 31 GR_STATIC_ASSERT(5 == SkPath::kClose_Verb); | 31 GR_STATIC_ASSERT(5 == SkPath::kClose_Verb); |
| 32 | 32 |
| 33 GrAssert(verb >= 0 && (size_t)verb < GR_ARRAY_COUNT(gTable)); | 33 SkASSERT(verb >= 0 && (size_t)verb < GR_ARRAY_COUNT(gTable)); |
| 34 return gTable[verb]; | 34 return gTable[verb]; |
| 35 } | 35 } |
| 36 | 36 |
| 37 #ifdef SK_DEBUG | 37 #ifdef SK_DEBUG |
| 38 inline int num_pts(const SkPath::Verb verb) { | 38 inline int num_pts(const SkPath::Verb verb) { |
| 39 static const int gTable[] = { | 39 static const int gTable[] = { |
| 40 1, // move | 40 1, // move |
| 41 1, // line | 41 1, // line |
| 42 2, // quad | 42 2, // quad |
| 43 2, // conic | 43 2, // conic |
| 44 3, // cubic | 44 3, // cubic |
| 45 0, // close | 45 0, // close |
| 46 }; | 46 }; |
| 47 GR_STATIC_ASSERT(0 == SkPath::kMove_Verb); | 47 GR_STATIC_ASSERT(0 == SkPath::kMove_Verb); |
| 48 GR_STATIC_ASSERT(1 == SkPath::kLine_Verb); | 48 GR_STATIC_ASSERT(1 == SkPath::kLine_Verb); |
| 49 GR_STATIC_ASSERT(2 == SkPath::kQuad_Verb); | 49 GR_STATIC_ASSERT(2 == SkPath::kQuad_Verb); |
| 50 GR_STATIC_ASSERT(4 == SkPath::kCubic_Verb); | 50 GR_STATIC_ASSERT(4 == SkPath::kCubic_Verb); |
| 51 GR_STATIC_ASSERT(5 == SkPath::kClose_Verb); | 51 GR_STATIC_ASSERT(5 == SkPath::kClose_Verb); |
| 52 | 52 |
| 53 GrAssert(verb >= 0 && (size_t)verb < GR_ARRAY_COUNT(gTable)); | 53 SkASSERT(verb >= 0 && (size_t)verb < GR_ARRAY_COUNT(gTable)); |
| 54 return gTable[verb]; | 54 return gTable[verb]; |
| 55 } | 55 } |
| 56 #endif | 56 #endif |
| 57 } | 57 } |
| 58 | 58 |
| 59 static const bool kIsWrapped = false; // The constructor creates the GL path obj
ect. | 59 static const bool kIsWrapped = false; // The constructor creates the GL path obj
ect. |
| 60 | 60 |
| 61 GrGLPath::GrGLPath(GrGpuGL* gpu, const SkPath& path) : INHERITED(gpu, kIsWrapped
) { | 61 GrGLPath::GrGLPath(GrGpuGL* gpu, const SkPath& path) : INHERITED(gpu, kIsWrapped
) { |
| 62 #ifndef SK_SCALAR_IS_FLOAT | 62 #ifndef SK_SCALAR_IS_FLOAT |
| 63 GrCrash("Assumes scalar is float."); | 63 GrCrash("Assumes scalar is float."); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 77 // TODO: Direct access to path points since we could pass them on directly. | 77 // TODO: Direct access to path points since we could pass them on directly. |
| 78 path.getPoints(&pathPoints[0], pointCnt); | 78 path.getPoints(&pathPoints[0], pointCnt); |
| 79 path.getVerbs(&pathCommands[0], verbCnt); | 79 path.getVerbs(&pathCommands[0], verbCnt); |
| 80 | 80 |
| 81 GR_DEBUGCODE(int numPts = 0); | 81 GR_DEBUGCODE(int numPts = 0); |
| 82 for (int i = 0; i < verbCnt; ++i) { | 82 for (int i = 0; i < verbCnt; ++i) { |
| 83 SkPath::Verb v = static_cast<SkPath::Verb>(pathCommands[i]); | 83 SkPath::Verb v = static_cast<SkPath::Verb>(pathCommands[i]); |
| 84 pathCommands[i] = verb_to_gl_path_cmd(v); | 84 pathCommands[i] = verb_to_gl_path_cmd(v); |
| 85 GR_DEBUGCODE(numPts += num_pts(v)); | 85 GR_DEBUGCODE(numPts += num_pts(v)); |
| 86 } | 86 } |
| 87 GrAssert(pathPoints.count() == numPts); | 87 SkASSERT(pathPoints.count() == numPts); |
| 88 | 88 |
| 89 GL_CALL(PathCommands(fPathID, | 89 GL_CALL(PathCommands(fPathID, |
| 90 verbCnt, &pathCommands[0], | 90 verbCnt, &pathCommands[0], |
| 91 2 * pointCnt, GR_GL_FLOAT, &pathPoints[0])); | 91 2 * pointCnt, GR_GL_FLOAT, &pathPoints[0])); |
| 92 fBounds = path.getBounds(); | 92 fBounds = path.getBounds(); |
| 93 } | 93 } |
| 94 | 94 |
| 95 GrGLPath::~GrGLPath() { | 95 GrGLPath::~GrGLPath() { |
| 96 this->release(); | 96 this->release(); |
| 97 } | 97 } |
| 98 | 98 |
| 99 void GrGLPath::onRelease() { | 99 void GrGLPath::onRelease() { |
| 100 if (0 != fPathID && !this->isWrapped()) { | 100 if (0 != fPathID && !this->isWrapped()) { |
| 101 GL_CALL(DeletePaths(fPathID, 1)); | 101 GL_CALL(DeletePaths(fPathID, 1)); |
| 102 fPathID = 0; | 102 fPathID = 0; |
| 103 } | 103 } |
| 104 | 104 |
| 105 INHERITED::onRelease(); | 105 INHERITED::onRelease(); |
| 106 } | 106 } |
| 107 | 107 |
| 108 void GrGLPath::onAbandon() { | 108 void GrGLPath::onAbandon() { |
| 109 fPathID = 0; | 109 fPathID = 0; |
| 110 | 110 |
| 111 INHERITED::onAbandon(); | 111 INHERITED::onAbandon(); |
| 112 } | 112 } |
| OLD | NEW |