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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 } else { | 92 } else { |
93 fMatrix.setIdentity(); | 93 fMatrix.setIdentity(); |
94 } | 94 } |
95 | 95 |
96 // Now translate so the bound's UL corner is at the origin | 96 // Now translate so the bound's UL corner is at the origin |
97 fMatrix.postTranslate(-resultBounds.fLeft * SK_Scalar1, | 97 fMatrix.postTranslate(-resultBounds.fLeft * SK_Scalar1, |
98 -resultBounds.fTop * SK_Scalar1); | 98 -resultBounds.fTop * SK_Scalar1); |
99 SkIRect bounds = SkIRect::MakeWH(resultBounds.width(), | 99 SkIRect bounds = SkIRect::MakeWH(resultBounds.width(), |
100 resultBounds.height()); | 100 resultBounds.height()); |
101 | 101 |
102 fBM.setConfig(SkBitmap::kA8_Config, bounds.fRight, bounds.fBottom); | 102 if (!fBM.allocPixels(SkImageInfo::MakeA8(bounds.fRight, bounds.fBottom))) { |
103 if (!fBM.allocPixels()) { | |
104 return false; | 103 return false; |
105 } | 104 } |
106 sk_bzero(fBM.getPixels(), fBM.getSafeSize()); | 105 sk_bzero(fBM.getPixels(), fBM.getSafeSize()); |
107 | 106 |
108 sk_bzero(&fDraw, sizeof(fDraw)); | 107 sk_bzero(&fDraw, sizeof(fDraw)); |
109 fRasterClip.setRect(bounds); | 108 fRasterClip.setRect(bounds); |
110 fDraw.fRC = &fRasterClip; | 109 fDraw.fRC = &fRasterClip; |
111 fDraw.fClip = &fRasterClip.bwRgn(); | 110 fDraw.fClip = &fRasterClip.bwRgn(); |
112 fDraw.fMatrix = &fMatrix; | 111 fDraw.fMatrix = &fMatrix; |
113 fDraw.fBitmap = &fBM; | 112 fDraw.fBitmap = &fBM; |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 maskMatrix.preConcat(drawState->getViewMatrix()); | 203 maskMatrix.preConcat(drawState->getViewMatrix()); |
205 | 204 |
206 drawState->addCoverageEffect( | 205 drawState->addCoverageEffect( |
207 GrSimpleTextureEffect::Create(texture, | 206 GrSimpleTextureEffect::Create(texture, |
208 maskMatrix, | 207 maskMatrix, |
209 GrTextureParams::kNone_Fi
lterMode, | 208 GrTextureParams::kNone_Fi
lterMode, |
210 kPosition_GrCoordSet))->u
nref(); | 209 kPosition_GrCoordSet))->u
nref(); |
211 | 210 |
212 target->drawSimpleRect(dstRect); | 211 target->drawSimpleRect(dstRect); |
213 } | 212 } |
OLD | NEW |