| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright 2012 The Android Open Source Project | |
| 3 * | |
| 4 * Use of this source code is governed by a BSD-style license that can be | |
| 5 * found in the LICENSE file. | |
| 6 */ | |
| 7 | |
| 8 #ifndef ANDROID_HWUI_PATH_RENDERER_H | |
| 9 #define ANDROID_HWUI_PATH_RENDERER_H | |
| 10 | |
| 11 #include <SkTArray.h> | |
| 12 | |
| 13 #include "Vertex.h" | |
| 14 | |
| 15 class SkMatrix; | |
| 16 | |
| 17 namespace android { | |
| 18 namespace uirenderer { | |
| 19 | |
| 20 class VertexBuffer { | |
| 21 public: | |
| 22 VertexBuffer(): | |
| 23 mBuffer(0), | |
| 24 mSize(0), | |
| 25 mCleanupMethod(0) | |
| 26 {} | |
| 27 | |
| 28 ~VertexBuffer() { | |
| 29 if (mCleanupMethod) | |
| 30 mCleanupMethod(mBuffer); | |
| 31 } | |
| 32 | |
| 33 template <class TYPE> | |
| 34 TYPE* alloc(int size) { | |
| 35 mSize = size; | |
| 36 mBuffer = (void*)new TYPE[size]; | |
| 37 mCleanupMethod = &(cleanup<TYPE>); | |
| 38 | |
| 39 return (TYPE*)mBuffer; | |
| 40 } | |
| 41 | |
| 42 void* getBuffer() { return mBuffer; } | |
| 43 unsigned int getSize() { return mSize; } | |
| 44 | |
| 45 private: | |
| 46 template <class TYPE> | |
| 47 static void cleanup(void* buffer) { | |
| 48 delete[] (TYPE*)buffer; | |
| 49 } | |
| 50 | |
| 51 void* mBuffer; | |
| 52 unsigned int mSize; | |
| 53 void (*mCleanupMethod)(void*); | |
| 54 }; | |
| 55 | |
| 56 class PathRenderer { | |
| 57 public: | |
| 58 static SkRect ComputePathBounds(const SkPath& path, const SkPaint* paint); | |
| 59 | |
| 60 static void ConvexPathVertices(const SkPath& path, const SkStrokeRec& stroke
, bool isAA, | |
| 61 const SkMatrix* transform, VertexBuffer* vertexBuffer); | |
| 62 | |
| 63 private: | |
| 64 static bool ConvexPathPerimeterVertices(const SkPath &path, bool forceClose, | |
| 65 float sqrInvScaleX, float sqrInvScaleY, SkTArray<Vertex, true>* outputVe
rtices); | |
| 66 | |
| 67 /* | |
| 68 endpoints a & b, | |
| 69 control c | |
| 70 */ | |
| 71 static void RecursiveQuadraticBezierVertices( | |
| 72 float ax, float ay, | |
| 73 float bx, float by, | |
| 74 float cx, float cy, | |
| 75 float sqrInvScaleX, float sqrInvScaleY, | |
| 76 SkTArray<Vertex, true>* outputVertices); | |
| 77 | |
| 78 /* | |
| 79 endpoints p1, p2 | |
| 80 control c1, c2 | |
| 81 */ | |
| 82 static void RecursiveCubicBezierVertices( | |
| 83 float p1x, float p1y, | |
| 84 float c1x, float c1y, | |
| 85 float p2x, float p2y, | |
| 86 float c2x, float c2y, | |
| 87 float sqrInvScaleX, float sqrInvScaleY, | |
| 88 SkTArray<Vertex, true>* outputVertices); | |
| 89 }; | |
| 90 | |
| 91 }; // namespace uirenderer | |
| 92 }; // namespace android | |
| 93 | |
| 94 #endif // ANDROID_HWUI_PATH_RENDERER_H | |
| OLD | NEW |