Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(496)

Side by Side Diff: src/effects/SkLayerDrawLooper.cpp

Issue 253633003: add asAShadowBlur for android to drawlooper (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: add unittests (and fix bugs in layerdrawlooper) Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/effects/SkEmbossMaskFilter.cpp ('k') | tests/BlurTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 // bottom layer needs to be just blur(maskfilter)
163 if ((rec->fInfo.fPaintBits & ~kMaskFilter_Bit)) {
164 return false;
165 }
166 if (SkXfermode::kSrc_Mode != rec->fInfo.fColorMode) {
167 return false;
168 }
169 const SkMaskFilter* mf = rec->fPaint.getMaskFilter();
170 if (NULL == mf) {
171 return false;
172 }
173 SkMaskFilter::BlurRec maskBlur;
174 if (!mf->asABlur(&maskBlur)) {
175 return false;
176 }
177
178 rec = rec->fNext;
179 // top layer needs to be "plain"
180 if (rec->fInfo.fPaintBits) {
181 return false;
182 }
183 if (SkXfermode::kDst_Mode != rec->fInfo.fColorMode) {
184 return false;
185 }
186 if (!rec->fInfo.fOffset.equals(0, 0)) {
187 return false;
188 }
189
190 if (bsRec) {
191 bsRec->fSigma = maskBlur.fSigma;
192 bsRec->fOffset = fRecs->fInfo.fOffset;
193 bsRec->fColor = fRecs->fPaint.getColor();
194 bsRec->fStyle = maskBlur.fStyle;
195 bsRec->fQuality = maskBlur.fQuality;
196 }
197 return true;
198 }
199
156 /////////////////////////////////////////////////////////////////////////////// 200 ///////////////////////////////////////////////////////////////////////////////
157 201
158 void SkLayerDrawLooper::flatten(SkWriteBuffer& buffer) const { 202 void SkLayerDrawLooper::flatten(SkWriteBuffer& buffer) const {
159 this->INHERITED::flatten(buffer); 203 this->INHERITED::flatten(buffer);
160 204
161 #ifdef SK_DEBUG 205 #ifdef SK_DEBUG
162 { 206 {
163 Rec* rec = fRecs; 207 Rec* rec = fRecs;
164 int count = 0; 208 int count = 0;
165 while (rec) { 209 while (rec) {
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 SkLayerDrawLooper* looper = SkNEW(SkLayerDrawLooper); 378 SkLayerDrawLooper* looper = SkNEW(SkLayerDrawLooper);
335 looper->fCount = fCount; 379 looper->fCount = fCount;
336 looper->fRecs = fRecs; 380 looper->fRecs = fRecs;
337 381
338 fCount = 0; 382 fCount = 0;
339 fRecs = NULL; 383 fRecs = NULL;
340 fTopRec = NULL; 384 fTopRec = NULL;
341 385
342 return looper; 386 return looper;
343 } 387 }
OLDNEW
« no previous file with comments | « src/effects/SkEmbossMaskFilter.cpp ('k') | tests/BlurTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698