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

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: Rebased, unified headers, NormalSource is now serialized, addressed patch 1 comments 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
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 // TODO does this need to be tagged with SK_API?
20 class NormalSource : public SkFlattenable {
egdaniel 2016/06/10 14:23:28 For SK_API, it is believed that having it on the o
dvonbeck 2016/06/10 15:22:29 The problem with the approach you suggested is tha
dvonbeck 2016/06/10 18:31:21 Done.
21
egdaniel 2016/06/10 14:23:28 remove \n between class and public
dvonbeck 2016/06/10 15:22:29 Done.
22 public:
23
24 virtual ~NormalSource();
25
26 virtual sk_sp<GrFragmentProcessor> asFragmentProcessor(
27 GrContext* context,
28 const SkMatrix& viewM,
29 const SkMatrix* localMatrix,
30 SkFilterQuality filterQuality,
31 SkSourceGammaTreatment gammaTreatment) const = 0;
32
33
34 // SK_TO_STRING_VIRT() // TODO do I need this one? just copied from SkSh ader
35 SK_DEFINE_FLATTENABLE_TYPE(NormalSource)
egdaniel 2016/06/10 14:23:28 These macros just declare/define various flattenab
dvonbeck 2016/06/10 15:22:29 Acknowledged.
36 };
37
38 class NormalMapSource {
39 public:
40 static sk_sp<NormalSource> Make(const SkBitmap& normal, const SkVector& invNormRotation,
41 const SkMatrix* normLocalM);
42
43 // TODO Why? Shouldn't the impls be registered?
44 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()
45 };
46
19 /** Returns a shader that lights the diffuse and normal maps with a set of l ights. 47 /** Returns a shader that lights the diffuse and normal maps with a set of l ights.
20 48
21 It returns a shader with a reference count of 1. 49 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. 50 The caller should decrement the shader's reference count when done with the shader.
23 It is an error for count to be < 2. 51 It is an error for count to be < 2.
24 @param diffuse the diffuse bitmap 52 @param diffuse the diffuse bitmap
25 @param normal the normal map 53 @param normal the normal map
26 @param lights the lights applied to the normal map 54 @param lights the lights applied to the normal map
27 @param invNormRotation rotation applied to the normal map's normals 55 @param invNormRotation rotation applied to the normal map's normals
28 @param diffLocalMatrix the local matrix for the diffuse texture 56 @param diffLocalMatrix the local matrix for the diffuse texture
(...skipping 17 matching lines...) Expand all
46 (127, 127, 0). 74 (127, 127, 0).
47 */ 75 */
48 static sk_sp<SkShader> Make(const SkBitmap& diffuse, const SkBitmap& normal, 76 static sk_sp<SkShader> Make(const SkBitmap& diffuse, const SkBitmap& normal,
49 sk_sp<SkLights> lights, const SkVector& invNormR otation, 77 sk_sp<SkLights> lights, const SkVector& invNormR otation,
50 const SkMatrix* diffLocalMatrix, const SkMatrix* normLocalMatrix); 78 const SkMatrix* diffLocalMatrix, const SkMatrix* normLocalMatrix);
51 79
52 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() 80 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()
53 }; 81 };
54 82
55 #endif 83 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698