SkLightingShader.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Copyright 2015 Google Inc.
  3. *
  4. * Use of this source code is governed by a BSD-style license that can be
  5. * found in the LICENSE file.
  6. */
  7. #ifndef SkLightingShader_DEFINED
  8. #define SkLightingShader_DEFINED
  9. #include "include/core/SkShader.h"
  10. #include "src/shaders/SkLights.h"
  11. class SkBitmap;
  12. class SkMatrix;
  13. class SkNormalSource;
  14. class SkLightingShader {
  15. public:
  16. /** Returns a shader that lights the shape, colored by the diffuseShader, using the
  17. normals from normalSource, with the set of lights provided.
  18. @param diffuseShader the shader that provides the colors. If nullptr, uses the paint's
  19. color.
  20. @param normalSource the source for the shape's normals. If nullptr, assumes straight
  21. up normals (<0,0,1>).
  22. @param lights the lights applied to the normals
  23. The lighting equation is currently:
  24. result = (LightColor * dot(Normal, LightDir) + AmbientColor) * DiffuseColor
  25. */
  26. static sk_sp<SkShader> Make(sk_sp<SkShader> diffuseShader, sk_sp<SkNormalSource> normalSource,
  27. sk_sp<SkLights> lights);
  28. static void RegisterFlattenables();
  29. };
  30. #endif