| 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 "GrGpu.h" | 11 #include "GrGpu.h" |
| 11 | 12 |
| 12 #include "SkStrokeRec.h" | 13 #include "SkStrokeRec.h" |
| 13 | 14 |
| 14 // TODO: try to remove this #include | 15 // TODO: try to remove this #include |
| 15 #include "GrContext.h" | 16 #include "GrContext.h" |
| 16 | 17 |
| 17 namespace { | 18 namespace { |
| 18 /* | 19 /* |
| 19 * Convert a boolean operation into a transfer mode code | 20 * Convert a boolean operation into a transfer mode code |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 texture->set(fContext, desc); | 127 texture->set(fContext, desc); |
| 127 return NULL != texture->texture(); | 128 return NULL != texture->texture(); |
| 128 } | 129 } |
| 129 | 130 |
| 130 /** | 131 /** |
| 131 * 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 |
| 132 */ | 133 */ |
| 133 void GrSWMaskHelper::toTexture(GrTexture *texture) { | 134 void GrSWMaskHelper::toTexture(GrTexture *texture) { |
| 134 SkAutoLockPixels alp(fBM); | 135 SkAutoLockPixels alp(fBM); |
| 135 | 136 |
| 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' |
| 139 bool reuseScratch = fContext->getGpu()->caps()->reuseScratchTextures(); |
| 140 |
| 136 texture->writePixels(0, 0, fBM.width(), fBM.height(), | 141 texture->writePixels(0, 0, fBM.width(), fBM.height(), |
| 137 kAlpha_8_GrPixelConfig, | 142 kAlpha_8_GrPixelConfig, |
| 138 fBM.getPixels(), fBM.rowBytes()); | 143 fBM.getPixels(), fBM.rowBytes(), |
| 144 reuseScratch ? 0 : GrContext::kDontFlush_PixelOpsFlag); |
| 139 } | 145 } |
| 140 | 146 |
| 141 //////////////////////////////////////////////////////////////////////////////// | 147 //////////////////////////////////////////////////////////////////////////////// |
| 142 /** | 148 /** |
| 143 * Software rasterizes path to A8 mask (possibly using the context's matrix) | 149 * Software rasterizes path to A8 mask (possibly using the context's matrix) |
| 144 * and uploads the result to a scratch texture. Returns the resulting | 150 * and uploads the result to a scratch texture. Returns the resulting |
| 145 * texture on success; NULL on failure. | 151 * texture on success; NULL on failure. |
| 146 */ | 152 */ |
| 147 GrTexture* GrSWMaskHelper::DrawPathMaskToTexture(GrContext* context, | 153 GrTexture* GrSWMaskHelper::DrawPathMaskToTexture(GrContext* context, |
| 148 const SkPath& path, | 154 const SkPath& path, |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 maskMatrix.preConcat(drawState->getViewMatrix()); | 201 maskMatrix.preConcat(drawState->getViewMatrix()); |
| 196 | 202 |
| 197 drawState->addCoverageEffect( | 203 drawState->addCoverageEffect( |
| 198 GrSimpleTextureEffect::Create(texture, | 204 GrSimpleTextureEffect::Create(texture, |
| 199 maskMatrix, | 205 maskMatrix, |
| 200 GrTextureParams::kNone_Fi
lterMode, | 206 GrTextureParams::kNone_Fi
lterMode, |
| 201 GrEffect::kPosition_Coord
sType))->unref(); | 207 GrEffect::kPosition_Coord
sType))->unref(); |
| 202 | 208 |
| 203 target->drawSimpleRect(dstRect); | 209 target->drawSimpleRect(dstRect); |
| 204 } | 210 } |
| OLD | NEW |