Revert of eliminate config param -- it was always self's config (https://codereview.chromium.org/246513002/)
Reason for revert: Causes some layout_test failures around texture backed bitmaps. Test names and crash logs accessible via: https://storage.googleapis.com/chromium-layout-test-archives/linux_layout/13845/layout-test-results/results.html Original issue's description: > eliminate config param -- it was always self's config > > BUG=skia: > R=bsalomon@google.com > > Committed: https://code.google.com/p/skia/source/detail?r=14303 R=reed@google.com TBR=reed@google.com NOTREECHECKS=true NOTRY=true BUG=skia: Author: bsalomon@google.com Review URL: https://codereview.chromium.org/249373003 git-svn-id: http://skia.googlecode.com/svn/trunk@14324 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
bc2f1dc85e
commit
6e332f768f
@ -223,13 +223,14 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes a deep copy of this PixelRef, respecting the requested config.
|
* 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
|
* @param subset Subset of this PixelRef to copy. Must be fully contained within the bounds of
|
||||||
* of this PixelRef.
|
* of this PixelRef.
|
||||||
* @return A new SkPixelRef, or NULL if either there is an error (e.g. the destination could
|
* @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
|
* not be created with the given config), or this PixelRef does not support deep
|
||||||
* copies.
|
* copies.
|
||||||
*/
|
*/
|
||||||
virtual SkPixelRef* deepCopy(const SkIRect* subset = NULL) {
|
virtual SkPixelRef* deepCopy(SkBitmap::Config config, const SkIRect* subset = NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
// overrides from SkPixelRef
|
// overrides from SkPixelRef
|
||||||
virtual bool onReadPixels(SkBitmap* dst, const SkIRect* subset) SK_OVERRIDE;
|
virtual bool onReadPixels(SkBitmap* dst, const SkIRect* subset) SK_OVERRIDE;
|
||||||
virtual SkPixelRef* deepCopy(const SkIRect* subset) SK_OVERRIDE;
|
virtual SkPixelRef* deepCopy(SkBitmap::Config dstConfig, const SkIRect* subset) SK_OVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GrSurface* fSurface;
|
GrSurface* fSurface;
|
||||||
|
@ -946,7 +946,7 @@ bool SkBitmap::extractSubset(SkBitmap* result, const SkIRect& subset) const {
|
|||||||
|
|
||||||
if (fPixelRef->getTexture() != NULL) {
|
if (fPixelRef->getTexture() != NULL) {
|
||||||
// Do a deep copy
|
// Do a deep copy
|
||||||
SkPixelRef* pixelRef = fPixelRef->deepCopy(&subset);
|
SkPixelRef* pixelRef = fPixelRef->deepCopy(this->config(), &subset);
|
||||||
if (pixelRef != NULL) {
|
if (pixelRef != NULL) {
|
||||||
SkBitmap dst;
|
SkBitmap dst;
|
||||||
dst.setConfig(this->config(), subset.width(), subset.height(), 0,
|
dst.setConfig(this->config(), subset.width(), subset.height(), 0,
|
||||||
@ -1146,7 +1146,8 @@ bool SkBitmap::copyTo(SkBitmap* dst, SkColorType dstColorType,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool SkBitmap::deepCopyTo(SkBitmap* dst) const {
|
bool SkBitmap::deepCopyTo(SkBitmap* dst) const {
|
||||||
const SkColorType dstCT = this->colorType();
|
const SkBitmap::Config dstConfig = this->config();
|
||||||
|
const SkColorType dstCT = SkBitmapConfigToColorType(dstConfig);
|
||||||
|
|
||||||
if (!this->canCopyTo(dstCT)) {
|
if (!this->canCopyTo(dstCT)) {
|
||||||
return false;
|
return false;
|
||||||
@ -1155,15 +1156,24 @@ bool SkBitmap::deepCopyTo(SkBitmap* dst) const {
|
|||||||
// If we have a PixelRef, and it supports deep copy, use it.
|
// If we have a PixelRef, and it supports deep copy, use it.
|
||||||
// Currently supported only by texture-backed bitmaps.
|
// Currently supported only by texture-backed bitmaps.
|
||||||
if (fPixelRef) {
|
if (fPixelRef) {
|
||||||
SkPixelRef* pixelRef = fPixelRef->deepCopy();
|
SkPixelRef* pixelRef = fPixelRef->deepCopy(dstConfig);
|
||||||
if (pixelRef) {
|
if (pixelRef) {
|
||||||
// Since there is no subset to pass to deepCopy, and deepCopy
|
uint32_t rowBytes;
|
||||||
// succeeded, the new pixel ref must be identical.
|
if (this->colorType() == dstCT) {
|
||||||
SkASSERT(fPixelRef->info() == pixelRef->info());
|
// Since there is no subset to pass to deepCopy, and deepCopy
|
||||||
pixelRef->cloneGenID(*fPixelRef);
|
// 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;
|
||||||
|
}
|
||||||
|
|
||||||
SkImageInfo info = fInfo;
|
SkImageInfo info = fInfo;
|
||||||
if (!dst->setConfig(info, fRowBytes)) {
|
info.fColorType = dstCT;
|
||||||
|
if (!dst->setConfig(info, rowBytes)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
dst->setPixelRef(pixelRef, fPixelRefOrigin)->unref();
|
dst->setPixelRef(pixelRef, fPixelRefOrigin)->unref();
|
||||||
|
@ -51,7 +51,8 @@ bool SkROLockPixelsPixelRef::onLockPixelsAreWritable() const {
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
static SkGrPixelRef* copyToTexturePixelRef(GrTexture* texture, const SkIRect* subset) {
|
static SkGrPixelRef* copyToTexturePixelRef(GrTexture* texture, SkBitmap::Config dstConfig,
|
||||||
|
const SkIRect* subset) {
|
||||||
if (NULL == texture) {
|
if (NULL == texture) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -76,7 +77,7 @@ static SkGrPixelRef* copyToTexturePixelRef(GrTexture* texture, const SkIRect* su
|
|||||||
topLeft = NULL;
|
topLeft = NULL;
|
||||||
}
|
}
|
||||||
desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit;
|
desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit;
|
||||||
desc.fConfig = texture->config();
|
desc.fConfig = SkBitmapConfig2GrPixelConfig(dstConfig);
|
||||||
|
|
||||||
SkImageInfo info;
|
SkImageInfo info;
|
||||||
if (!GrPixelConfig2ColorType(desc.fConfig, &info.fColorType)) {
|
if (!GrPixelConfig2ColorType(desc.fConfig, &info.fColorType)) {
|
||||||
@ -151,7 +152,7 @@ GrTexture* SkGrPixelRef::getTexture() {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SkPixelRef* SkGrPixelRef::deepCopy(const SkIRect* subset) {
|
SkPixelRef* SkGrPixelRef::deepCopy(SkBitmap::Config dstConfig, const SkIRect* subset) {
|
||||||
if (NULL == fSurface) {
|
if (NULL == fSurface) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -162,7 +163,7 @@ SkPixelRef* SkGrPixelRef::deepCopy(const SkIRect* subset) {
|
|||||||
// a GrTexture owned elsewhere (e.g., SkGpuDevice), and cannot live
|
// a GrTexture owned elsewhere (e.g., SkGpuDevice), and cannot live
|
||||||
// independently of that texture. Texture-backed pixel refs, on the other
|
// independently of that texture. Texture-backed pixel refs, on the other
|
||||||
// hand, own their GrTextures, and are thus self-contained.
|
// hand, own their GrTextures, and are thus self-contained.
|
||||||
return copyToTexturePixelRef(fSurface->asTexture(), subset);
|
return copyToTexturePixelRef(fSurface->asTexture(), dstConfig, subset);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SkGrPixelRef::onReadPixels(SkBitmap* dst, const SkIRect* subset) {
|
bool SkGrPixelRef::onReadPixels(SkBitmap* dst, const SkIRect* subset) {
|
||||||
|
Loading…
Reference in New Issue
Block a user