Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(300)

Side by Side Diff: src/core/SkLightingShader.h

Issue 2064153002: Changed SkLightingShader API to take in a shader as color source (Closed) Base URL: https://skia.googlesource.com/skia@dvonbeck-diffuse-factor-out
Patch Set: rebase Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « samplecode/SampleLitAtlas.cpp ('k') | src/core/SkLightingShader.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 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 #ifndef SkLightingShader_DEFINED 8 #ifndef SkLightingShader_DEFINED
9 #define SkLightingShader_DEFINED 9 #define SkLightingShader_DEFINED
10 10
11 #include "SkLights.h" 11 #include "SkLights.h"
12 #include "SkShader.h" 12 #include "SkShader.h"
13 13
14 class SkBitmap; 14 class SkBitmap;
15 class SkMatrix; 15 class SkMatrix;
16 class SkNormalSource; 16 class SkNormalSource;
17 17
18 class SK_API SkLightingShader { 18 class SK_API SkLightingShader {
19 public: 19 public:
20 /** Returns a shader that lights the diffuse map using the normals and a set of lights. 20 /** Returns a shader that lights the shape, colored by the diffuseShader, us ing the
21 normals from normalSource, with the set of lights provided.
21 22
22 It returns a shader with a reference count of 1. 23 It returns a shader with a reference count of 1.
23 The caller should decrement the shader's reference count when done with the shader. 24 The caller should decrement the shader's reference count when done with the shader.
24 It is an error for count to be < 2. 25 It is an error for count to be < 2.
25 @param diffuse the diffuse bitmap 26 @param diffuseShader the shader that provides the colors
26 @param lights the lights applied to the normal map 27 @param normalSource the source for the shape's normals
27 @param diffLocalMatrix the local matrix for the diffuse map (transform from 28 @param lights the lights applied to the normals
28 texture coordinates to shape source coordinates) . nullptr is
29 interpreted as an identity matrix.
30 @param normalSource the source for the normals
31
32 nullptr will be returned if:
33 'diffuse' is empty
34 'diffuse' is too big (> 65535 on any side)
35 29
36 The lighting equation is currently: 30 The lighting equation is currently:
37 result = LightColor * DiffuseColor * (Normal * LightDir) + AmbientCo lor 31 result = LightColor * DiffuseColor * (Normal * LightDir) + AmbientCo lor
38 32
39 */ 33 */
40 static sk_sp<SkShader> Make(const SkBitmap& diffuse, sk_sp<SkLights> lights, 34 static sk_sp<SkShader> Make(sk_sp<SkShader> diffuseShader, sk_sp<SkNormalSou rce> normalSource,
41 const SkMatrix* diffLocalMatrix, 35 sk_sp<SkLights> lights);
42 sk_sp<SkNormalSource> normalSource);
43 36
44 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() 37 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()
45 }; 38 };
46 39
47 #endif 40 #endif
OLDNEW
« no previous file with comments | « samplecode/SampleLitAtlas.cpp ('k') | src/core/SkLightingShader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698