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 "GrDrawTargetCaps.h" | 10 #include "GrDrawTargetCaps.h" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 /** | 131 /** |
132 * Move the result of the software mask generation back to the gpu | 132 * Move the result of the software mask generation back to the gpu |
133 */ | 133 */ |
134 void GrSWMaskHelper::toTexture(GrTexture *texture) { | 134 void GrSWMaskHelper::toTexture(GrTexture *texture) { |
135 SkAutoLockPixels alp(fBM); | 135 SkAutoLockPixels alp(fBM); |
136 | 136 |
137 // If we aren't reusing scratch textures we don't need to flush before | 137 // If we aren't reusing scratch textures we don't need to flush before |
138 // writing since no one else will be using 'texture' | 138 // writing since no one else will be using 'texture' |
139 bool reuseScratch = fContext->getGpu()->caps()->reuseScratchTextures(); | 139 bool reuseScratch = fContext->getGpu()->caps()->reuseScratchTextures(); |
140 | 140 |
| 141 // Since we're uploading to it, 'texture' shouldn't have a render target. |
| 142 SkASSERT(NULL == texture->asRenderTarget()); |
| 143 |
141 texture->writePixels(0, 0, fBM.width(), fBM.height(), | 144 texture->writePixels(0, 0, fBM.width(), fBM.height(), |
142 kAlpha_8_GrPixelConfig, | 145 kAlpha_8_GrPixelConfig, |
143 fBM.getPixels(), fBM.rowBytes(), | 146 fBM.getPixels(), fBM.rowBytes(), |
144 reuseScratch ? 0 : GrContext::kDontFlush_PixelOpsFlag); | 147 reuseScratch ? 0 : GrContext::kDontFlush_PixelOpsFlag); |
145 } | 148 } |
146 | 149 |
147 //////////////////////////////////////////////////////////////////////////////// | 150 //////////////////////////////////////////////////////////////////////////////// |
148 /** | 151 /** |
149 * Software rasterizes path to A8 mask (possibly using the context's matrix) | 152 * Software rasterizes path to A8 mask (possibly using the context's matrix) |
150 * and uploads the result to a scratch texture. Returns the resulting | 153 * and uploads the result to a scratch texture. Returns the resulting |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 maskMatrix.preConcat(drawState->getViewMatrix()); | 204 maskMatrix.preConcat(drawState->getViewMatrix()); |
202 | 205 |
203 drawState->addCoverageEffect( | 206 drawState->addCoverageEffect( |
204 GrSimpleTextureEffect::Create(texture, | 207 GrSimpleTextureEffect::Create(texture, |
205 maskMatrix, | 208 maskMatrix, |
206 GrTextureParams::kNone_Fi
lterMode, | 209 GrTextureParams::kNone_Fi
lterMode, |
207 kPosition_GrCoordSet))->u
nref(); | 210 kPosition_GrCoordSet))->u
nref(); |
208 | 211 |
209 target->drawSimpleRect(dstRect); | 212 target->drawSimpleRect(dstRect); |
210 } | 213 } |
OLD | NEW |