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

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

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