9 #ifndef SkLights_DEFINED
10 #define SkLights_DEFINED
12 #include "../private/SkTArray.h"
25 kDirectional_LightType,
31 , fColor(other.fColor)
32 , fDirOrPos(other.fDirOrPos)
33 , fIntensity(other.fIntensity)
34 , fShadowMap(other.fShadowMap)
35 , fIsRadial(other.fIsRadial) {
40 , fColor(other.fColor)
41 , fDirOrPos(other.fDirOrPos)
42 , fIntensity(other.fIntensity)
43 , fShadowMap(std::move(other.fShadowMap))
44 , fIsRadial(other.fIsRadial) {
48 bool isRadial =
false) {
49 Light light(kDirectional_LightType, color, dir, isRadial);
51 light.fDirOrPos.set(0.0f, 0.0f, 1.0f);
57 bool isRadial =
false) {
58 return Light(kPoint_LightType, color, pos, intensity, isRadial);
61 LightType type()
const {
return fType; }
62 const SkColor3f& color()
const {
return fColor; }
64 SkASSERT(kDirectional_LightType == fType);
68 SkASSERT(kPoint_LightType == fType);
71 SkScalar intensity()
const {
72 SkASSERT(kPoint_LightType == fType);
77 fShadowMap = std::move(shadowMap);
81 return fShadowMap.get();
84 bool isRadial()
const {
return fIsRadial; }
93 fDirOrPos = b.fDirOrPos;
94 fIntensity = b.fIntensity;
95 fShadowMap = b.fShadowMap;
96 fIsRadial = b.fIsRadial;
100 bool operator== (
const Light& b) {
105 return (fColor == b.fColor) &&
106 (fType == b.fType) &&
107 (fDirOrPos == b.fDirOrPos) &&
108 (fShadowMap == b.fShadowMap) &&
109 (fIntensity == b.fIntensity) &&
110 (fIsRadial == b.fIsRadial);
113 bool operator!= (
const Light& b) {
return !(this->operator==(b)); }
133 SkScalar intensity = 0.0f,
bool isRadial =
false) {
136 fDirOrPos = dirOrPos;
137 fIntensity = intensity;
138 fIsRadial = isRadial;
146 void add(
const Light& light) {
148 fLights->fLights.push_back(light);
152 void add(
Light&& light) {
154 fLights->fLights.push_back(std::move(light));
158 void setAmbientLightColor(
const SkColor3f& color) {
160 fLights->fAmbientLightColor = color;
165 return std::move(fLights);
172 int numLights()
const {
173 return fLights.count();
176 const Light& light(
int index)
const {
177 return fLights[index];
180 Light& light(
int index) {
181 return fLights[index];
184 const SkColor3f& ambientLightColor()
const {
185 return fAmbientLightColor;
194 fAmbientLightColor.set(0.0f, 0.0f, 0.0f);
197 friend class SkLightingShaderImpl;
200 SkTArray<Light> fLights;
Definition: SkPoint3.h:13
Definition: SkRefCnt.h:125
Definition: SkLights.h:20
Definition: SkLights.h:142
Definition: SkLights.h:22
bool normalize()
Set the point (vector) to be unit-length in the same direction as it already points.
Definition: SkWriteBuffer.h:27
SkImage is an abstraction for drawing a rectagle of pixels, though the particular type of image could...
Definition: SkImage.h:48