| 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,
SkScalar outerThreshold); | 16 SkAlphaThresholdFilterImpl(const SkRegion& region, SkScalar innerThreshold,
SkScalar outerThreshold); |
| 17 | 17 |
| 18 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkAlphaThresholdFilterIm
pl) | 18 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkAlphaThresholdFilterIm
pl) |
| 19 | 19 |
| 20 protected: | 20 protected: |
| 21 explicit SkAlphaThresholdFilterImpl(SkReadBuffer& buffer); | 21 explicit SkAlphaThresholdFilterImpl(SkReadBuffer& buffer); |
| 22 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; | 22 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
| 23 | 23 |
| 24 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, | 24 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, |
| 25 SkBitmap* result, SkIPoint* offset) const SK_OVER
RIDE; | 25 SkBitmap* result, SkIPoint* offset) const SK_OVER
RIDE; |
| 26 #if SK_SUPPORT_GPU | 26 #if SK_SUPPORT_GPU |
| 27 virtual bool asNewEffect(GrEffect** effect, GrTexture* texture, | 27 virtual bool asNewEffect(GrEffectRef** effect, GrTexture* texture, |
| 28 const SkMatrix& matrix, const SkIRect& bounds) cons
t SK_OVERRIDE; | 28 const SkMatrix& matrix, const SkIRect& bounds) cons
t SK_OVERRIDE; |
| 29 #endif | 29 #endif |
| 30 | 30 |
| 31 private: | 31 private: |
| 32 SkRegion fRegion; | 32 SkRegion fRegion; |
| 33 SkScalar fInnerThreshold; | 33 SkScalar fInnerThreshold; |
| 34 SkScalar fOuterThreshold; | 34 SkScalar fOuterThreshold; |
| 35 typedef SkImageFilter INHERITED; | 35 typedef SkImageFilter INHERITED; |
| 36 }; | 36 }; |
| 37 | 37 |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 SkAlphaThresholdFilterImpl::SkAlphaThresholdFilterImpl(const SkRegion& region, | 241 SkAlphaThresholdFilterImpl::SkAlphaThresholdFilterImpl(const SkRegion& region, |
| 242 SkScalar innerThreshold, | 242 SkScalar innerThreshold, |
| 243 SkScalar outerThreshold) | 243 SkScalar outerThreshold) |
| 244 : INHERITED(0) | 244 : INHERITED(0) |
| 245 , fRegion(region) | 245 , fRegion(region) |
| 246 , fInnerThreshold(innerThreshold) | 246 , fInnerThreshold(innerThreshold) |
| 247 , fOuterThreshold(outerThreshold) { | 247 , fOuterThreshold(outerThreshold) { |
| 248 } | 248 } |
| 249 | 249 |
| 250 #if SK_SUPPORT_GPU | 250 #if SK_SUPPORT_GPU |
| 251 bool SkAlphaThresholdFilterImpl::asNewEffect(GrEffect** effect, GrTexture* textu
re, | 251 bool SkAlphaThresholdFilterImpl::asNewEffect(GrEffectRef** effect, GrTexture* te
xture, |
| 252 const SkMatrix& in_matrix, const Sk
IRect&) const { | 252 const SkMatrix& in_matrix, const Sk
IRect&) const { |
| 253 if (effect) { | 253 if (effect) { |
| 254 GrContext* context = texture->getContext(); | 254 GrContext* context = texture->getContext(); |
| 255 GrTextureDesc maskDesc; | 255 GrTextureDesc maskDesc; |
| 256 if (context->isConfigRenderable(kAlpha_8_GrPixelConfig, false)) { | 256 if (context->isConfigRenderable(kAlpha_8_GrPixelConfig, false)) { |
| 257 maskDesc.fConfig = kAlpha_8_GrPixelConfig; | 257 maskDesc.fConfig = kAlpha_8_GrPixelConfig; |
| 258 } else { | 258 } else { |
| 259 maskDesc.fConfig = kRGBA_8888_GrPixelConfig; | 259 maskDesc.fConfig = kRGBA_8888_GrPixelConfig; |
| 260 } | 260 } |
| 261 maskDesc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureF
lagBit; | 261 maskDesc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureF
lagBit; |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 (U8CPU)(SkColorGetG(source) *
scale), | 357 (U8CPU)(SkColorGetG(source) *
scale), |
| 358 (U8CPU)(SkColorGetB(source) *
scale)); | 358 (U8CPU)(SkColorGetB(source) *
scale)); |
| 359 } | 359 } |
| 360 } | 360 } |
| 361 dptr[y * dst->width() + x] = output_color; | 361 dptr[y * dst->width() + x] = output_color; |
| 362 } | 362 } |
| 363 } | 363 } |
| 364 | 364 |
| 365 return true; | 365 return true; |
| 366 } | 366 } |
| OLD | NEW |