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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 buffer.writeScalar(point.fX); | 255 buffer.writeScalar(point.fX); |
256 buffer.writeScalar(point.fY); | 256 buffer.writeScalar(point.fY); |
257 buffer.writeScalar(point.fZ); | 257 buffer.writeScalar(point.fZ); |
258 }; | 258 }; |
259 | 259 |
260 class SkDiffuseLightingImageFilter : public SkLightingImageFilter { | 260 class SkDiffuseLightingImageFilter : public SkLightingImageFilter { |
261 public: | 261 public: |
262 SkDiffuseLightingImageFilter(SkLight* light, SkScalar surfaceScale, | 262 SkDiffuseLightingImageFilter(SkLight* light, SkScalar surfaceScale, |
263 SkScalar kd, SkImageFilter* input, const CropRe
ct* cropRect); | 263 SkScalar kd, SkImageFilter* input, const CropRe
ct* cropRect); |
264 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDiffuseLightingImageFi
lter) | 264 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDiffuseLightingImageFi
lter) |
265 | |
266 #if SK_SUPPORT_GPU | |
267 virtual bool asNewEffect(GrEffectRef** effect, GrTexture*, const SkMatrix& m
atrix) const SK_OVERRIDE; | |
268 #endif | |
269 SkScalar kd() const { return fKD; } | 265 SkScalar kd() const { return fKD; } |
270 | 266 |
271 protected: | 267 protected: |
272 explicit SkDiffuseLightingImageFilter(SkFlattenableReadBuffer& buffer); | 268 explicit SkDiffuseLightingImageFilter(SkFlattenableReadBuffer& buffer); |
273 virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE; | 269 virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE; |
274 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&, | 270 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&, |
275 SkBitmap* result, SkIPoint* offset) SK_OVERRIDE; | 271 SkBitmap* result, SkIPoint* offset) SK_OVERRIDE; |
276 | 272 #if SK_SUPPORT_GPU |
| 273 virtual bool asNewEffect(GrEffectRef** effect, GrTexture*, const SkMatrix& m
atrix) const SK_OVERRIDE; |
| 274 #endif |
277 | 275 |
278 private: | 276 private: |
279 typedef SkLightingImageFilter INHERITED; | 277 typedef SkLightingImageFilter INHERITED; |
280 SkScalar fKD; | 278 SkScalar fKD; |
281 }; | 279 }; |
282 | 280 |
283 class SkSpecularLightingImageFilter : public SkLightingImageFilter { | 281 class SkSpecularLightingImageFilter : public SkLightingImageFilter { |
284 public: | 282 public: |
285 SkSpecularLightingImageFilter(SkLight* light, SkScalar surfaceScale, SkScala
r ks, SkScalar shininess, SkImageFilter* input, const CropRect* cropRect); | 283 SkSpecularLightingImageFilter(SkLight* light, SkScalar surfaceScale, SkScala
r ks, SkScalar shininess, SkImageFilter* input, const CropRect* cropRect); |
286 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSpecularLightingImageF
ilter) | 284 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSpecularLightingImageF
ilter) |
287 | 285 |
288 #if SK_SUPPORT_GPU | |
289 virtual bool asNewEffect(GrEffectRef** effect, GrTexture*, const SkMatrix& m
atrix) const SK_OVERRIDE; | |
290 #endif | |
291 | |
292 SkScalar ks() const { return fKS; } | 286 SkScalar ks() const { return fKS; } |
293 SkScalar shininess() const { return fShininess; } | 287 SkScalar shininess() const { return fShininess; } |
294 | 288 |
295 protected: | 289 protected: |
296 explicit SkSpecularLightingImageFilter(SkFlattenableReadBuffer& buffer); | 290 explicit SkSpecularLightingImageFilter(SkFlattenableReadBuffer& buffer); |
297 virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE; | 291 virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE; |
298 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&, | 292 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&, |
299 SkBitmap* result, SkIPoint* offset) SK_OVERRIDE; | 293 SkBitmap* result, SkIPoint* offset) SK_OVERRIDE; |
| 294 #if SK_SUPPORT_GPU |
| 295 virtual bool asNewEffect(GrEffectRef** effect, GrTexture*, const SkMatrix& m
atrix) const SK_OVERRIDE; |
| 296 #endif |
300 | 297 |
301 private: | 298 private: |
302 typedef SkLightingImageFilter INHERITED; | 299 typedef SkLightingImageFilter INHERITED; |
303 SkScalar fKS; | 300 SkScalar fKS; |
304 SkScalar fShininess; | 301 SkScalar fShininess; |
305 }; | 302 }; |
306 | 303 |
307 #if SK_SUPPORT_GPU | 304 #if SK_SUPPORT_GPU |
308 | 305 |
309 class GrLightingEffect : public GrSingleTextureEffect { | 306 class GrLightingEffect : public GrSingleTextureEffect { |
(...skipping 1263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1573 | 1570 |
1574 builder->fsCodeAppendf("%s(%s)", fLightColorFunc.c_str(), surfaceToLight); | 1571 builder->fsCodeAppendf("%s(%s)", fLightColorFunc.c_str(), surfaceToLight); |
1575 } | 1572 } |
1576 | 1573 |
1577 #endif | 1574 #endif |
1578 | 1575 |
1579 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingImageFilter) | 1576 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingImageFilter) |
1580 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiffuseLightingImageFilter) | 1577 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiffuseLightingImageFilter) |
1581 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpecularLightingImageFilter) | 1578 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpecularLightingImageFilter) |
1582 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 1579 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
OLD | NEW |