aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrian Osman <brianosman@google.com>2018-10-22 16:10:44 -0400
committerSkia Commit-Bot <skia-commit-bot@chromium.org>2018-10-23 14:28:12 +0000
commitb70fd9168111a9cc090a766ec68a8e7595cfb738 (patch)
tree167ba6836d8bf63b1671118e89029f81e47419d3 /src
parentf84ded269e7ab95d165b3231bc35498afc1b1fe7 (diff)
downloadskqp-b70fd9168111a9cc090a766ec68a8e7595cfb738.tar.gz
Remove colorType and colorSpace from bitmap cache key, and IWYU
Bug: skia: Change-Id: Ie72cb729af48f4ee2c8d5624b114f3b521dc1059 Reviewed-on: https://skia-review.googlesource.com/c/164041 Commit-Queue: Brian Osman <brianosman@google.com> Reviewed-by: Mike Klein <mtklein@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/core/SkBitmapCache.cpp15
-rw-r--r--src/core/SkBitmapCache.h15
-rw-r--r--src/core/SkSpecialImage.cpp3
-rw-r--r--src/image/SkImage.cpp1
-rw-r--r--src/image/SkImage_Lazy.cpp2
-rw-r--r--src/image/SkImage_Lazy.h1
-rw-r--r--src/shaders/SkImageShader.cpp9
7 files changed, 17 insertions, 29 deletions
diff --git a/src/core/SkBitmapCache.cpp b/src/core/SkBitmapCache.cpp
index 7c1e2ac78c..e8cdead1fc 100644
--- a/src/core/SkBitmapCache.cpp
+++ b/src/core/SkBitmapCache.cpp
@@ -28,20 +28,15 @@ void SkNotifyBitmapGenIDIsStale(uint32_t bitmapGenID) {
///////////////////////////////////////////////////////////////////////////////////////////////////
-SkBitmapCacheDesc SkBitmapCacheDesc::Make(uint32_t imageID, SkColorType colorType,
- SkColorSpace* colorSpace, const SkIRect& subset) {
+SkBitmapCacheDesc SkBitmapCacheDesc::Make(uint32_t imageID, const SkIRect& subset) {
SkASSERT(imageID);
SkASSERT(subset.width() > 0 && subset.height() > 0);
- return { imageID,
- colorType,
- colorSpace ? colorSpace->toXYZD50Hash() : 0,
- colorSpace ? colorSpace->transferFnHash() : 0,
- subset };
+ return { imageID, subset };
}
SkBitmapCacheDesc SkBitmapCacheDesc::Make(const SkImage* image) {
SkIRect bounds = SkIRect::MakeWH(image->width(), image->height());
- return Make(image->uniqueID(), image->colorType(), image->colorSpace(), bounds);
+ return Make(image->uniqueID(), bounds);
}
namespace {
@@ -226,10 +221,6 @@ SkBitmapCache::RecPtr SkBitmapCache::Alloc(const SkBitmapCacheDesc& desc, const
// Ensure that the info matches the subset (i.e. the subset is the entire image)
SkASSERT(info.width() == desc.fSubset.width());
SkASSERT(info.height() == desc.fSubset.height());
- SkASSERT(info.colorType() == desc.fColorType);
- SkASSERT((info.colorSpace() ? info.colorSpace()->toXYZD50Hash() : 0) == desc.fCSXYZHash);
- SkASSERT((info.colorSpace() ? info.colorSpace()->transferFnHash() : 0) ==
- desc.fCSTransferFnHash);
const size_t rb = info.minRowBytes();
size_t size = info.computeByteSize(rb);
diff --git a/src/core/SkBitmapCache.h b/src/core/SkBitmapCache.h
index de8dd0f30e..f1984e65b8 100644
--- a/src/core/SkBitmapCache.h
+++ b/src/core/SkBitmapCache.h
@@ -8,11 +8,15 @@
#ifndef SkBitmapCache_DEFINED
#define SkBitmapCache_DEFINED
-#include "SkBitmap.h"
-#include "SkMipMap.h"
+#include "SkRect.h"
+#include <memory>
+class SkBitmap;
class SkBitmapProvider;
class SkImage;
+struct SkImageInfo;
+class SkMipMap;
+class SkPixmap;
class SkResourceCache;
uint64_t SkMakeResourceCacheSharedIDForBitmap(uint32_t bitmapGenID);
@@ -21,21 +25,16 @@ void SkNotifyBitmapGenIDIsStale(uint32_t bitmapGenID);
struct SkBitmapCacheDesc {
uint32_t fImageID; // != 0
- SkColorType fColorType;
- uint32_t fCSXYZHash;
- uint32_t fCSTransferFnHash;
SkIRect fSubset; // always set to a valid rect (entire or subset)
void validate() const {
SkASSERT(fImageID);
SkASSERT(fSubset.fLeft >= 0 && fSubset.fTop >= 0);
SkASSERT(fSubset.width() > 0 && fSubset.height() > 0);
- SkASSERT(kUnknown_SkColorType != fColorType);
}
static SkBitmapCacheDesc Make(const SkImage*);
- static SkBitmapCacheDesc Make(uint32_t genID, SkColorType, SkColorSpace*,
- const SkIRect& subset);
+ static SkBitmapCacheDesc Make(uint32_t genID, const SkIRect& subset);
};
class SkBitmapCache {
diff --git a/src/core/SkSpecialImage.cpp b/src/core/SkSpecialImage.cpp
index 4b1be8ebd4..4309b80088 100644
--- a/src/core/SkSpecialImage.cpp
+++ b/src/core/SkSpecialImage.cpp
@@ -394,8 +394,7 @@ public:
}
bool onGetROPixels(SkBitmap* dst) const override {
- const auto desc = SkBitmapCacheDesc::Make(this->uniqueID(), kN32_SkColorType,
- fColorSpace.get(), this->subset());
+ const auto desc = SkBitmapCacheDesc::Make(this->uniqueID(), this->subset());
if (SkBitmapCache::Find(desc, dst)) {
SkASSERT(dst->getGenerationID() == this->uniqueID());
SkASSERT(dst->isImmutable());
diff --git a/src/image/SkImage.cpp b/src/image/SkImage.cpp
index 9652aab22d..5825fd91ca 100644
--- a/src/image/SkImage.cpp
+++ b/src/image/SkImage.cpp
@@ -7,6 +7,7 @@
#include "SkBitmap.h"
#include "SkBitmapCache.h"
+#include "SkCachedData.h"
#include "SkCanvas.h"
#include "SkColorSpacePriv.h"
#include "SkData.h"
diff --git a/src/image/SkImage_Lazy.cpp b/src/image/SkImage_Lazy.cpp
index fa88db1ba9..2107251687 100644
--- a/src/image/SkImage_Lazy.cpp
+++ b/src/image/SkImage_Lazy.cpp
@@ -9,6 +9,7 @@
#include "SkBitmap.h"
#include "SkBitmapCache.h"
+#include "SkCachedData.h"
#include "SkData.h"
#include "SkImageGenerator.h"
#include "SkImagePriv.h"
@@ -282,7 +283,6 @@ sk_sp<SkImage> SkImage::MakeFromGenerator(std::unique_ptr<SkImageGenerator> gene
void SkImage_Lazy::makeCacheKeyFromOrigKey(const GrUniqueKey& origKey,
GrUniqueKey* cacheKey) const {
- // TODO: Take dstColorSpace, include hash in key
SkASSERT(!cacheKey->isValid());
if (origKey.isValid()) {
static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain();
diff --git a/src/image/SkImage_Lazy.h b/src/image/SkImage_Lazy.h
index 780098aacb..bfba3b15cf 100644
--- a/src/image/SkImage_Lazy.h
+++ b/src/image/SkImage_Lazy.h
@@ -69,7 +69,6 @@ public:
bool willBeMipped,
GrTextureMaker::AllowedTexGenType genType) const;
- // TODO: Need to pass in dstColorSpace to fold into key here?
void makeCacheKeyFromOrigKey(const GrUniqueKey& origKey, GrUniqueKey* cacheKey) const;
#endif
diff --git a/src/shaders/SkImageShader.cpp b/src/shaders/SkImageShader.cpp
index 07b837ec63..83138069b6 100644
--- a/src/shaders/SkImageShader.cpp
+++ b/src/shaders/SkImageShader.cpp
@@ -100,6 +100,9 @@ SkShaderBase::Context* SkImageShader::onMakeContext(const ContextRec& rec,
if (fImage->alphaType() == kUnpremul_SkAlphaType) {
return nullptr;
}
+ if (fImage->colorType() != kN32_SkColorType) {
+ return nullptr;
+ }
if (fTileModeX != fTileModeY) {
return nullptr;
}
@@ -113,12 +116,8 @@ SkShaderBase::Context* SkImageShader::onMakeContext(const ContextRec& rec,
return nullptr;
}
- SkBitmapProvider provider(fImage.get());
- if (kN32_SkColorType != provider.makeCacheDesc().fColorType) {
- return nullptr;
- }
return SkBitmapProcLegacyShader::MakeContext(*this, fTileModeX, fTileModeY,
- provider, rec, alloc);
+ SkBitmapProvider(fImage.get()), rec, alloc);
}
#endif