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

Unified Diff: src/core/SkPixelRef.cpp

Issue 536003002: Hide fields in SkImageInfo (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix qt Created 6 years, 3 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 | « src/core/SkMallocPixelRef.cpp ('k') | src/effects/gradients/SkGradientShader.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPixelRef.cpp
diff --git a/src/core/SkPixelRef.cpp b/src/core/SkPixelRef.cpp
index 106407019258b078e3c6b4dc4ed655e089a70b77..1e6db7ec5a906c3e6a5ba6a61e111e2a71bd8a57 100644
--- a/src/core/SkPixelRef.cpp
+++ b/src/core/SkPixelRef.cpp
@@ -81,10 +81,13 @@ void SkPixelRef::setMutex(SkBaseMutex* mutex) {
// just need a > 0 value, so pick a funny one to aid in debugging
#define SKPIXELREF_PRELOCKED_LOCKCOUNT 123456789
-SkPixelRef::SkPixelRef(const SkImageInfo& info) : fInfo(info) {
- SkAssertResult(SkColorTypeValidateAlphaType(fInfo.colorType(), fInfo.alphaType(),
- const_cast<SkAlphaType*>(&fInfo.fAlphaType)));
+static SkImageInfo validate_info(const SkImageInfo& info) {
+ SkAlphaType newAlphaType = info.alphaType();
+ SkAssertResult(SkColorTypeValidateAlphaType(info.colorType(), info.alphaType(), &newAlphaType));
+ return info.makeAlphaType(newAlphaType);
+}
+SkPixelRef::SkPixelRef(const SkImageInfo& info) : fInfo(validate_info(info)) {
this->setMutex(NULL);
fRec.zero();
fLockCount = 0;
@@ -94,10 +97,7 @@ SkPixelRef::SkPixelRef(const SkImageInfo& info) : fInfo(info) {
}
-SkPixelRef::SkPixelRef(const SkImageInfo& info, SkBaseMutex* mutex) : fInfo(info) {
- SkAssertResult(SkColorTypeValidateAlphaType(fInfo.colorType(), fInfo.alphaType(),
- const_cast<SkAlphaType*>(&fInfo.fAlphaType)));
-
+SkPixelRef::SkPixelRef(const SkImageInfo& info, SkBaseMutex* mutex) : fInfo(validate_info(info)) {
this->setMutex(mutex);
fRec.zero();
fLockCount = 0;
@@ -234,7 +234,7 @@ void SkPixelRef::notifyPixelsChanged() {
}
void SkPixelRef::changeAlphaType(SkAlphaType at) {
- *const_cast<SkAlphaType*>(&fInfo.fAlphaType) = at;
+ *const_cast<SkImageInfo*>(&fInfo) = fInfo.makeAlphaType(at);
}
void SkPixelRef::setImmutable() {
« no previous file with comments | « src/core/SkMallocPixelRef.cpp ('k') | src/effects/gradients/SkGradientShader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698