| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkAlphaThresholdFilter.h" | 8 #include "SkAlphaThresholdFilter.h" |
| 9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
| 10 #include "SkReadBuffer.h" | 10 #include "SkReadBuffer.h" |
| 11 #include "SkWriteBuffer.h" | 11 #include "SkWriteBuffer.h" |
| 12 #include "SkRegion.h" | 12 #include "SkRegion.h" |
| 13 | 13 |
| 14 class SK_API SkAlphaThresholdFilterImpl : public SkImageFilter { | 14 class SK_API SkAlphaThresholdFilterImpl : public SkImageFilter { |
| 15 public: | 15 public: |
| 16 SkAlphaThresholdFilterImpl(const SkRegion& region, SkScalar innerThreshold, | 16 SkAlphaThresholdFilterImpl(const SkRegion& region, SkScalar innerThreshold, |
| 17 SkScalar outerThreshold, SkImageFilter* input); | 17 SkScalar outerThreshold, SkImageFilter* input); |
| 18 | 18 |
| 19 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkAlphaThresholdFilterIm
pl) | 19 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkAlphaThresholdFilterIm
pl) |
| 20 | 20 |
| 21 protected: | 21 protected: |
| 22 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING |
| 22 explicit SkAlphaThresholdFilterImpl(SkReadBuffer& buffer); | 23 explicit SkAlphaThresholdFilterImpl(SkReadBuffer& buffer); |
| 24 #endif |
| 23 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; | 25 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
| 24 | 26 |
| 25 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, | 27 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, |
| 26 SkBitmap* result, SkIPoint* offset) const SK_OVER
RIDE; | 28 SkBitmap* result, SkIPoint* offset) const SK_OVER
RIDE; |
| 27 #if SK_SUPPORT_GPU | 29 #if SK_SUPPORT_GPU |
| 28 virtual bool asNewEffect(GrEffect** effect, GrTexture* texture, | 30 virtual bool asNewEffect(GrEffect** effect, GrTexture* texture, |
| 29 const SkMatrix& matrix, const SkIRect& bounds) cons
t SK_OVERRIDE; | 31 const SkMatrix& matrix, const SkIRect& bounds) cons
t SK_OVERRIDE; |
| 30 #endif | 32 #endif |
| 31 | 33 |
| 32 private: | 34 private: |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 if ((*validFlags & kA_GrColorComponentFlag) && 0xFF == GrColorUnpackA(*color
) && | 228 if ((*validFlags & kA_GrColorComponentFlag) && 0xFF == GrColorUnpackA(*color
) && |
| 227 GrPixelConfigIsOpaque(this->texture(0)->config())) { | 229 GrPixelConfigIsOpaque(this->texture(0)->config())) { |
| 228 *validFlags = kA_GrColorComponentFlag; | 230 *validFlags = kA_GrColorComponentFlag; |
| 229 } else { | 231 } else { |
| 230 *validFlags = 0; | 232 *validFlags = 0; |
| 231 } | 233 } |
| 232 } | 234 } |
| 233 | 235 |
| 234 #endif | 236 #endif |
| 235 | 237 |
| 238 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING |
| 236 SkAlphaThresholdFilterImpl::SkAlphaThresholdFilterImpl(SkReadBuffer& buffer) | 239 SkAlphaThresholdFilterImpl::SkAlphaThresholdFilterImpl(SkReadBuffer& buffer) |
| 237 : INHERITED(1, buffer) { | 240 : INHERITED(1, buffer) { |
| 238 fInnerThreshold = buffer.readScalar(); | 241 fInnerThreshold = buffer.readScalar(); |
| 239 fOuterThreshold = buffer.readScalar(); | 242 fOuterThreshold = buffer.readScalar(); |
| 240 buffer.readRegion(&fRegion); | 243 buffer.readRegion(&fRegion); |
| 241 } | 244 } |
| 245 #endif |
| 246 |
| 247 SkFlattenable* SkAlphaThresholdFilterImpl::CreateProc(SkReadBuffer& buffer) { |
| 248 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); |
| 249 SkScalar inner = buffer.readScalar(); |
| 250 SkScalar outer = buffer.readScalar(); |
| 251 SkRegion rgn; |
| 252 buffer.readRegion(&rgn); |
| 253 return SkAlphaThresholdFilter::Create(rgn, inner, outer, common.getInput(0))
; |
| 254 } |
| 242 | 255 |
| 243 SkAlphaThresholdFilterImpl::SkAlphaThresholdFilterImpl(const SkRegion& region, | 256 SkAlphaThresholdFilterImpl::SkAlphaThresholdFilterImpl(const SkRegion& region, |
| 244 SkScalar innerThreshold, | 257 SkScalar innerThreshold, |
| 245 SkScalar outerThreshold, | 258 SkScalar outerThreshold, |
| 246 SkImageFilter* input) | 259 SkImageFilter* input) |
| 247 : INHERITED(1, &input) | 260 : INHERITED(1, &input) |
| 248 , fRegion(region) | 261 , fRegion(region) |
| 249 , fInnerThreshold(innerThreshold) | 262 , fInnerThreshold(innerThreshold) |
| 250 , fOuterThreshold(outerThreshold) { | 263 , fOuterThreshold(outerThreshold) { |
| 251 } | 264 } |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 (U8CPU)(SkColorGetG(source) *
scale), | 373 (U8CPU)(SkColorGetG(source) *
scale), |
| 361 (U8CPU)(SkColorGetB(source) *
scale)); | 374 (U8CPU)(SkColorGetB(source) *
scale)); |
| 362 } | 375 } |
| 363 } | 376 } |
| 364 dptr[y * dst->width() + x] = output_color; | 377 dptr[y * dst->width() + x] = output_color; |
| 365 } | 378 } |
| 366 } | 379 } |
| 367 | 380 |
| 368 return true; | 381 return true; |
| 369 } | 382 } |
| OLD | NEW |