| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef GrPathRendering_DEFINED | 8 #ifndef GrPathRendering_DEFINED |
| 9 #define GrPathRendering_DEFINED | 9 #define GrPathRendering_DEFINED |
| 10 | 10 |
| 11 #include "SkPath.h" | 11 #include "SkPath.h" |
| 12 #include "GrGpu.h" |
| 12 #include "GrPathRange.h" | 13 #include "GrPathRange.h" |
| 13 | 14 |
| 14 class SkDescriptor; | 15 class SkDescriptor; |
| 15 class SkTypeface; | 16 class SkTypeface; |
| 16 class GrPath; | 17 class GrPath; |
| 17 class GrGpu; | |
| 18 class GrStencilSettings; | 18 class GrStencilSettings; |
| 19 class GrStrokeInfo; | 19 class GrStrokeInfo; |
| 20 | 20 |
| 21 /** | 21 /** |
| 22 * Abstract class wrapping HW path rendering API. | 22 * Abstract class wrapping HW path rendering API. |
| 23 * | 23 * |
| 24 * The subclasses of this class use the possible HW API to render paths (as oppo
sed to path | 24 * The subclasses of this class use the possible HW API to render paths (as oppo
sed to path |
| 25 * rendering implemented in Skia on top of a "3d" HW API). | 25 * rendering implemented in Skia on top of a "3d" HW API). |
| 26 * The subclasses hold the global state needed to render paths, including shadow
of the global HW | 26 * The subclasses hold the global state needed to render paths, including shadow
of the global HW |
| 27 * API state. Similar to GrGpu. | 27 * API state. Similar to GrGpu. |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 * @param GrStrokeInfo Common stroke that the GPU will apply to every path.
Note that | 120 * @param GrStrokeInfo Common stroke that the GPU will apply to every path.
Note that |
| 121 * if the glyph outlines contain baked-in strokes from t
he font | 121 * if the glyph outlines contain baked-in strokes from t
he font |
| 122 * descriptor, the GPU stroke will be applied on top of
those | 122 * descriptor, the GPU stroke will be applied on top of
those |
| 123 * outlines. | 123 * outlines. |
| 124 * | 124 * |
| 125 * @return a new path range populated with glyphs. | 125 * @return a new path range populated with glyphs. |
| 126 */ | 126 */ |
| 127 virtual GrPathRange* createGlyphs(const SkTypeface*, const SkDescriptor*, | 127 virtual GrPathRange* createGlyphs(const SkTypeface*, const SkDescriptor*, |
| 128 const GrStrokeInfo&) = 0; | 128 const GrStrokeInfo&) = 0; |
| 129 | 129 |
| 130 virtual void stencilPath(const GrPath*, const GrStencilSettings&) = 0; | 130 /** None of these params are optional, pointers used just to avoid making co
pies. */ |
| 131 virtual void drawPath(const GrPath*, const GrStencilSettings&) = 0; | 131 struct StencilPathArgs { |
| 132 virtual void drawPaths(const GrPathRange*, const void* indices, PathIndexTyp
e, | 132 StencilPathArgs(bool useHWAA, |
| 133 const float transformValues[], PathTransformType, int
count, | 133 GrRenderTarget* renderTarget, |
| 134 const GrStencilSettings&) = 0; | 134 const SkMatrix* viewMatrix, |
| 135 const GrScissorState* scissor, |
| 136 const GrStencilSettings* stencil) |
| 137 : fUseHWAA(useHWAA) |
| 138 , fRenderTarget(renderTarget) |
| 139 , fViewMatrix(viewMatrix) |
| 140 , fScissor(scissor) |
| 141 , fStencil(stencil) { |
| 142 } |
| 143 bool fUseHWAA; |
| 144 GrRenderTarget* fRenderTarget; |
| 145 const SkMatrix* fViewMatrix; |
| 146 const GrScissorState* fScissor; |
| 147 const GrStencilSettings* fStencil; |
| 148 }; |
| 149 |
| 150 void stencilPath(const StencilPathArgs& args, const GrPath* path) { |
| 151 fGpu->handleDirtyContext(); |
| 152 this->onStencilPath(args, path); |
| 153 } |
| 154 |
| 155 struct DrawPathArgs : public GrGpu::DrawArgs { |
| 156 DrawPathArgs(const GrPrimitiveProcessor* primProc, |
| 157 const GrPipeline* pipeline, |
| 158 const GrProgramDesc* desc, |
| 159 const GrBatchTracker* batchTracker, |
| 160 const GrStencilSettings* stencil) |
| 161 : DrawArgs(primProc, pipeline, desc, batchTracker) |
| 162 , fStencil(stencil) { |
| 163 } |
| 164 |
| 165 const GrStencilSettings* fStencil; |
| 166 }; |
| 167 |
| 168 void drawPath(const DrawPathArgs& args, const GrPath* path) { |
| 169 fGpu->handleDirtyContext(); |
| 170 this->onDrawPath(args, path); |
| 171 } |
| 172 |
| 173 void drawPaths(const DrawPathArgs& args, const GrPathRange* pathRange, const
void* indices, |
| 174 PathIndexType indexType, const float transformValues[], |
| 175 PathTransformType transformType, int count) { |
| 176 fGpu->handleDirtyContext(); |
| 177 pathRange->willDrawPaths(indices, indexType, count); |
| 178 this->onDrawPaths(args, pathRange, indices, indexType, transformValues,
transformType, |
| 179 count); |
| 180 } |
| 135 protected: | 181 protected: |
| 136 GrPathRendering() { } | 182 GrPathRendering(GrGpu* gpu) |
| 183 : fGpu(gpu) { |
| 184 } |
| 185 virtual void onStencilPath(const StencilPathArgs&, const GrPath*) = 0; |
| 186 virtual void onDrawPath(const DrawPathArgs&, const GrPath*) = 0; |
| 187 virtual void onDrawPaths(const DrawPathArgs&, const GrPathRange*, const void
*, PathIndexType, |
| 188 const float[], PathTransformType, int) = 0; |
| 137 | 189 |
| 190 GrGpu* fGpu; |
| 138 private: | 191 private: |
| 139 GrPathRendering& operator=(const GrPathRendering&); | 192 GrPathRendering& operator=(const GrPathRendering&); |
| 140 }; | 193 }; |
| 141 | 194 |
| 142 #endif | 195 #endif |
| OLD | NEW |