| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 SkRasterPipeline_DEFINED | 8 #ifndef SkRasterPipeline_DEFINED |
| 9 #define SkRasterPipeline_DEFINED | 9 #define SkRasterPipeline_DEFINED |
| 10 | 10 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 | 65 |
| 66 // It makes next() a good bit cheaper if we hold the next function to ca
ll here, | 66 // It makes next() a good bit cheaper if we hold the next function to ca
ll here, |
| 67 // rather than logically simpler choice of the function implementing thi
s stage. | 67 // rather than logically simpler choice of the function implementing thi
s stage. |
| 68 Fn fNext; | 68 Fn fNext; |
| 69 void* fCtx; | 69 void* fCtx; |
| 70 }; | 70 }; |
| 71 | 71 |
| 72 | 72 |
| 73 SkRasterPipeline(); | 73 SkRasterPipeline(); |
| 74 | 74 |
| 75 // Run the pipeline constructed with append(), walking x through [x,x+n), | 75 // Run the pipeline constructed with append(), walking x through [0,n), |
| 76 // generally in 4 pixel steps, but sometimes 1 pixel at a time. | 76 // generally in 4 pixel steps, but sometimes 1 pixel at a time. |
| 77 void run(size_t x, size_t n); | 77 void run(size_t n); |
| 78 void run(size_t n) { this->run(0, n); } | |
| 79 | 78 |
| 80 // Use this append() if your stage is sensitive to the number of pixels you'
re working with: | 79 // Use this append() if your stage is sensitive to the number of pixels you'
re working with: |
| 81 // - body will always be called for a full 4 pixels | 80 // - body will always be called for a full 4 pixels |
| 82 // - tail will always be called for a single pixel | 81 // - tail will always be called for a single pixel |
| 83 // Typically this is only an essential distintion for stages that read or wr
ite memory. | 82 // Typically this is only an essential distintion for stages that read or wr
ite memory. |
| 84 void append(Fn body, const void* body_ctx, | 83 void append(Fn body, const void* body_ctx, |
| 85 Fn tail, const void* tail_ctx); | 84 Fn tail, const void* tail_ctx); |
| 86 | 85 |
| 87 // Most stages don't actually care if they're working on 4 or 1 pixel. | 86 // Most stages don't actually care if they're working on 4 or 1 pixel. |
| 88 void append(Fn fn, const void* ctx = nullptr) { | 87 void append(Fn fn, const void* ctx = nullptr) { |
| 89 this->append(fn, ctx, fn, ctx); | 88 this->append(fn, ctx, fn, ctx); |
| 90 } | 89 } |
| 91 | 90 |
| 92 // Most 4 pixel or 1 pixel variants share the same context pointer. | 91 // Most 4 pixel or 1 pixel variants share the same context pointer. |
| 93 void append(Fn body, Fn tail, const void* ctx = nullptr) { | 92 void append(Fn body, Fn tail, const void* ctx = nullptr) { |
| 94 this->append(body, ctx, tail, ctx); | 93 this->append(body, ctx, tail, ctx); |
| 95 } | 94 } |
| 96 | 95 |
| 97 // Append all stages to this pipeline. | |
| 98 void extend(const SkRasterPipeline&); | |
| 99 | |
| 100 private: | 96 private: |
| 101 using Stages = SkSTArray<10, Stage, /*MEM_COPY=*/true>; | 97 using Stages = SkSTArray<10, Stage, /*MEM_COPY=*/true>; |
| 102 | 98 |
| 103 // This no-op default makes fBodyStart and fTailStart unconditionally safe t
o call, | 99 // This no-op default makes fBodyStart and fTailStart unconditionally safe t
o call, |
| 104 // and is always the last stage's fNext as a sort of safety net to make sure
even a | 100 // and is always the last stage's fNext as a sort of safety net to make sure
even a |
| 105 // buggy pipeline can't walk off its own end. | 101 // buggy pipeline can't walk off its own end. |
| 106 static void SK_VECTORCALL JustReturn(Stage*, size_t, Sk4f,Sk4f,Sk4f,Sk4f, | 102 static void SK_VECTORCALL JustReturn(Stage*, size_t, Sk4f,Sk4f,Sk4f,Sk4f, |
| 107 Sk4f,Sk4f,Sk4f,Sk4f); | 103 Sk4f,Sk4f,Sk4f,Sk4f); |
| 108 | 104 |
| 109 Stages fBody, | 105 Stages fBody, |
| 110 fTail; | 106 fTail; |
| 111 Fn fBodyStart = &JustReturn, | 107 Fn fBodyStart = &JustReturn, |
| 112 fTailStart = &JustReturn; | 108 fTailStart = &JustReturn; |
| 113 }; | 109 }; |
| 114 | 110 |
| 115 #endif//SkRasterPipeline_DEFINED | 111 #endif//SkRasterPipeline_DEFINED |
| OLD | NEW |