diff options
author | reed <reed@google.com> | 2014-09-03 11:54:58 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-03 11:54:58 -0700 |
commit | e5ea500d4714a7d84de2bf913e81be3b65d2de68 (patch) | |
tree | 0c94feeb709b17b954f5e97fad463ec9cfc4dc18 /src | |
parent | 42b0dfeb29e993b7fd247dcecff705d3dd4cf191 (diff) |
Hide fields in SkImageInfo
R=rmistry@google.com
TBR=bsalomon
Author: reed@google.com
Review URL: https://codereview.chromium.org/536003002
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkBitmap.cpp | 67 | ||||
-rw-r--r-- | src/core/SkBitmapDevice.cpp | 9 | ||||
-rw-r--r-- | src/core/SkBitmapProcState.cpp | 4 | ||||
-rw-r--r-- | src/core/SkCanvas.cpp | 8 | ||||
-rw-r--r-- | src/core/SkMallocPixelRef.cpp | 13 | ||||
-rw-r--r-- | src/core/SkPixelRef.cpp | 16 | ||||
-rw-r--r-- | src/effects/gradients/SkGradientShader.cpp | 7 | ||||
-rw-r--r-- | src/gpu/GrSurface.cpp | 9 | ||||
-rw-r--r-- | src/gpu/SkGpuDevice.cpp | 14 | ||||
-rw-r--r-- | src/gpu/SkGrPixelRef.cpp | 8 | ||||
-rw-r--r-- | src/image/SkImage.cpp | 4 | ||||
-rw-r--r-- | src/image/SkImage_Raster.cpp | 22 | ||||
-rw-r--r-- | src/image/SkSurface.cpp | 5 | ||||
-rw-r--r-- | src/image/SkSurface_Raster.cpp | 8 | ||||
-rw-r--r-- | src/images/SkDecodingImageGenerator.cpp | 14 | ||||
-rw-r--r-- | src/lazy/SkCachingPixelRef.cpp | 4 | ||||
-rw-r--r-- | src/utils/debugger/SkDebugCanvas.h | 4 |
17 files changed, 96 insertions, 120 deletions
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp index 928a4b74ed..adb69da1de 100644 --- a/src/core/SkBitmap.cpp +++ b/src/core/SkBitmap.cpp @@ -94,23 +94,22 @@ void SkBitmap::reset() { void SkBitmap::getBounds(SkRect* bounds) const { SkASSERT(bounds); bounds->set(0, 0, - SkIntToScalar(fInfo.fWidth), SkIntToScalar(fInfo.fHeight)); + SkIntToScalar(fInfo.width()), SkIntToScalar(fInfo.height())); } void SkBitmap::getBounds(SkIRect* bounds) const { SkASSERT(bounds); - bounds->set(0, 0, fInfo.fWidth, fInfo.fHeight); + bounds->set(0, 0, fInfo.width(), fInfo.height()); } /////////////////////////////////////////////////////////////////////////////// -bool SkBitmap::setInfo(const SkImageInfo& origInfo, size_t rowBytes) { - SkImageInfo info = origInfo; - - if (!SkColorTypeValidateAlphaType(info.fColorType, info.fAlphaType, - &info.fAlphaType)) { +bool SkBitmap::setInfo(const SkImageInfo& info, size_t rowBytes) { + SkAlphaType newAT = info.alphaType(); + if (!SkColorTypeValidateAlphaType(info.colorType(), info.alphaType(), &newAT)) { return reset_return_false(this); } + // don't look at info.alphaType(), since newAT is the real value... // require that rowBytes fit in 31bits int64_t mrb = info.minRowBytes64(); @@ -135,19 +134,19 @@ bool SkBitmap::setInfo(const SkImageInfo& origInfo, size_t rowBytes) { this->freePixels(); - fInfo = info; + fInfo = info.makeAlphaType(newAT); fRowBytes = SkToU32(rowBytes); return true; } -bool SkBitmap::setAlphaType(SkAlphaType alphaType) { - if (!SkColorTypeValidateAlphaType(fInfo.fColorType, alphaType, &alphaType)) { +bool SkBitmap::setAlphaType(SkAlphaType newAlphaType) { + if (!SkColorTypeValidateAlphaType(fInfo.colorType(), newAlphaType, &newAlphaType)) { return false; } - if (fInfo.fAlphaType != alphaType) { - fInfo.fAlphaType = alphaType; + if (fInfo.alphaType() != newAlphaType) { + fInfo = fInfo.makeAlphaType(newAlphaType); if (fPixelRef) { - fPixelRef->changeAlphaType(alphaType); + fPixelRef->changeAlphaType(newAlphaType); } } return true; @@ -179,21 +178,21 @@ SkPixelRef* SkBitmap::setPixelRef(SkPixelRef* pr, int dx, int dy) { if (pr) { if (kUnknown_SkColorType != fInfo.colorType()) { const SkImageInfo& prInfo = pr->info(); - SkASSERT(fInfo.fWidth <= prInfo.fWidth); - SkASSERT(fInfo.fHeight <= prInfo.fHeight); - SkASSERT(fInfo.fColorType == prInfo.fColorType); - switch (prInfo.fAlphaType) { + SkASSERT(fInfo.width() <= prInfo.width()); + SkASSERT(fInfo.height() <= prInfo.height()); + SkASSERT(fInfo.colorType() == prInfo.colorType()); + switch (prInfo.alphaType()) { case kIgnore_SkAlphaType: - SkASSERT(fInfo.fAlphaType == kIgnore_SkAlphaType); + SkASSERT(fInfo.alphaType() == kIgnore_SkAlphaType); break; case kOpaque_SkAlphaType: case kPremul_SkAlphaType: - SkASSERT(fInfo.fAlphaType == kOpaque_SkAlphaType || - fInfo.fAlphaType == kPremul_SkAlphaType); + SkASSERT(fInfo.alphaType() == kOpaque_SkAlphaType || + fInfo.alphaType() == kPremul_SkAlphaType); break; case kUnpremul_SkAlphaType: - SkASSERT(fInfo.fAlphaType == kOpaque_SkAlphaType || - fInfo.fAlphaType == kUnpremul_SkAlphaType); + SkASSERT(fInfo.alphaType() == kOpaque_SkAlphaType || + fInfo.alphaType() == kUnpremul_SkAlphaType); break; } } @@ -202,8 +201,7 @@ SkPixelRef* SkBitmap::setPixelRef(SkPixelRef* pr, int dx, int dy) { if (pr) { const SkImageInfo& info = pr->info(); - fPixelRefOrigin.set(SkPin32(dx, 0, info.fWidth), - SkPin32(dy, 0, info.fHeight)); + fPixelRefOrigin.set(SkPin32(dx, 0, info.width()), SkPin32(dy, 0, info.height())); } else { // ignore dx,dy if there is no pixelref fPixelRefOrigin.setZero(); @@ -310,7 +308,7 @@ bool SkBitmap::tryAllocPixels(const SkImageInfo& requestedInfo, size_t rowBytes) bool SkBitmap::tryAllocPixels(const SkImageInfo& requestedInfo, SkPixelRefFactory* factory, SkColorTable* ctable) { - if (kIndex_8_SkColorType == requestedInfo.fColorType && NULL == ctable) { + if (kIndex_8_SkColorType == requestedInfo.colorType() && NULL == ctable) { return reset_return_false(this); } if (!this->setInfo(requestedInfo)) { @@ -467,8 +465,7 @@ bool SkBitmap::copyPixelsTo(void* const dst, size_t dstSize, SkAutoLockPixels lock(*this); const uint8_t* srcP = reinterpret_cast<const uint8_t*>(getPixels()); uint8_t* dstP = reinterpret_cast<uint8_t*>(dst); - for (int row = 0; row < fInfo.fHeight; - row++, srcP += fRowBytes, dstP += dstRowBytes) { + for (int row = 0; row < fInfo.height(); row++, srcP += fRowBytes, dstP += dstRowBytes) { memcpy(dstP, srcP, rowBytes); } @@ -857,10 +854,8 @@ bool SkBitmap::readPixels(const SkImageInfo& requestedDstInfo, void* dstPixels, return false; } - SkImageInfo dstInfo = requestedDstInfo; // the intersect may have shrunk info's logical size - dstInfo.fWidth = srcR.width(); - dstInfo.fHeight = srcR.height(); + const SkImageInfo dstInfo = requestedDstInfo.makeWH(srcR.width(), srcR.height()); // if x or y are negative, then we have to adjust pixels if (x > 0) { @@ -881,9 +876,7 @@ bool SkBitmap::readPixels(const SkImageInfo& requestedDstInfo, void* dstPixels, return false; } - SkImageInfo srcInfo = this->info(); - srcInfo.fWidth = dstInfo.width(); - srcInfo.fHeight = dstInfo.height(); + const SkImageInfo srcInfo = this->info().makeWH(dstInfo.width(), dstInfo.height()); const void* srcPixels = this->getAddr(srcR.x(), srcR.y()); return SkPixelInfo::CopyPixels(dstInfo, dstPixels, dstRB, srcInfo, srcPixels, this->rowBytes(), @@ -936,8 +929,7 @@ bool SkBitmap::copyTo(SkBitmap* dst, SkColorType dstColorType, Allocator* alloc) // The only way to be readyToDraw is if fPixelRef is non NULL. SkASSERT(fPixelRef != NULL); - SkImageInfo dstInfo = src->info(); - dstInfo.fColorType = dstColorType; + const SkImageInfo dstInfo = src->info().makeColorType(dstColorType); SkBitmap tmpDst; if (!tmpDst.setInfo(dstInfo)) { @@ -1009,8 +1001,7 @@ bool SkBitmap::deepCopyTo(SkBitmap* dst) const { rowBytes = 0; } - SkImageInfo info = fInfo; - info.fColorType = dstCT; + const SkImageInfo info = fInfo.makeColorType(dstCT); if (!dst->setInfo(info, rowBytes)) { return false; } @@ -1338,7 +1329,7 @@ void SkBitmap::validate() const { SkASSERT(fPixelRefOrigin.fX >= 0); SkASSERT(fPixelRefOrigin.fY >= 0); SkASSERT(fPixelRef->info().width() >= (int)this->width() + fPixelRefOrigin.fX); - SkASSERT(fPixelRef->info().fHeight >= (int)this->height() + fPixelRefOrigin.fY); + SkASSERT(fPixelRef->info().height() >= (int)this->height() + fPixelRefOrigin.fY); SkASSERT(fPixelRef->rowBytes() >= fInfo.minRowBytes()); } else { SkASSERT(NULL == fColorTable); diff --git a/src/core/SkBitmapDevice.cpp b/src/core/SkBitmapDevice.cpp index 2287864bae..2711004aef 100644 --- a/src/core/SkBitmapDevice.cpp +++ b/src/core/SkBitmapDevice.cpp @@ -70,11 +70,12 @@ SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap, const SkDeviceProperties& SkBitmapDevice* SkBitmapDevice::Create(const SkImageInfo& origInfo, const SkDeviceProperties* props) { - SkImageInfo info = origInfo; - if (!valid_for_bitmap_device(info, &info.fAlphaType)) { + SkAlphaType newAT = origInfo.alphaType(); + if (!valid_for_bitmap_device(origInfo, &newAT)) { return NULL; } + const SkImageInfo info = origInfo.makeAlphaType(newAT); SkBitmap bitmap; if (kUnknown_SkColorType == info.colorType()) { @@ -150,9 +151,7 @@ bool SkBitmapDevice::onWritePixels(const SkImageInfo& srcInfo, const void* srcPi return false; } - SkImageInfo dstInfo = fBitmap.info(); - dstInfo.fWidth = srcInfo.width(); - dstInfo.fHeight = srcInfo.height(); + const SkImageInfo dstInfo = fBitmap.info().makeWH(srcInfo.width(), srcInfo.height()); void* dstPixels = fBitmap.getAddr(x, y); size_t dstRowBytes = fBitmap.rowBytes(); diff --git a/src/core/SkBitmapProcState.cpp b/src/core/SkBitmapProcState.cpp index 2fa0294750..068a107153 100644 --- a/src/core/SkBitmapProcState.cpp +++ b/src/core/SkBitmapProcState.cpp @@ -273,9 +273,7 @@ bool SkBitmapProcState::possiblyScaleImage() { SkScalar invScaleFixup = level.fScale; fInvMatrix.postScale(invScaleFixup, invScaleFixup); - SkImageInfo info = fOrigBitmap.info(); - info.fWidth = level.fWidth; - info.fHeight = level.fHeight; + const SkImageInfo info = fOrigBitmap.info().makeWH(level.fWidth, level.fHeight); // todo: if we could wrap the fCurrMip in a pixelref, then we could just install // that here, and not need to explicitly track it ourselves. fScaledBitmap.installPixels(info, level.fPixels, level.fRowBytes); diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp index f071fc99fc..83fe1407d5 100644 --- a/src/core/SkCanvas.cpp +++ b/src/core/SkCanvas.cpp @@ -631,10 +631,8 @@ bool SkCanvas::readPixels(const SkImageInfo& origInfo, void* dstP, size_t rowByt return false; } - SkImageInfo info = origInfo; // the intersect may have shrunk info's logical size - info.fWidth = srcR.width(); - info.fHeight = srcR.height(); + const SkImageInfo info = origInfo.makeWH(srcR.width(), srcR.height()); // if x or y are negative, then we have to adjust pixels if (x > 0) { @@ -686,10 +684,8 @@ bool SkCanvas::writePixels(const SkImageInfo& origInfo, const void* pixels, size return false; } - SkImageInfo info = origInfo; // the intersect may have shrunk info's logical size - info.fWidth = target.width(); - info.fHeight = target.height(); + const SkImageInfo info = origInfo.makeWH(target.width(), target.height()); // if x or y are negative, then we have to adjust pixels if (x > 0) { diff --git a/src/core/SkMallocPixelRef.cpp b/src/core/SkMallocPixelRef.cpp index 0d50164832..ae29310aea 100644 --- a/src/core/SkMallocPixelRef.cpp +++ b/src/core/SkMallocPixelRef.cpp @@ -16,10 +16,9 @@ static void sk_free_releaseproc(void* ptr, void*) { } static bool is_valid(const SkImageInfo& info, SkColorTable* ctable) { - if (info.fWidth < 0 || - info.fHeight < 0 || - (unsigned)info.fColorType > (unsigned)kLastEnum_SkColorType || - (unsigned)info.fAlphaType > (unsigned)kLastEnum_SkAlphaType) + if (info.width() < 0 || info.height() < 0 || + (unsigned)info.colorType() > (unsigned)kLastEnum_SkColorType || + (unsigned)info.alphaType() > (unsigned)kLastEnum_SkAlphaType) { return false; } @@ -72,7 +71,7 @@ SkMallocPixelRef* SkMallocPixelRef::NewAllocate(const SkImageInfo& info, rowBytes = minRB; } - int64_t bigSize = (int64_t)info.fHeight * rowBytes; + int64_t bigSize = (int64_t)info.height() * rowBytes; if (!sk_64_isS32(bigSize)) { return NULL; } @@ -142,7 +141,7 @@ SkMallocPixelRef::SkMallocPixelRef(const SkImageInfo& info, void* storage, SkASSERT(is_valid(info, ctable)); SkASSERT(rowBytes >= info.minRowBytes()); - if (kIndex_8_SkColorType != info.fColorType) { + if (kIndex_8_SkColorType != info.colorType()) { ctable = NULL; } @@ -165,7 +164,7 @@ SkMallocPixelRef::SkMallocPixelRef(const SkImageInfo& info, void* storage, SkASSERT(is_valid(info, ctable)); SkASSERT(rowBytes >= info.minRowBytes()); - if (kIndex_8_SkColorType != info.fColorType) { + if (kIndex_8_SkColorType != info.colorType()) { ctable = NULL; } diff --git a/src/core/SkPixelRef.cpp b/src/core/SkPixelRef.cpp index 1064070192..1e6db7ec5a 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() { diff --git a/src/effects/gradients/SkGradientShader.cpp b/src/effects/gradients/SkGradientShader.cpp index 9d6e856aad..3ac363568c 100644 --- a/src/effects/gradients/SkGradientShader.cpp +++ b/src/effects/gradients/SkGradientShader.cpp @@ -622,11 +622,8 @@ const SkPMColor* SkGradientShaderBase::GradientShaderCache::getCache32() { } void SkGradientShaderBase::GradientShaderCache::initCache32(GradientShaderCache* cache) { - SkImageInfo info; - info.fWidth = kCache32Count; - info.fHeight = 4; // for our 4 dither rows - info.fAlphaType = kPremul_SkAlphaType; - info.fColorType = kN32_SkColorType; + const int kNumberOfDitherRows = 4; + const SkImageInfo info = SkImageInfo::MakeN32Premul(kCache32Count, kNumberOfDitherRows); SkASSERT(NULL == cache->fCache32PixelRef); cache->fCache32PixelRef = SkMallocPixelRef::NewAllocate(info, 0, NULL); diff --git a/src/gpu/GrSurface.cpp b/src/gpu/GrSurface.cpp index 54497fe8c8..52ab4fd11d 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 d26d4f8ed2..1b6558ce43 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -168,17 +168,19 @@ SkGpuDevice* SkGpuDevice::Create(GrContext* context, const SkImageInfo& origInfo 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 2371ea72e3..f56c3b6390 100644 --- a/src/gpu/SkGrPixelRef.cpp +++ b/src/gpu/SkGrPixelRef.cpp @@ -116,8 +116,8 @@ SkGrPixelRef::SkGrPixelRef(const SkImageInfo& info, GrSurface* surface, 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 @@ bool SkGrPixelRef::onReadPixels(SkBitmap* dst, const SkIRect* subset) { 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"); diff --git a/src/image/SkImage.cpp b/src/image/SkImage.cpp index a6063846c7..13b6fcd463 100644 --- a/src/image/SkImage.cpp +++ b/src/image/SkImage.cpp @@ -94,9 +94,9 @@ SkData* SkImage::encode(SkImageEncoder::Type type, int quality) const { /////////////////////////////////////////////////////////////////////////////// static bool raster_canvas_supports(const SkImageInfo& info) { - switch (info.fColorType) { + switch (info.colorType()) { case kN32_SkColorType: - return kUnpremul_SkAlphaType != info.fAlphaType; + return kUnpremul_SkAlphaType != info.alphaType(); case kRGB_565_SkColorType: return true; case kAlpha_8_SkColorType: diff --git a/src/image/SkImage_Raster.cpp b/src/image/SkImage_Raster.cpp index a7e4e009e5..f1d1fcd27f 100644 --- a/src/image/SkImage_Raster.cpp +++ b/src/image/SkImage_Raster.cpp @@ -19,16 +19,16 @@ public: const int maxDimension = SK_MaxS32 >> 2; const size_t kMaxPixelByteSize = SK_MaxS32; - if (info.fWidth < 0 || info.fHeight < 0) { + if (info.width() < 0 || info.height() < 0) { return false; } - if (info.fWidth > maxDimension || info.fHeight > maxDimension) { + if (info.width() > maxDimension || info.height() > maxDimension) { return false; } - if ((unsigned)info.fColorType > (unsigned)kLastEnum_SkColorType) { + if ((unsigned)info.colorType() > (unsigned)kLastEnum_SkColorType) { return false; } - if ((unsigned)info.fAlphaType > (unsigned)kLastEnum_SkAlphaType) { + if ((unsigned)info.alphaType() > (unsigned)kLastEnum_SkAlphaType) { return false; } @@ -42,7 +42,7 @@ public: return false; } - int64_t size = (int64_t)info.fHeight * rowBytes; + int64_t size = (int64_t)info.height() * rowBytes; if (size > (int64_t)kMaxPixelByteSize) { return false; } @@ -102,7 +102,7 @@ static void release_data(void* addr, void* context) { } SkImage_Raster::SkImage_Raster(const Info& info, SkData* data, size_t rowBytes) - : INHERITED(info.fWidth, info.fHeight) + : INHERITED(info.width(), info.height()) { data->ref(); void* addr = const_cast<void*>(data->data()); @@ -114,7 +114,7 @@ SkImage_Raster::SkImage_Raster(const Info& info, SkData* data, size_t rowBytes) } SkImage_Raster::SkImage_Raster(const Info& info, SkPixelRef* pr, size_t rowBytes) - : INHERITED(info.fWidth, info.fHeight) + : INHERITED(info.width(), info.height()) { fBitmap.setInfo(info, rowBytes); fBitmap.setPixelRef(pr); @@ -170,7 +170,7 @@ SkImage* SkImage::NewRasterCopy(const SkImageInfo& info, const void* pixels, siz if (!SkImage_Raster::ValidArgs(info, rowBytes)) { return NULL; } - if (0 == info.fWidth && 0 == info.fHeight) { + if (0 == info.width() && 0 == info.height()) { return SkImage_Raster::NewEmpty(); } // check this after empty-check @@ -179,7 +179,7 @@ SkImage* SkImage::NewRasterCopy(const SkImageInfo& info, const void* pixels, siz } // Here we actually make a copy of the caller's pixel data - SkAutoDataUnref data(SkData::NewWithCopy(pixels, info.fHeight * rowBytes)); + SkAutoDataUnref data(SkData::NewWithCopy(pixels, info.height() * rowBytes)); return SkNEW_ARGS(SkImage_Raster, (info, data, rowBytes)); } @@ -188,7 +188,7 @@ SkImage* SkImage::NewRasterData(const SkImageInfo& info, SkData* data, size_t ro if (!SkImage_Raster::ValidArgs(info, rowBytes)) { return NULL; } - if (0 == info.fWidth && 0 == info.fHeight) { + if (0 == info.width() && 0 == info.height()) { return SkImage_Raster::NewEmpty(); } // check this after empty-check @@ -197,7 +197,7 @@ SkImage* SkImage::NewRasterData(const SkImageInfo& info, SkData* data, size_t ro } // did they give us enough data? - size_t size = info.fHeight * rowBytes; + size_t size = info.height() * rowBytes; if (data->size() < size) { return NULL; } diff --git a/src/image/SkSurface.cpp b/src/image/SkSurface.cpp index edc6ef5fa0..9f24e97c50 100644 --- a/src/image/SkSurface.cpp +++ b/src/image/SkSurface.cpp @@ -80,10 +80,7 @@ SkSurface::SkSurface(int width, int height) : fWidth(width), fHeight(height) { fGenerationID = 0; } -SkSurface::SkSurface(const SkImageInfo& info) - : fWidth(info.fWidth) - , fHeight(info.fHeight) -{ +SkSurface::SkSurface(const SkImageInfo& info) : fWidth(info.width()), fHeight(info.height()) { SkASSERT(fWidth >= 0); SkASSERT(fHeight >= 0); fGenerationID = 0; diff --git a/src/image/SkSurface_Raster.cpp b/src/image/SkSurface_Raster.cpp index 986994ab8f..167f7733db 100644 --- a/src/image/SkSurface_Raster.cpp +++ b/src/image/SkSurface_Raster.cpp @@ -41,7 +41,7 @@ bool SkSurface_Raster::Valid(const SkImageInfo& info, size_t rowBytes) { static const size_t kMaxTotalSize = SK_MaxS32; int shift = 0; - switch (info.fColorType) { + switch (info.colorType()) { case kAlpha_8_SkColorType: shift = 0; break; @@ -59,7 +59,7 @@ bool SkSurface_Raster::Valid(const SkImageInfo& info, size_t rowBytes) { return true; } - uint64_t minRB = (uint64_t)info.fWidth << shift; + uint64_t minRB = (uint64_t)info.width() << shift; if (minRB > rowBytes) { return false; } @@ -69,7 +69,7 @@ bool SkSurface_Raster::Valid(const SkImageInfo& info, size_t rowBytes) { return false; } - uint64_t size = sk_64_mul(info.fHeight, rowBytes); + uint64_t size = sk_64_mul(info.height(), rowBytes); if (size > kMaxTotalSize) { return false; } @@ -86,7 +86,7 @@ SkSurface_Raster::SkSurface_Raster(const SkImageInfo& info, void* pixels, size_t } SkSurface_Raster::SkSurface_Raster(SkPixelRef* pr) - : INHERITED(pr->info().fWidth, pr->info().fHeight) + : INHERITED(pr->info().width(), pr->info().height()) { const SkImageInfo& info = pr->info(); diff --git a/src/images/SkDecodingImageGenerator.cpp b/src/images/SkDecodingImageGenerator.cpp index 5c66c94a53..1d91bcc0f9 100644 --- a/src/images/SkDecodingImageGenerator.cpp +++ b/src/images/SkDecodingImageGenerator.cpp @@ -167,8 +167,7 @@ bool DecodingImageGenerator::onGetPixels(const SkImageInfo& info, } decoder->setDitherImage(fDitherImage); decoder->setSampleSize(fSampleSize); - decoder->setRequireUnpremultipliedColors( - info.fAlphaType == kUnpremul_SkAlphaType); + decoder->setRequireUnpremultipliedColors(info.alphaType() == kUnpremul_SkAlphaType); SkBitmap bitmap; TargetAllocator allocator(fInfo, pixels, rowBytes); @@ -240,19 +239,20 @@ SkImageGenerator* CreateDecodingImageGenerator( SkASSERT(bitmap.colorType() != opts.fRequestedColorType); return NULL; // Can not translate to needed config. } - info.fColorType = opts.fRequestedColorType; + info = info.makeColorType(opts.fRequestedColorType); } - if (opts.fRequireUnpremul && info.fAlphaType != kOpaque_SkAlphaType) { - info.fAlphaType = kUnpremul_SkAlphaType; + if (opts.fRequireUnpremul && info.alphaType() != kOpaque_SkAlphaType) { + info = info.makeAlphaType(kUnpremul_SkAlphaType); } - if (!SkColorTypeValidateAlphaType(info.fColorType, info.fAlphaType, &info.fAlphaType)) { + SkAlphaType newAlphaType = info.alphaType(); + if (!SkColorTypeValidateAlphaType(info.colorType(), info.alphaType(), &newAlphaType)) { return NULL; } return SkNEW_ARGS(DecodingImageGenerator, - (data, autoStream.detach(), info, + (data, autoStream.detach(), info.makeAlphaType(newAlphaType), opts.fSampleSize, opts.fDitherImage)); } diff --git a/src/lazy/SkCachingPixelRef.cpp b/src/lazy/SkCachingPixelRef.cpp index bd675324f1..aeaa412508 100644 --- a/src/lazy/SkCachingPixelRef.cpp +++ b/src/lazy/SkCachingPixelRef.cpp @@ -44,7 +44,7 @@ bool SkCachingPixelRef::onNewLockPixels(LockRec* rec) { } const SkImageInfo& info = this->info(); - if (!SkBitmapCache::Find(this->getGenerationID(), info.fWidth, info.fHeight, &fLockedBitmap)) { + if (!SkBitmapCache::Find(this->getGenerationID(), info.width(), info.height(), &fLockedBitmap)) { // Cache has been purged, must re-decode. if (!fLockedBitmap.tryAllocPixels(info, fRowBytes)) { fErrorInDecoding = true; @@ -55,7 +55,7 @@ bool SkCachingPixelRef::onNewLockPixels(LockRec* rec) { return false; } fLockedBitmap.setImmutable(); - SkBitmapCache::Add(this->getGenerationID(), info.fWidth, info.fHeight, fLockedBitmap); + SkBitmapCache::Add(this->getGenerationID(), info.width(), info.height(), fLockedBitmap); } // Now bitmap should contain a concrete PixelRef of the decoded image. diff --git a/src/utils/debugger/SkDebugCanvas.h b/src/utils/debugger/SkDebugCanvas.h index 2e9a032e4e..4bb33b7475 100644 --- a/src/utils/debugger/SkDebugCanvas.h +++ b/src/utils/debugger/SkDebugCanvas.h @@ -210,8 +210,8 @@ public: virtual bool getClipBounds(SkRect* bounds) const SK_OVERRIDE { if (NULL != bounds) { bounds->setXYWH(0, 0, - SkIntToScalar(this->imageInfo().fWidth), - SkIntToScalar(this->imageInfo().fHeight)); + SkIntToScalar(this->imageInfo().width()), + SkIntToScalar(this->imageInfo().height())); } return true; } |