diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-04-22 18:22:30 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-04-22 18:22:30 +0000 |
commit | dcacd5fd5a0baeb83d8c61bb6127c442ef72e29a (patch) | |
tree | 97943d5b70c7c7cf5afec33987de49f60c0ec87d | |
parent | dcecb168968ca136c7fb9e8b444bec56f19af70c (diff) |
eliminate config param -- it was always self's config
BUG=skia:
R=bsalomon@google.com
Review URL: https://codereview.chromium.org/246513002
git-svn-id: http://skia.googlecode.com/svn/trunk@14303 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | include/core/SkPixelRef.h | 3 | ||||
-rw-r--r-- | include/gpu/SkGrPixelRef.h | 2 | ||||
-rw-r--r-- | src/core/SkBitmap.cpp | 26 | ||||
-rw-r--r-- | src/gpu/SkGrPixelRef.cpp | 9 |
4 files changed, 14 insertions, 26 deletions
diff --git a/include/core/SkPixelRef.h b/include/core/SkPixelRef.h index 8319ec6da5..579ca5b7e8 100644 --- a/include/core/SkPixelRef.h +++ b/include/core/SkPixelRef.h @@ -223,14 +223,13 @@ public: /** * Makes a deep copy of this PixelRef, respecting the requested config. - * @param config Desired config. * @param subset Subset of this PixelRef to copy. Must be fully contained within the bounds of * of this PixelRef. * @return A new SkPixelRef, or NULL if either there is an error (e.g. the destination could * not be created with the given config), or this PixelRef does not support deep * copies. */ - virtual SkPixelRef* deepCopy(SkBitmap::Config config, const SkIRect* subset = NULL) { + virtual SkPixelRef* deepCopy(const SkIRect* subset = NULL) { return NULL; } diff --git a/include/gpu/SkGrPixelRef.h b/include/gpu/SkGrPixelRef.h index 1e495611fc..702a3bf871 100644 --- a/include/gpu/SkGrPixelRef.h +++ b/include/gpu/SkGrPixelRef.h @@ -56,7 +56,7 @@ public: protected: // overrides from SkPixelRef virtual bool onReadPixels(SkBitmap* dst, const SkIRect* subset) SK_OVERRIDE; - virtual SkPixelRef* deepCopy(SkBitmap::Config dstConfig, const SkIRect* subset) SK_OVERRIDE; + virtual SkPixelRef* deepCopy(const SkIRect* subset) SK_OVERRIDE; private: GrSurface* fSurface; diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp index 72395172da..2a8c8e45e2 100644 --- a/src/core/SkBitmap.cpp +++ b/src/core/SkBitmap.cpp @@ -946,7 +946,7 @@ bool SkBitmap::extractSubset(SkBitmap* result, const SkIRect& subset) const { if (fPixelRef->getTexture() != NULL) { // Do a deep copy - SkPixelRef* pixelRef = fPixelRef->deepCopy(this->config(), &subset); + SkPixelRef* pixelRef = fPixelRef->deepCopy(&subset); if (pixelRef != NULL) { SkBitmap dst; dst.setConfig(this->config(), subset.width(), subset.height(), 0, @@ -1145,8 +1145,7 @@ bool SkBitmap::copyTo(SkBitmap* dst, SkColorType dstColorType, } bool SkBitmap::deepCopyTo(SkBitmap* dst) const { - const SkBitmap::Config dstConfig = this->config(); - const SkColorType dstCT = SkBitmapConfigToColorType(dstConfig); + const SkColorType dstCT = this->colorType(); if (!this->canCopyTo(dstCT)) { return false; @@ -1155,24 +1154,15 @@ bool SkBitmap::deepCopyTo(SkBitmap* dst) const { // If we have a PixelRef, and it supports deep copy, use it. // Currently supported only by texture-backed bitmaps. if (fPixelRef) { - SkPixelRef* pixelRef = fPixelRef->deepCopy(dstConfig); + SkPixelRef* pixelRef = fPixelRef->deepCopy(); if (pixelRef) { - uint32_t rowBytes; - if (this->colorType() == dstCT) { - // Since there is no subset to pass to deepCopy, and deepCopy - // succeeded, the new pixel ref must be identical. - SkASSERT(fPixelRef->info() == pixelRef->info()); - pixelRef->cloneGenID(*fPixelRef); - // Use the same rowBytes as the original. - rowBytes = fRowBytes; - } else { - // With the new config, an appropriate fRowBytes will be computed by setConfig. - rowBytes = 0; - } + // Since there is no subset to pass to deepCopy, and deepCopy + // succeeded, the new pixel ref must be identical. + SkASSERT(fPixelRef->info() == pixelRef->info()); + pixelRef->cloneGenID(*fPixelRef); SkImageInfo info = fInfo; - info.fColorType = dstCT; - if (!dst->setConfig(info, rowBytes)) { + if (!dst->setConfig(info, fRowBytes)) { return false; } dst->setPixelRef(pixelRef, fPixelRefOrigin)->unref(); diff --git a/src/gpu/SkGrPixelRef.cpp b/src/gpu/SkGrPixelRef.cpp index 18fefcc789..f0e4e322f8 100644 --- a/src/gpu/SkGrPixelRef.cpp +++ b/src/gpu/SkGrPixelRef.cpp @@ -51,8 +51,7 @@ bool SkROLockPixelsPixelRef::onLockPixelsAreWritable() const { /////////////////////////////////////////////////////////////////////////////// -static SkGrPixelRef* copyToTexturePixelRef(GrTexture* texture, SkBitmap::Config dstConfig, - const SkIRect* subset) { +static SkGrPixelRef* copyToTexturePixelRef(GrTexture* texture, const SkIRect* subset) { if (NULL == texture) { return NULL; } @@ -77,7 +76,7 @@ static SkGrPixelRef* copyToTexturePixelRef(GrTexture* texture, SkBitmap::Config topLeft = NULL; } desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit; - desc.fConfig = SkBitmapConfig2GrPixelConfig(dstConfig); + desc.fConfig = texture->config(); SkImageInfo info; if (!GrPixelConfig2ColorType(desc.fConfig, &info.fColorType)) { @@ -152,7 +151,7 @@ GrTexture* SkGrPixelRef::getTexture() { return NULL; } -SkPixelRef* SkGrPixelRef::deepCopy(SkBitmap::Config dstConfig, const SkIRect* subset) { +SkPixelRef* SkGrPixelRef::deepCopy(const SkIRect* subset) { if (NULL == fSurface) { return NULL; } @@ -163,7 +162,7 @@ SkPixelRef* SkGrPixelRef::deepCopy(SkBitmap::Config dstConfig, const SkIRect* su // a GrTexture owned elsewhere (e.g., SkGpuDevice), and cannot live // independently of that texture. Texture-backed pixel refs, on the other // hand, own their GrTextures, and are thus self-contained. - return copyToTexturePixelRef(fSurface->asTexture(), dstConfig, subset); + return copyToTexturePixelRef(fSurface->asTexture(), subset); } bool SkGrPixelRef::onReadPixels(SkBitmap* dst, const SkIRect* subset) { |