OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 #include "GrSWMaskHelper.h" | 8 #include "GrSWMaskHelper.h" |
9 #include "GrDrawState.h" | 9 #include "GrDrawState.h" |
10 #include "GrGpu.h" | 10 #include "GrGpu.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
125 | 125 |
126 texture->set(fContext, desc); | 126 texture->set(fContext, desc); |
127 return NULL != texture->texture(); | 127 return NULL != texture->texture(); |
128 } | 128 } |
129 | 129 |
130 /** | 130 /** |
131 * Move the result of the software mask generation back to the gpu | 131 * Move the result of the software mask generation back to the gpu |
132 */ | 132 */ |
133 void GrSWMaskHelper::toTexture(GrTexture *texture, uint8_t alpha) { | 133 void GrSWMaskHelper::toTexture(GrTexture *texture, uint8_t alpha) { |
134 SkAutoLockPixels alp(fBM); | 134 SkAutoLockPixels alp(fBM); |
135 | 135 |
bsalomon
2013/07/19 17:42:28
I think we want to delete from here...
| |
136 // The destination texture is almost always larger than "fBM". Clear | 136 // The destination texture is almost always larger than "fBM". Clear |
137 // it appropriately so we don't get mask artifacts outside of the path's | 137 // it appropriately so we don't get mask artifacts outside of the path's |
138 // bounding box | 138 // bounding box |
139 | 139 |
140 // "texture" needs to be installed as the render target for the clear | 140 // "texture" needs to be installed as the render target for the clear |
141 // and the texture upload but cannot remain the render target upon | 141 // and the texture upload but cannot remain the render target upon |
142 // return. Callers typically use it as a texture and it would then | 142 // return. Callers typically use it as a texture and it would then |
143 // be both source and dest. | 143 // be both source and dest. |
144 GrDrawState::AutoRenderTargetRestore artr(fContext->getGpu()->drawState(), | 144 GrDrawState::AutoRenderTargetRestore artr(fContext->getGpu()->drawState(), |
145 texture->asRenderTarget()); | 145 texture->asRenderTarget()); |
146 | 146 |
147 fContext->getGpu()->clear(NULL, GrColorPackRGBA(alpha, alpha, alpha, alpha)) ; | |
148 | |
149 texture->writePixels(0, 0, fBM.width(), fBM.height(), | 147 texture->writePixels(0, 0, fBM.width(), fBM.height(), |
bsalomon
2013/07/19 17:42:28
... up to this line.
robertphillips
2013/07/19 17:54:47
You are correct - done.
| |
150 kAlpha_8_GrPixelConfig, | 148 kAlpha_8_GrPixelConfig, |
151 fBM.getPixels(), fBM.rowBytes()); | 149 fBM.getPixels(), fBM.rowBytes()); |
152 } | 150 } |
153 | 151 |
154 //////////////////////////////////////////////////////////////////////////////// | 152 //////////////////////////////////////////////////////////////////////////////// |
155 /** | 153 /** |
156 * Software rasterizes path to A8 mask (possibly using the context's matrix) | 154 * Software rasterizes path to A8 mask (possibly using the context's matrix) |
157 * and uploads the result to a scratch texture. Returns the resulting | 155 * and uploads the result to a scratch texture. Returns the resulting |
158 * texture on success; NULL on failure. | 156 * texture on success; NULL on failure. |
159 */ | 157 */ |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
208 maskMatrix.preConcat(drawState->getViewMatrix()); | 206 maskMatrix.preConcat(drawState->getViewMatrix()); |
209 | 207 |
210 drawState->addCoverageEffect( | 208 drawState->addCoverageEffect( |
211 GrSimpleTextureEffect::Create(texture, | 209 GrSimpleTextureEffect::Create(texture, |
212 maskMatrix, | 210 maskMatrix, |
213 false, | 211 false, |
214 GrEffect::kPosition_Coord sType))->unref(); | 212 GrEffect::kPosition_Coord sType))->unref(); |
215 | 213 |
216 target->drawSimpleRect(dstRect); | 214 target->drawSimpleRect(dstRect); |
217 } | 215 } |
OLD | NEW |