OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "SkCanvas.h" | 8 #include "SkCanvas.h" |
9 #include "SkColor.h" | 9 #include "SkColor.h" |
10 #include "SkReadBuffer.h" | 10 #include "SkReadBuffer.h" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 fCurrRec->fInfo.fOffset.fY); | 146 fCurrRec->fInfo.fOffset.fY); |
147 } else { | 147 } else { |
148 canvas->translate(fCurrRec->fInfo.fOffset.fX, | 148 canvas->translate(fCurrRec->fInfo.fOffset.fX, |
149 fCurrRec->fInfo.fOffset.fY); | 149 fCurrRec->fInfo.fOffset.fY); |
150 } | 150 } |
151 fCurrRec = fCurrRec->fNext; | 151 fCurrRec = fCurrRec->fNext; |
152 | 152 |
153 return true; | 153 return true; |
154 } | 154 } |
155 | 155 |
| 156 bool SkLayerDrawLooper::asABlurShadow(BlurShadowRec* bsRec) const { |
| 157 if (fCount != 2) { |
| 158 return false; |
| 159 } |
| 160 const Rec* rec = fRecs; |
| 161 |
| 162 // 2nd layer needs to be "plain" |
| 163 if (rec[1].fInfo.fPaintBits) { |
| 164 return false; |
| 165 } |
| 166 if (SkXfermode::kDst_Mode != rec[1].fInfo.fColorMode) { |
| 167 return false; |
| 168 } |
| 169 if (0 != rec[1].fInfo.fOffset.x() || 0 != rec[1].fInfo.fOffset.y()) { |
| 170 return false; |
| 171 } |
| 172 |
| 173 // 1st layer needs to be just blur(maskfilter) |
| 174 if ((rec[0].fInfo.fPaintBits & ~kMaskFilter_Bit)) { |
| 175 return false; |
| 176 } |
| 177 if (SkXfermode::kSrc_Mode != rec[0].fInfo.fColorMode) { |
| 178 return false; |
| 179 } |
| 180 const SkMaskFilter* mf = rec[0].fPaint.getMaskFilter(); |
| 181 if (NULL == mf) { |
| 182 return false; |
| 183 } |
| 184 SkMaskFilter::BlurRec maskBlur; |
| 185 if (!mf->asABlur(&maskBlur)) { |
| 186 return false; |
| 187 } |
| 188 |
| 189 if (bsRec) { |
| 190 bsRec->fSigma = maskBlur.fSigma; |
| 191 bsRec->fOffset = rec[0].fInfo.fOffset; |
| 192 bsRec->fColor = rec[0].fPaint.getColor(); |
| 193 bsRec->fStyle = maskBlur.fStyle; |
| 194 bsRec->fQuality = maskBlur.fQuality; |
| 195 } |
| 196 return true; |
| 197 } |
| 198 |
156 /////////////////////////////////////////////////////////////////////////////// | 199 /////////////////////////////////////////////////////////////////////////////// |
157 | 200 |
158 void SkLayerDrawLooper::flatten(SkWriteBuffer& buffer) const { | 201 void SkLayerDrawLooper::flatten(SkWriteBuffer& buffer) const { |
159 this->INHERITED::flatten(buffer); | 202 this->INHERITED::flatten(buffer); |
160 | 203 |
161 #ifdef SK_DEBUG | 204 #ifdef SK_DEBUG |
162 { | 205 { |
163 Rec* rec = fRecs; | 206 Rec* rec = fRecs; |
164 int count = 0; | 207 int count = 0; |
165 while (rec) { | 208 while (rec) { |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 SkLayerDrawLooper* looper = SkNEW(SkLayerDrawLooper); | 377 SkLayerDrawLooper* looper = SkNEW(SkLayerDrawLooper); |
335 looper->fCount = fCount; | 378 looper->fCount = fCount; |
336 looper->fRecs = fRecs; | 379 looper->fRecs = fRecs; |
337 | 380 |
338 fCount = 0; | 381 fCount = 0; |
339 fRecs = NULL; | 382 fRecs = NULL; |
340 fTopRec = NULL; | 383 fTopRec = NULL; |
341 | 384 |
342 return looper; | 385 return looper; |
343 } | 386 } |
OLD | NEW |