Hide fields in SkImageInfo
R=rmistry@google.com
TBR=bsalomon
Author: reed@google.com
Review URL: https://codereview.chromium.org/536003002
diff --git a/src/gpu/GrSurface.cpp b/src/gpu/GrSurface.cpp
index 54497fe..52ab4fd 100644
--- a/src/gpu/GrSurface.cpp
+++ b/src/gpu/GrSurface.cpp
@@ -13,14 +13,11 @@
#include <stdio.h>
SkImageInfo GrSurface::info() const {
- SkImageInfo info;
- if (!GrPixelConfig2ColorType(this->config(), &info.fColorType)) {
+ SkColorType colorType;
+ if (!GrPixelConfig2ColorType(this->config(), &colorType)) {
sk_throw();
}
- info.fWidth = this->width();
- info.fHeight = this->height();
- info.fAlphaType = kPremul_SkAlphaType;
- return info;
+ return SkImageInfo::Make(this->width(), this->height(), colorType, kPremul_SkAlphaType);
}
bool GrSurface::savePixels(const char* filename) {
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index d26d4f8..1b6558c 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -168,17 +168,19 @@
return NULL;
}
- SkImageInfo info = origInfo;
+ SkColorType ct = origInfo.colorType();
+ SkAlphaType at = origInfo.alphaType();
// TODO: perhas we can loosen this check now that colortype is more detailed
// e.g. can we support both RGBA and BGRA here?
- if (kRGB_565_SkColorType == info.colorType()) {
- info.fAlphaType = kOpaque_SkAlphaType; // force this setting
+ if (kRGB_565_SkColorType == ct) {
+ at = kOpaque_SkAlphaType; // force this setting
} else {
- info.fColorType = kN32_SkColorType;
- if (kOpaque_SkAlphaType != info.alphaType()) {
- info.fAlphaType = kPremul_SkAlphaType; // force this setting
+ ct = kN32_SkColorType;
+ if (kOpaque_SkAlphaType != at) {
+ at = kPremul_SkAlphaType; // force this setting
}
}
+ const SkImageInfo info = SkImageInfo::Make(origInfo.width(), origInfo.height(), ct, at);
GrTextureDesc desc;
desc.fFlags = kRenderTarget_GrTextureFlagBit;
diff --git a/src/gpu/SkGrPixelRef.cpp b/src/gpu/SkGrPixelRef.cpp
index 2371ea7..f56c3b6 100644
--- a/src/gpu/SkGrPixelRef.cpp
+++ b/src/gpu/SkGrPixelRef.cpp
@@ -116,8 +116,8 @@
fUnlock = transferCacheLock;
if (fSurface) {
- SkASSERT(info.fWidth <= fSurface->width());
- SkASSERT(info.fHeight <= fSurface->height());
+ SkASSERT(info.width() <= fSurface->width());
+ SkASSERT(info.height() <= fSurface->height());
}
}
@@ -166,9 +166,9 @@
height = subset->height();
} else {
left = 0;
- width = this->info().fWidth;
+ width = this->info().width();
top = 0;
- height = this->info().fHeight;
+ height = this->info().height();
}
if (!dst->tryAllocN32Pixels(width, height)) {
SkDebugf("SkGrPixelRef::onReadPixels failed to alloc bitmap for result!\n");