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

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

Issue 2062133004: Revert of Refactoring of GPU NormalMap handling out into its own class (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Created 4 years, 6 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 | « src/core/SkBitmapProcShader.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 16
17 class SK_API SkLightingShader { 17 class SK_API SkLightingShader {
18 public: 18 public:
19 /** Abstract class that generates or reads in normals for use by SkLightingS hader. Currently
20 implements the GPU side only. Not to be used as part of the API yet. Use d internally by
21 SkLightingShader.
22 */
23 class NormalSource : public SkFlattenable {
24 public:
25 virtual ~NormalSource();
26
27 #if SK_SUPPORT_GPU
28
29 /** Returns a fragment processor that takes no input and outputs a norma l (already rotated)
30 as its output color. To be used as a child fragment processor.
31 */
32 virtual sk_sp<GrFragmentProcessor> asFragmentProcessor(
33 GrContext* context,
34 const SkMatrix& viewM,
35 const SkMatrix* localMatrix,
36 SkFilterQuality filterQuality,
37 SkSourceGammaTreatment gammaTreatment) const = 0;
38 #endif
39
40 SK_DEFINE_FLATTENABLE_TYPE(NormalSource)
41 };
42
43 /** Returns a normal source that provides normals sourced from the the norma l map argument.
44 Not to be used as part of the API yet. Used internally by SkLightingShad er.
45
46 @param normal the normal map
47 @param invNormRotation rotation applied to the normal map's norma ls
48 @param normLocalM the local matrix for the normal map
49
50 nullptr will be returned if
51 'normal' is empty
52 'normal' too big (> 65535 on either side)
53
54 The normal map is currently assumed to be an 8888 image where the normal at a texel
55 is retrieved by:
56 N.x = R-127;
57 N.y = G-127;
58 N.z = B-127;
59 N.normalize();
60 The +Z axis is thus encoded in RGB as (127, 127, 255) while the -Z axis is
61 (127, 127, 0).
62 */
63 class NormalMapSource {
64 public:
65 static sk_sp<NormalSource> Make(const SkBitmap& normal, const SkVector& invNormRotation,
66 const SkMatrix* normLocalM);
67
68 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()
69 };
70
71 /** Returns a shader that lights the diffuse and normal maps with a set of l ights. 19 /** Returns a shader that lights the diffuse and normal maps with a set of l ights.
72 20
73 It returns a shader with a reference count of 1. 21 It returns a shader with a reference count of 1.
74 The caller should decrement the shader's reference count when done with the shader. 22 The caller should decrement the shader's reference count when done with the shader.
75 It is an error for count to be < 2. 23 It is an error for count to be < 2.
76 @param diffuse the diffuse bitmap 24 @param diffuse the diffuse bitmap
77 @param normal the normal map 25 @param normal the normal map
78 @param lights the lights applied to the normal map 26 @param lights the lights applied to the normal map
79 @param invNormRotation rotation applied to the normal map's normals 27 @param invNormRotation rotation applied to the normal map's normals
80 @param diffLocalMatrix the local matrix for the diffuse texture 28 @param diffLocalMatrix the local matrix for the diffuse texture
(...skipping 17 matching lines...) Expand all
98 (127, 127, 0). 46 (127, 127, 0).
99 */ 47 */
100 static sk_sp<SkShader> Make(const SkBitmap& diffuse, const SkBitmap& normal, 48 static sk_sp<SkShader> Make(const SkBitmap& diffuse, const SkBitmap& normal,
101 sk_sp<SkLights> lights, const SkVector& invNormR otation, 49 sk_sp<SkLights> lights, const SkVector& invNormR otation,
102 const SkMatrix* diffLocalMatrix, const SkMatrix* normLocalMatrix); 50 const SkMatrix* diffLocalMatrix, const SkMatrix* normLocalMatrix);
103 51
104 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() 52 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()
105 }; 53 };
106 54
107 #endif 55 #endif
OLDNEW
« no previous file with comments | « src/core/SkBitmapProcShader.cpp ('k') | src/core/SkLightingShader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698