Skip to content

Commit

Permalink
Revert "Remove lazy image color space hacks for gray"
Browse files Browse the repository at this point in the history
This reverts commit a81c2be.

Reason for revert: Bad images on gold.

Original change's description:
> Remove lazy image color space hacks for gray
> 
> Change-Id: Idca6c0bb237d7973f84acbd2f0583cc8b6c6292c
> Reviewed-on: https://skia-review.googlesource.com/150241
> Reviewed-by: Mike Klein <mtklein@google.com>
> Commit-Queue: Brian Osman <brianosman@google.com>

TBR=mtklein@google.com,scroggo@google.com,brianosman@google.com

# Not skipping CQ checks because original CL landed > 1 day ago.

Change-Id: I08658c69eb7b0b9adfc36e73fbbd09ff1aad75f6
Reviewed-on: https://skia-review.googlesource.com/150464
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
  • Loading branch information
brianosman committed Aug 30, 2018
1 parent cd7907b commit 7ed0eae
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/core/SkImageCacherator.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class SkImageCacherator {
public:
virtual ~SkImageCacherator() {}

virtual SkImageInfo buildCacheInfo() const = 0;

#if SK_SUPPORT_GPU
// Returns the texture proxy. If the cacherator is generating the texture and wants to cache it,
// it should use the passed in key (if the key is valid).
Expand Down
32 changes: 25 additions & 7 deletions src/image/SkImage_Lazy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ class SkImage_Lazy : public SkImage_Base, public SkImageCacherator {
void makeCacheKeyFromOrigKey(const GrUniqueKey& origKey, GrUniqueKey* cacheKey) override;
#endif

SkImageInfo buildCacheInfo() const override;

private:
class ScopedGenerator;

Expand Down Expand Up @@ -231,6 +233,16 @@ SkImage_Lazy::SkImage_Lazy(Validator* validator)

//////////////////////////////////////////////////////////////////////////////////////////////////

SkImageInfo SkImage_Lazy::buildCacheInfo() const {
if (kGray_8_SkColorType == fInfo.colorType()) {
return fInfo.makeColorSpace(nullptr);
} else {
return fInfo;
}
}

//////////////////////////////////////////////////////////////////////////////////////////////////

static bool check_output_bitmap(const SkBitmap& bitmap, uint32_t expectedID) {
SkASSERT(bitmap.getGenerationID() == expectedID);
SkASSERT(bitmap.isImmutable());
Expand Down Expand Up @@ -372,7 +384,8 @@ sk_sp<SkData> SkImage_Lazy::onRefEncoded() const {

bool SkImage_Lazy::getROPixels(SkBitmap* bitmap, SkColorSpace* dstColorSpace,
CachingHint chint) const {
return this->lockAsBitmap(bitmap, chint, fInfo);
const SkImageInfo cacheInfo = this->buildCacheInfo();
return this->lockAsBitmap(bitmap, chint, cacheInfo);
}

bool SkImage_Lazy::onIsValid(GrContext* context) const {
Expand Down Expand Up @@ -484,11 +497,16 @@ static void set_key_on_proxy(GrProxyProvider* proxyProvider,
sk_sp<SkColorSpace> SkImage_Lazy::getColorSpace(GrContext* ctx, SkColorSpace* dstColorSpace) {
// TODO: Is this ever needed? Is the output of this function going to be:
// return dstColorSpace ? fInfo.refColorSpace() : dstColorSpace;

// In legacy mode, we do no modification to the image's color space or encoding.
// Subsequent legacy drawing is likely to ignore the color space, but some clients
// may want to know what space the image data is in, so return it.
return fInfo.refColorSpace();
// Yes, except for gray?
if (!dstColorSpace) {
// In legacy mode, we do no modification to the image's color space or encoding.
// Subsequent legacy drawing is likely to ignore the color space, but some clients
// may want to know what space the image data is in, so return it.
return fInfo.refColorSpace();
} else {
SkImageInfo cacheInfo = this->buildCacheInfo();
return cacheInfo.refColorSpace();
}
}

/*
Expand Down Expand Up @@ -540,7 +558,7 @@ sk_sp<GrTextureProxy> SkImage_Lazy::lockTextureProxy(GrContext* ctx,

// What format are we going to ask the generator to create?
// TODO: Based on the dstColorSpace?
const SkImageInfo cacheInfo = fInfo;
const SkImageInfo cacheInfo = this->buildCacheInfo();

// 2. Ask the generator to natively create one
if (!proxy) {
Expand Down

0 comments on commit 7ed0eae

Please sign in to comment.