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

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

Issue 2063793002: API change to allow for NormalSource selection at the user level. (Closed) Base URL: https://skia.googlesource.com/skia@dvonbeck-normal-factor-out
Patch Set: Addressed remaining patch 8 comments 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 | « src/core/SkLightingShader.cpp ('k') | src/core/SkNormalSource.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 2016 Google Inc. 2 * Copyright 2016 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 SkNormalSource_DEFINED 8 #ifndef SkNormalSource_DEFINED
9 #define SkNormalSource_DEFINED 9 #define SkNormalSource_DEFINED
10 10
11 #include "SkFlattenable.h" 11 #include "SkFlattenable.h"
12 12
13 /** Abstract class that generates or reads in normals for use by SkLightingShade r. Not to be 13 /** Abstract class that generates or reads in normals for use by SkLightingShade r.
14 used as part of the API yet. Used internally by SkLightingShader.
15 */ 14 */
16 class SK_API SkNormalSource : public SkFlattenable { 15 class SK_API SkNormalSource : public SkFlattenable {
17 public: 16 public:
18 virtual ~SkNormalSource() override; 17 virtual ~SkNormalSource() override;
19 18
20 #if SK_SUPPORT_GPU 19 #if SK_SUPPORT_GPU
21 /** Returns a fragment processor that takes no input and outputs a normal (a lready rotated) 20 /** Returns a fragment processor that takes no input and outputs a normal (a lready rotated)
22 as its output color. To be used as a child fragment processor. 21 as its output color. To be used as a child fragment processor.
23 */ 22 */
24 virtual sk_sp<GrFragmentProcessor> asFragmentProcessor( 23 virtual sk_sp<GrFragmentProcessor> asFragmentProcessor(
(...skipping 17 matching lines...) Expand all
42 /** Returns an instance of 'Provider' that provides normals for the CPU pipe line. The 41 /** Returns an instance of 'Provider' that provides normals for the CPU pipe line. The
43 necessary data will be initialized in place at 'storage'. 42 necessary data will be initialized in place at 'storage'.
44 */ 43 */
45 virtual Provider* asProvider(const SkShader::ContextRec&, void* storage) con st = 0; 44 virtual Provider* asProvider(const SkShader::ContextRec&, void* storage) con st = 0;
46 45
47 /** Amount of memory needed to store a provider object and its dependencies. 46 /** Amount of memory needed to store a provider object and its dependencies.
48 */ 47 */
49 virtual size_t providerSize(const SkShader::ContextRec&) const = 0; 48 virtual size_t providerSize(const SkShader::ContextRec&) const = 0;
50 49
51 /** Returns a normal source that provides normals sourced from the the norma l map argument. 50 /** Returns a normal source that provides normals sourced from the the norma l map argument.
52 Not to be used as part of the API yet. Used internally by SkLightingShad er.
53 51
54 @param map a shader that outputs the normal map 52 @param map a shader that outputs the normal map
55 @param normRotation rotation applied to the normal map's normals, i n the 53 @param ctm the current canvas' total matrix, used to rotate normals wh en necessary.
56 [cos a, sin a] form.
57 54
58 nullptr will be returned if 'map' is null 55 nullptr will be returned if 'map' is null
59 56
60 The normal map is currently assumed to be an 8888 image where the normal at a texel 57 The normal map is currently assumed to be an 8888 image where the normal at a texel
61 is retrieved by: 58 is retrieved by:
62 N.x = R-127; 59 N.x = R-127;
63 N.y = G-127; 60 N.y = G-127;
64 N.z = B-127; 61 N.z = B-127;
65 N.normalize(); 62 N.normalize();
66 The +Z axis is thus encoded in RGB as (127, 127, 255) while the -Z axis is 63 The +Z axis is thus encoded in RGB as (127, 127, 255) while the -Z axis is
67 (127, 127, 0). 64 (127, 127, 0).
68 */ 65 */
69 static sk_sp<SkNormalSource> MakeFromNormalMap(sk_sp<SkShader> map, 66 static sk_sp<SkNormalSource> MakeFromNormalMap(sk_sp<SkShader> map, const Sk Matrix& ctm);
70 const SkVector& normRotation) ;
71 67
72 SK_DEFINE_FLATTENABLE_TYPE(SkNormalSource) 68 SK_DEFINE_FLATTENABLE_TYPE(SkNormalSource)
73 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() 69 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()
74 }; 70 };
75 71
76 #endif 72 #endif
OLDNEW
« no previous file with comments | « src/core/SkLightingShader.cpp ('k') | src/core/SkNormalSource.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698