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

Unified Diff: include/core/SkLights.h

Issue 2206823003: Fix dtor bug in SkLights (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkLights.h
diff --git a/include/core/SkLights.h b/include/core/SkLights.h
index 0b23cc14aa01fa742133e5dfdf332f24d8e6a334..52e60c71a07a5fe3cae5f441f58e858617490251 100644
--- a/include/core/SkLights.h
+++ b/include/core/SkLights.h
@@ -11,7 +11,7 @@
#include "SkPoint3.h"
#include "SkRefCnt.h"
-#include "../private/SkTDArray.h"
+#include "../private/SkTArray.h"
#include "SkImage.h"
class SK_API SkLights : public SkRefCnt {
@@ -23,11 +23,24 @@ public:
kDirectional_LightType
};
+ Light(const Light& other)
+ : fType(other.fType)
+ , fColor(other.fColor)
+ , fDirection(other.fDirection)
+ , fShadowMap(other.fShadowMap) {
+ }
+
+ Light(Light&& other)
+ : fType(other.fType)
+ , fColor(other.fColor)
+ , fDirection(other.fDirection)
+ , fShadowMap(std::move(other.fShadowMap)) {
+ }
+
Light(const SkColor3f& color)
: fType(kAmbient_LightType)
, fColor(color) {
fDirection.set(0.0f, 0.0f, 1.0f);
- fShadowMap.reset(nullptr);
}
Light(const SkColor3f& color, const SkVector3& dir)
@@ -37,7 +50,6 @@ public:
if (!fDirection.normalize()) {
fDirection.set(0.0f, 0.0f, 1.0f);
}
- fShadowMap.reset(nullptr);
}
LightType type() const { return fType; }
@@ -51,22 +63,19 @@ public:
fShadowMap = std::move(shadowMap);
}
- sk_sp<SkImage> getShadowMap() const {
- return fShadowMap;
+ SkImage* getShadowMap() const {
+ return fShadowMap.get();
}
Light& operator= (const Light& b) {
- if (this == &b)
+ if (this == &b) {
return *this;
-
- this->fColor = b.fColor;
- this->fType = b.fType;
- this->fDirection = b.fDirection;
-
- if (b.fShadowMap) {
- this->fShadowMap = b.fShadowMap;
}
+ fColor = b.fColor;
+ fType = b.fType;
+ fDirection = b.fDirection;
+ fShadowMap = b.fShadowMap;
return *this;
}
@@ -84,12 +93,18 @@ public:
void add(const Light& light) {
if (fLights) {
- (void) fLights->fLights.append(1, &light);
+ fLights->fLights.push_back(light);
+ }
+ }
+
+ void add(Light&& light) {
+ if (fLights) {
+ fLights->fLights.push_back(std::move(light));
}
}
sk_sp<SkLights> finish() {
- return fLights;
+ return std::move(fLights);
}
private:
@@ -111,7 +126,9 @@ public:
private:
SkLights() {}
- SkTDArray<Light> fLights;
+ SkTArray<Light> fLights;
+
+ typedef SkRefCnt INHERITED;
};
#endif
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698