| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 The Android Open Source Project | 2 * Copyright 2012 The Android Open Source Project |
| 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 "SkLightingImageFilter.h" | 8 #include "SkLightingImageFilter.h" |
| 9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
| 10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 public: | 265 public: |
| 266 SkDiffuseLightingImageFilter(SkLight* light, SkScalar surfaceScale, | 266 SkDiffuseLightingImageFilter(SkLight* light, SkScalar surfaceScale, |
| 267 SkScalar kd, SkImageFilter* input, const CropRe
ct* cropRect); | 267 SkScalar kd, SkImageFilter* input, const CropRe
ct* cropRect); |
| 268 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDiffuseLightingImageFi
lter) | 268 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDiffuseLightingImageFi
lter) |
| 269 SkScalar kd() const { return fKD; } | 269 SkScalar kd() const { return fKD; } |
| 270 | 270 |
| 271 protected: | 271 protected: |
| 272 explicit SkDiffuseLightingImageFilter(SkReadBuffer& buffer); | 272 explicit SkDiffuseLightingImageFilter(SkReadBuffer& buffer); |
| 273 virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE; | 273 virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE; |
| 274 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&, | 274 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&, |
| 275 SkBitmap* result, SkIPoint* offset) SK_OVERRIDE; | 275 SkBitmap* result, SkIPoint* offset) const SK_OVER
RIDE; |
| 276 #if SK_SUPPORT_GPU | 276 #if SK_SUPPORT_GPU |
| 277 virtual bool asNewEffect(GrEffectRef** effect, GrTexture*, const SkMatrix& m
atrix, const SkIRect& bounds) const SK_OVERRIDE; | 277 virtual bool asNewEffect(GrEffectRef** effect, GrTexture*, const SkMatrix& m
atrix, const SkIRect& bounds) const SK_OVERRIDE; |
| 278 #endif | 278 #endif |
| 279 | 279 |
| 280 private: | 280 private: |
| 281 typedef SkLightingImageFilter INHERITED; | 281 typedef SkLightingImageFilter INHERITED; |
| 282 SkScalar fKD; | 282 SkScalar fKD; |
| 283 }; | 283 }; |
| 284 | 284 |
| 285 class SkSpecularLightingImageFilter : public SkLightingImageFilter { | 285 class SkSpecularLightingImageFilter : public SkLightingImageFilter { |
| 286 public: | 286 public: |
| 287 SkSpecularLightingImageFilter(SkLight* light, SkScalar surfaceScale, SkScala
r ks, SkScalar shininess, SkImageFilter* input, const CropRect* cropRect); | 287 SkSpecularLightingImageFilter(SkLight* light, SkScalar surfaceScale, SkScala
r ks, SkScalar shininess, SkImageFilter* input, const CropRect* cropRect); |
| 288 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSpecularLightingImageF
ilter) | 288 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSpecularLightingImageF
ilter) |
| 289 | 289 |
| 290 SkScalar ks() const { return fKS; } | 290 SkScalar ks() const { return fKS; } |
| 291 SkScalar shininess() const { return fShininess; } | 291 SkScalar shininess() const { return fShininess; } |
| 292 | 292 |
| 293 protected: | 293 protected: |
| 294 explicit SkSpecularLightingImageFilter(SkReadBuffer& buffer); | 294 explicit SkSpecularLightingImageFilter(SkReadBuffer& buffer); |
| 295 virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE; | 295 virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE; |
| 296 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&, | 296 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&, |
| 297 SkBitmap* result, SkIPoint* offset) SK_OVERRIDE; | 297 SkBitmap* result, SkIPoint* offset) const SK_OVER
RIDE; |
| 298 #if SK_SUPPORT_GPU | 298 #if SK_SUPPORT_GPU |
| 299 virtual bool asNewEffect(GrEffectRef** effect, GrTexture*, const SkMatrix& m
atrix, const SkIRect& bounds) const SK_OVERRIDE; | 299 virtual bool asNewEffect(GrEffectRef** effect, GrTexture*, const SkMatrix& m
atrix, const SkIRect& bounds) const SK_OVERRIDE; |
| 300 #endif | 300 #endif |
| 301 | 301 |
| 302 private: | 302 private: |
| 303 typedef SkLightingImageFilter INHERITED; | 303 typedef SkLightingImageFilter INHERITED; |
| 304 SkScalar fKS; | 304 SkScalar fKS; |
| 305 SkScalar fShininess; | 305 SkScalar fShininess; |
| 306 }; | 306 }; |
| 307 | 307 |
| (...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 918 | 918 |
| 919 void SkDiffuseLightingImageFilter::flatten(SkWriteBuffer& buffer) const { | 919 void SkDiffuseLightingImageFilter::flatten(SkWriteBuffer& buffer) const { |
| 920 this->INHERITED::flatten(buffer); | 920 this->INHERITED::flatten(buffer); |
| 921 buffer.writeScalar(fKD); | 921 buffer.writeScalar(fKD); |
| 922 } | 922 } |
| 923 | 923 |
| 924 bool SkDiffuseLightingImageFilter::onFilterImage(Proxy* proxy, | 924 bool SkDiffuseLightingImageFilter::onFilterImage(Proxy* proxy, |
| 925 const SkBitmap& source, | 925 const SkBitmap& source, |
| 926 const SkMatrix& ctm, | 926 const SkMatrix& ctm, |
| 927 SkBitmap* dst, | 927 SkBitmap* dst, |
| 928 SkIPoint* offset) { | 928 SkIPoint* offset) const { |
| 929 SkImageFilter* input = getInput(0); | 929 SkImageFilter* input = getInput(0); |
| 930 SkBitmap src = source; | 930 SkBitmap src = source; |
| 931 SkIPoint srcOffset = SkIPoint::Make(0, 0); | 931 SkIPoint srcOffset = SkIPoint::Make(0, 0); |
| 932 if (input && !input->filterImage(proxy, source, ctm, &src, &srcOffset)) { | 932 if (input && !input->filterImage(proxy, source, ctm, &src, &srcOffset)) { |
| 933 return false; | 933 return false; |
| 934 } | 934 } |
| 935 | 935 |
| 936 if (src.config() != SkBitmap::kARGB_8888_Config) { | 936 if (src.config() != SkBitmap::kARGB_8888_Config) { |
| 937 return false; | 937 return false; |
| 938 } | 938 } |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1011 void SkSpecularLightingImageFilter::flatten(SkWriteBuffer& buffer) const { | 1011 void SkSpecularLightingImageFilter::flatten(SkWriteBuffer& buffer) const { |
| 1012 this->INHERITED::flatten(buffer); | 1012 this->INHERITED::flatten(buffer); |
| 1013 buffer.writeScalar(fKS); | 1013 buffer.writeScalar(fKS); |
| 1014 buffer.writeScalar(fShininess); | 1014 buffer.writeScalar(fShininess); |
| 1015 } | 1015 } |
| 1016 | 1016 |
| 1017 bool SkSpecularLightingImageFilter::onFilterImage(Proxy* proxy, | 1017 bool SkSpecularLightingImageFilter::onFilterImage(Proxy* proxy, |
| 1018 const SkBitmap& source, | 1018 const SkBitmap& source, |
| 1019 const SkMatrix& ctm, | 1019 const SkMatrix& ctm, |
| 1020 SkBitmap* dst, | 1020 SkBitmap* dst, |
| 1021 SkIPoint* offset) { | 1021 SkIPoint* offset) const { |
| 1022 SkImageFilter* input = getInput(0); | 1022 SkImageFilter* input = getInput(0); |
| 1023 SkBitmap src = source; | 1023 SkBitmap src = source; |
| 1024 SkIPoint srcOffset = SkIPoint::Make(0, 0); | 1024 SkIPoint srcOffset = SkIPoint::Make(0, 0); |
| 1025 if (input && !input->filterImage(proxy, source, ctm, &src, &srcOffset)) { | 1025 if (input && !input->filterImage(proxy, source, ctm, &src, &srcOffset)) { |
| 1026 return false; | 1026 return false; |
| 1027 } | 1027 } |
| 1028 | 1028 |
| 1029 if (src.config() != SkBitmap::kARGB_8888_Config) { | 1029 if (src.config() != SkBitmap::kARGB_8888_Config) { |
| 1030 return false; | 1030 return false; |
| 1031 } | 1031 } |
| (...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1608 | 1608 |
| 1609 builder->fsCodeAppendf("%s(%s)", fLightColorFunc.c_str(), surfaceToLight); | 1609 builder->fsCodeAppendf("%s(%s)", fLightColorFunc.c_str(), surfaceToLight); |
| 1610 } | 1610 } |
| 1611 | 1611 |
| 1612 #endif | 1612 #endif |
| 1613 | 1613 |
| 1614 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingImageFilter) | 1614 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingImageFilter) |
| 1615 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiffuseLightingImageFilter) | 1615 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiffuseLightingImageFilter) |
| 1616 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpecularLightingImageFilter) | 1616 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpecularLightingImageFilter) |
| 1617 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 1617 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
| OLD | NEW |