aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar senorblanco <senorblanco@chromium.org>2016-04-21 06:49:15 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-04-21 06:49:15 -0700
commit32eaa8993da28f9ec4f5c4d392265c096086eb91 (patch)
treee7f0dced10e7ba320e3a6fc7a224fae4f09bf84d
parent0b229669dceedc87a39df43039050b8aed36a5ff (diff)
Image filters: remove SkBitmap-based cache.
Also some #include cleanup. TBR=reed@google.com BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1905753002 Review URL: https://codereview.chromium.org/1905753002
-rw-r--r--include/core/SkImageFilter.h5
-rw-r--r--include/effects/SkMatrixConvolutionImageFilter.h2
-rw-r--r--src/core/SkImageFilter.cpp48
3 files changed, 5 insertions, 50 deletions
diff --git a/include/core/SkImageFilter.h b/include/core/SkImageFilter.h
index 43369d364d..a31403fd8c 100644
--- a/include/core/SkImageFilter.h
+++ b/include/core/SkImageFilter.h
@@ -15,13 +15,10 @@
#include "SkFlattenable.h"
#include "SkMatrix.h"
#include "SkRect.h"
-#include "SkSurfaceProps.h"
class GrContext;
class GrFragmentProcessor;
-class GrTexture;
class SkBaseDevice;
-class SkBitmap;
class SkColorFilter;
struct SkIPoint;
class SkSpecialImage;
@@ -43,9 +40,7 @@ public:
virtual ~Cache() {}
static Cache* Create(size_t maxBytes);
static Cache* Get();
- virtual bool get(const Key& key, SkBitmap* result, SkIPoint* offset) const = 0;
virtual SkSpecialImage* get(const Key& key, SkIPoint* offset) const = 0;
- virtual void set(const Key& key, const SkBitmap& result, const SkIPoint& offset) = 0;
virtual void set(const Key& key, SkSpecialImage* image, const SkIPoint& offset) = 0;
virtual void purge() = 0;
virtual void purgeByKeys(const Key[], int) = 0;
diff --git a/include/effects/SkMatrixConvolutionImageFilter.h b/include/effects/SkMatrixConvolutionImageFilter.h
index 6c559675d6..9a45486d88 100644
--- a/include/effects/SkMatrixConvolutionImageFilter.h
+++ b/include/effects/SkMatrixConvolutionImageFilter.h
@@ -13,6 +13,8 @@
#include "SkSize.h"
#include "SkPoint.h"
+class SkBitmap;
+
/*! \class SkMatrixConvolutionImageFilter
Matrix convolution image filter. This filter applies an NxM image
processing kernel to a given input image. This can be used to produce
diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp
index 18fafd9cff..4128ba6cc2 100644
--- a/src/core/SkImageFilter.cpp
+++ b/src/core/SkImageFilter.cpp
@@ -8,8 +8,7 @@
#include "SkImageFilter.h"
#include "SkImageFilterCacheKey.h"
-#include "SkBitmap.h"
-#include "SkBitmapDevice.h"
+#include "SkCanvas.h"
#include "SkChecksum.h"
#include "SkFuzzLogging.h"
#include "SkLocalMatrixImageFilter.h"
@@ -26,8 +25,6 @@
#if SK_SUPPORT_GPU
#include "GrContext.h"
#include "GrDrawContext.h"
-#include "SkGrPixelRef.h"
-#include "SkGr.h"
#endif
#ifdef SK_BUILD_FOR_IOS
@@ -467,13 +464,10 @@ public:
}
}
struct Value {
- Value(const Key& key, const SkBitmap& bitmap, const SkIPoint& offset)
- : fKey(key), fBitmap(bitmap), fOffset(offset) {}
Value(const Key& key, SkSpecialImage* image, const SkIPoint& offset)
: fKey(key), fImage(SkRef(image)), fOffset(offset) {}
Key fKey;
- SkBitmap fBitmap;
SkAutoTUnref<SkSpecialImage> fImage;
SkIPoint fOffset;
static const Key& GetKey(const Value& v) {
@@ -485,20 +479,6 @@ public:
SK_DECLARE_INTERNAL_LLIST_INTERFACE(Value);
};
- bool get(const Key& key, SkBitmap* result, SkIPoint* offset) const override {
- SkAutoMutexAcquire mutex(fMutex);
- if (Value* v = fLookup.find(key)) {
- *result = v->fBitmap;
- *offset = v->fOffset;
- if (v != fLRU.head()) {
- fLRU.remove(v);
- fLRU.addToHead(v);
- }
- return true;
- }
- return false;
- }
-
SkSpecialImage* get(const Key& key, SkIPoint* offset) const override {
SkAutoMutexAcquire mutex(fMutex);
if (Value* v = fLookup.find(key)) {
@@ -512,25 +492,6 @@ public:
return nullptr;
}
- void set(const Key& key, const SkBitmap& result, const SkIPoint& offset) override {
- SkAutoMutexAcquire mutex(fMutex);
- if (Value* v = fLookup.find(key)) {
- this->removeInternal(v);
- }
- Value* v = new Value(key, result, offset);
- fLookup.add(v);
- fLRU.addToHead(v);
- fCurrentBytes += result.getSize();
- while (fCurrentBytes > fMaxBytes) {
- Value* tail = fLRU.tail();
- SkASSERT(tail);
- if (tail == v) {
- break;
- }
- this->removeInternal(tail);
- }
- }
-
void set(const Key& key, SkSpecialImage* image, const SkIPoint& offset) override {
SkAutoMutexAcquire mutex(fMutex);
if (Value* v = fLookup.find(key)) {
@@ -571,11 +532,8 @@ public:
SkDEBUGCODE(int count() const override { return fLookup.count(); })
private:
void removeInternal(Value* v) {
- if (v->fImage) {
- fCurrentBytes -= v->fImage->getSize();
- } else {
- fCurrentBytes -= v->fBitmap.getSize();
- }
+ SkASSERT(v->fImage);
+ fCurrentBytes -= v->fImage->getSize();
fLRU.remove(v);
fLookup.remove(v->fKey);
delete v;