Index: src/effects/SkColorFilterImageFilter.cpp |
diff --git a/src/effects/SkColorFilterImageFilter.cpp b/src/effects/SkColorFilterImageFilter.cpp |
index a93997fabd9eca4d42a8028d533d86ec79e6fee2..6eb66533d90a96846610a9c7674d784b19e34a3e 100644 |
--- a/src/effects/SkColorFilterImageFilter.cpp |
+++ b/src/effects/SkColorFilterImageFilter.cpp |
@@ -6,17 +6,18 @@ |
*/ |
#include "SkColorFilterImageFilter.h" |
- |
+#include "SkBitmap.h" |
#include "SkCanvas.h" |
+#include "SkColorMatrixFilter.h" |
+#include "SkDevice.h" |
#include "SkColorFilter.h" |
#include "SkReadBuffer.h" |
-#include "SkSpecialImage.h" |
-#include "SkSpecialSurface.h" |
+#include "SkTableColorFilter.h" |
#include "SkWriteBuffer.h" |
SkImageFilter* SkColorFilterImageFilter::Create(SkColorFilter* cf, SkImageFilter* input, |
const CropRect* cropRect) { |
- if (!cf) { |
+ if (nullptr == cf) { |
return nullptr; |
} |
@@ -35,10 +36,8 @@ |
} |
SkColorFilterImageFilter::SkColorFilterImageFilter(SkColorFilter* cf, |
- SkImageFilter* input, |
- const CropRect* cropRect) |
- : INHERITED(1, &input, cropRect) |
- , fColorFilter(SkRef(cf)) { |
+ SkImageFilter* input, const CropRect* cropRect) |
+ : INHERITED(1, &input, cropRect), fColorFilter(SkRef(cf)) { |
} |
SkFlattenable* SkColorFilterImageFilter::CreateProc(SkReadBuffer& buffer) { |
@@ -52,46 +51,39 @@ |
buffer.writeFlattenable(fColorFilter.get()); |
} |
-SkSpecialImage* SkColorFilterImageFilter::onFilterImage(SkSpecialImage* source, const Context& ctx, |
- SkIPoint* offset) const { |
- SkIPoint inputOffset = SkIPoint::Make(0, 0); |
- SkAutoTUnref<SkSpecialImage> input(this->filterInput(0, source, ctx, &inputOffset)); |
- if (!input) { |
- return nullptr; |
+bool SkColorFilterImageFilter::onFilterImageDeprecated(Proxy* proxy, const SkBitmap& source, |
+ const Context& ctx, |
+ SkBitmap* result, |
+ SkIPoint* offset) const { |
+ SkBitmap src = source; |
+ SkIPoint srcOffset = SkIPoint::Make(0, 0); |
+ if (!this->filterInputDeprecated(0, proxy, source, ctx, &src, &srcOffset)) { |
+ return false; |
} |
SkIRect bounds; |
- const SkIRect inputBounds = SkIRect::MakeXYWH(inputOffset.fX, inputOffset.fY, |
- input->width(), input->height()); |
- if (!this->applyCropRect(ctx, inputBounds, &bounds)) { |
- return nullptr; |
+ SkIRect srcBounds = src.bounds(); |
+ srcBounds.offset(srcOffset); |
+ if (!this->applyCropRect(ctx, srcBounds, &bounds)) { |
+ return false; |
} |
- SkImageInfo info = SkImageInfo::MakeN32(bounds.width(), bounds.height(), kPremul_SkAlphaType); |
- sk_sp<SkSpecialSurface> surf(source->makeSurface(info)); |
- if (!surf) { |
- return nullptr; |
+ SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds.height())); |
+ if (nullptr == device.get()) { |
+ return false; |
} |
- |
- SkCanvas* canvas = surf->getCanvas(); |
- SkASSERT(canvas); |
- |
- // TODO: it seems like this clear shouldn't be necessary (see skbug.com/5075) |
- canvas->clear(0x0); |
- |
+ SkCanvas canvas(device.get()); |
SkPaint paint; |
paint.setXfermodeMode(SkXfermode::kSrc_Mode); |
paint.setColorFilter(fColorFilter); |
+ canvas.drawBitmap(src, SkIntToScalar(srcOffset.fX - bounds.fLeft), |
+ SkIntToScalar(srcOffset.fY - bounds.fTop), &paint); |
- input->draw(canvas, |
- SkIntToScalar(inputOffset.fX - bounds.fLeft), |
- SkIntToScalar(inputOffset.fY - bounds.fTop), |
- &paint); |
- |
+ *result = device.get()->accessBitmap(false); |
offset->fX = bounds.fLeft; |
offset->fY = bounds.fTop; |
- return surf->makeImageSnapshot().release(); |
+ return true; |
} |
bool SkColorFilterImageFilter::onIsColorFilterNode(SkColorFilter** filter) const { |