OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 GrBufferedDrawTarget_DEFINED | 8 #ifndef GrBufferedDrawTarget_DEFINED |
9 #define GrBufferedDrawTarget_DEFINED | 9 #define GrBufferedDrawTarget_DEFINED |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 /** | 24 /** |
25 * Creates a GrBufferedDrawTarget | 25 * Creates a GrBufferedDrawTarget |
26 * | 26 * |
27 * @param context the context object that owns this draw buffer. | 27 * @param context the context object that owns this draw buffer. |
28 */ | 28 */ |
29 GrBufferedDrawTarget(GrContext* context); | 29 GrBufferedDrawTarget(GrContext* context); |
30 | 30 |
31 ~GrBufferedDrawTarget() override; | 31 ~GrBufferedDrawTarget() override; |
32 | 32 |
33 void clearStencilClip(const SkIRect& rect, | |
34 bool insideClip, | |
35 GrRenderTarget* renderTarget) override; | |
36 | |
37 protected: | 33 protected: |
38 void appendIndicesAndTransforms(const void* indexValues, PathIndexType index
Type, | 34 void appendIndicesAndTransforms(const void* indexValues, PathIndexType index
Type, |
39 const float* transformValues, PathTransformT
ype transformType, | 35 const float* transformValues, PathTransformT
ype transformType, |
40 int count, char** indicesLocation, float** x
formsLocation) { | 36 int count, char** indicesLocation, float** x
formsLocation) { |
41 int indexBytes = GrPathRange::PathIndexSizeInBytes(indexType); | 37 int indexBytes = GrPathRange::PathIndexSizeInBytes(indexType); |
42 *indicesLocation = (char*) fPathIndexBuffer.alloc(count * indexBytes, | 38 *indicesLocation = (char*) fPathIndexBuffer.alloc(count * indexBytes, |
43 SkChunkAlloc::kThrow_A
llocFailType); | 39 SkChunkAlloc::kThrow_A
llocFailType); |
44 SkASSERT(SkIsAlign4((uintptr_t)*indicesLocation)); | 40 SkASSERT(SkIsAlign4((uintptr_t)*indicesLocation)); |
45 memcpy(*indicesLocation, reinterpret_cast<const char*>(indexValues), cou
nt * indexBytes); | 41 memcpy(*indicesLocation, reinterpret_cast<const char*>(indexValues), cou
nt * indexBytes); |
46 | 42 |
47 const int xformBytes = GrPathRendering::PathTransformSize(transformType)
* sizeof(float); | 43 const int xformBytes = GrPathRendering::PathTransformSize(transformType)
* sizeof(float); |
48 *xformsLocation = NULL; | 44 *xformsLocation = NULL; |
49 | 45 |
50 if (0 != xformBytes) { | 46 if (0 != xformBytes) { |
51 *xformsLocation = (float*) fPathTransformBuffer.alloc(count * xformB
ytes, | 47 *xformsLocation = (float*) fPathTransformBuffer.alloc(count * xformB
ytes, |
52 SkChunkAlloc::kTh
row_AllocFailType); | 48 SkChunkAlloc::kTh
row_AllocFailType); |
53 SkASSERT(SkIsAlign4((uintptr_t)*xformsLocation)); | 49 SkASSERT(SkIsAlign4((uintptr_t)*xformsLocation)); |
54 memcpy(*xformsLocation, transformValues, count * xformBytes); | 50 memcpy(*xformsLocation, transformValues, count * xformBytes); |
55 } | 51 } |
56 } | 52 } |
57 | 53 |
| 54 void onDrawBatch(GrBatch*) override; |
| 55 |
58 private: | 56 private: |
59 friend class GrInOrderCommandBuilder; | 57 friend class GrInOrderCommandBuilder; |
60 friend class GrTargetCommands; | 58 friend class GrTargetCommands; |
61 | 59 |
62 typedef GrTargetCommands::StateForPathDraw StateForPathDraw; | 60 typedef GrTargetCommands::StateForPathDraw StateForPathDraw; |
63 | 61 |
64 StateForPathDraw* allocState(const GrPrimitiveProcessor* primProc = NULL) { | 62 StateForPathDraw* allocState(const GrPrimitiveProcessor* primProc = NULL) { |
65 void* allocation = fPipelineBuffer.alloc(sizeof(StateForPathDraw), | 63 void* allocation = fPipelineBuffer.alloc(sizeof(StateForPathDraw), |
66 SkChunkAlloc::kThrow_AllocFailT
ype); | 64 SkChunkAlloc::kThrow_AllocFailT
ype); |
67 return SkNEW_PLACEMENT_ARGS(allocation, StateForPathDraw, (primProc)); | 65 return SkNEW_PLACEMENT_ARGS(allocation, StateForPathDraw, (primProc)); |
68 } | 66 } |
69 | 67 |
70 void unallocState(StateForPathDraw* state) { | 68 void unallocState(StateForPathDraw* state) { |
71 state->unref(); | 69 state->unref(); |
72 fPipelineBuffer.unalloc(state); | 70 fPipelineBuffer.unalloc(state); |
73 } | 71 } |
74 | 72 |
75 void onReset() override; | 73 void onReset() override; |
76 void onFlush() override; | 74 void onFlush() override; |
77 | 75 |
78 // overrides from GrDrawTarget | |
79 void onDrawBatch(GrBatch*) override; | |
80 void onStencilPath(const GrPipelineBuilder&, | 76 void onStencilPath(const GrPipelineBuilder&, |
81 const GrPathProcessor*, | 77 const GrPathProcessor*, |
82 const GrPath*, | 78 const GrPath*, |
83 const GrScissorState&, | 79 const GrScissorState&, |
84 const GrStencilSettings&) override; | 80 const GrStencilSettings&) override; |
85 void onDrawPath(const GrPathProcessor*, | 81 void onDrawPath(const GrPathProcessor*, |
86 const GrPath*, | 82 const GrPath*, |
87 const GrStencilSettings&, | 83 const GrStencilSettings&, |
88 const PipelineInfo&) override; | 84 const PipelineInfo&) override; |
89 void onDrawPaths(const GrPathProcessor*, | 85 void onDrawPaths(const GrPathProcessor*, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 SkChunkAlloc fPathIndexBuffer; | 118 SkChunkAlloc fPathIndexBuffer; |
123 SkChunkAlloc fPathTransformBuffer; | 119 SkChunkAlloc fPathTransformBuffer; |
124 SkChunkAlloc fPipelineBuffer; | 120 SkChunkAlloc fPipelineBuffer; |
125 uint32_t fDrawID; | 121 uint32_t fDrawID; |
126 SkAutoTUnref<StateForPathDraw> fPrevState; | 122 SkAutoTUnref<StateForPathDraw> fPrevState; |
127 | 123 |
128 typedef GrClipTarget INHERITED; | 124 typedef GrClipTarget INHERITED; |
129 }; | 125 }; |
130 | 126 |
131 #endif | 127 #endif |
OLD | NEW |