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

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

Issue 2050773002: Refactoring of CPU NormalMap handling out into its own class (Closed) Base URL: https://skia.googlesource.com/skia@dvonbeck-normals-gpu-cl
Patch Set: Got rid of variable-length arrays 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 | « no previous file | src/core/SkLightingShader.cpp » ('j') | src/core/SkLightingShader.cpp » ('J')
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 19 /** Abstract class that generates or reads in normals for use by SkLightingS hader. Not to be
20 implements the GPU side only. Not to be used as part of the API yet. Use d internally by 20 used as part of the API yet. Used internally by SkLightingShader.
21 SkLightingShader.
22 */ 21 */
23 class NormalSource : public SkFlattenable { 22 class NormalSource : public SkFlattenable {
24 public: 23 public:
25 virtual ~NormalSource(); 24 virtual ~NormalSource();
26 25
27 #if SK_SUPPORT_GPU 26 #if SK_SUPPORT_GPU
28 27
29 /** Returns a fragment processor that takes no input and outputs a norma l (already rotated) 28 /** 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. 29 as its output color. To be used as a child fragment processor.
31 */ 30 */
32 virtual sk_sp<GrFragmentProcessor> asFragmentProcessor( 31 virtual sk_sp<GrFragmentProcessor> asFragmentProcessor(
33 GrContext* context, 32 GrContext* context,
34 const SkMatrix& viewM, 33 const SkMatrix& viewM,
35 const SkMatrix* localMatrix, 34 const SkMatrix* localMatrix,
36 SkFilterQuality filterQuality, 35 SkFilterQuality filterQuality,
37 SkSourceGammaTreatment gammaTreatment) const = 0; 36 SkSourceGammaTreatment gammaTreatment) const = 0;
38 #endif 37 #endif
39 38
39 class Provider {
40 public:
41 virtual ~Provider(){};
egdaniel 2016/06/16 13:48:10 nit: space between () and {}
dvonbeck 2016/06/16 22:05:40 Done.
42
43 /** Called for each span of the object being drawn on the CPU. Your subclass should set
44 the appropriate normals that correspond to the specified device coordinates.
45 */
46 virtual void fillScanLine(int x, int y, SkPoint3 output[], int count ) const = 0;
47
48 /** Returns the maximum count that can be passed into 'fillScanLine' for an output
49 buffer of size 'count'.
50 */
51 virtual int maxCountForFillScanLine(int count) const = 0;
52 };
53
54 /** Returns an instance of 'Provider' that provides normals for the CPU pipeline. The
55 necessary data will be initialized in place at 'storage'.
56 */
57 virtual Provider* asProvider(const SkShader::ContextRec& rec, void* stor age) const = 0;
58
59 /** Amount of memory needed to store a provider object and its dependenc ies.
60 */
61 virtual size_t providerSize() const = 0;
62
40 SK_DEFINE_FLATTENABLE_TYPE(NormalSource) 63 SK_DEFINE_FLATTENABLE_TYPE(NormalSource)
41 }; 64 };
42 65
43 /** Returns a normal source that provides normals sourced from the the norma l map argument. 66 /** 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. 67 Not to be used as part of the API yet. Used internally by SkLightingShad er.
45 68
46 @param normal the normal map 69 @param normal the normal map
47 @param invNormRotation rotation applied to the normal map's norma ls 70 @param invNormRotation rotation applied to the normal map's norma ls
48 @param normLocalM the local matrix for the normal map 71 @param normLocalM the local matrix for the normal map
49 72
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 (127, 127, 0). 121 (127, 127, 0).
99 */ 122 */
100 static sk_sp<SkShader> Make(const SkBitmap& diffuse, const SkBitmap& normal, 123 static sk_sp<SkShader> Make(const SkBitmap& diffuse, const SkBitmap& normal,
101 sk_sp<SkLights> lights, const SkVector& invNormR otation, 124 sk_sp<SkLights> lights, const SkVector& invNormR otation,
102 const SkMatrix* diffLocalMatrix, const SkMatrix* normLocalMatrix); 125 const SkMatrix* diffLocalMatrix, const SkMatrix* normLocalMatrix);
103 126
104 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() 127 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()
105 }; 128 };
106 129
107 #endif 130 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkLightingShader.cpp » ('j') | src/core/SkLightingShader.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698