aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2015-06-09 08:18:39 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-06-09 08:18:40 -0700
commit2c55d7b7f3c2c834085d019bf6b1519b315c8aa1 (patch)
treee8b584e6f7f085132c2333e87b060e65f7f77ca8
parentded9a6f794a43fc9ec7b370559ba0699c061628d (diff)
remove subclassing from ImageFilter::Proxy
-rw-r--r--include/core/SkBitmapDevice.h1
-rw-r--r--include/core/SkDevice.h2
-rw-r--r--include/core/SkImageFilter.h31
-rw-r--r--src/core/SkCanvas.cpp5
-rw-r--r--src/core/SkDeviceImageFilterProxy.h47
-rw-r--r--src/core/SkImageFilter.cpp23
-rw-r--r--src/effects/SkPictureImageFilter.cpp6
-rw-r--r--src/gpu/GrLayerHoister.cpp3
-rw-r--r--src/gpu/SkGpuDevice.cpp3
-rw-r--r--tests/ImageFilterTest.cpp9
10 files changed, 54 insertions, 76 deletions
diff --git a/include/core/SkBitmapDevice.h b/include/core/SkBitmapDevice.h
index 5941016ce3..a2101a2dd9 100644
--- a/include/core/SkBitmapDevice.h
+++ b/include/core/SkBitmapDevice.h
@@ -129,7 +129,6 @@ private:
friend class SkDraw;
friend class SkDrawIter;
friend class SkDeviceFilteredPaint;
- friend class SkDeviceImageFilterProxy;
friend class SkSurface_Raster;
diff --git a/include/core/SkDevice.h b/include/core/SkDevice.h
index de43d1e8b8..3b5d38a6af 100644
--- a/include/core/SkDevice.h
+++ b/include/core/SkDevice.h
@@ -374,7 +374,7 @@ private:
friend class SkDraw;
friend class SkDrawIter;
friend class SkDeviceFilteredPaint;
- friend class SkDeviceImageFilterProxy;
+ friend class SkImageFilter::Proxy;
friend class SkDeferredDevice; // for newSurface
friend class SkNoPixelsBitmapDevice;
diff --git a/include/core/SkImageFilter.h b/include/core/SkImageFilter.h
index 55a504ced2..3508df50ce 100644
--- a/include/core/SkImageFilter.h
+++ b/include/core/SkImageFilter.h
@@ -12,15 +12,15 @@
#include "SkFlattenable.h"
#include "SkMatrix.h"
#include "SkRect.h"
+#include "SkSurfaceProps.h"
#include "SkTemplates.h"
+class GrFragmentProcessor;
+class GrTexture;
+class SkBaseDevice;
class SkBitmap;
class SkColorFilter;
-class SkBaseDevice;
-class SkSurfaceProps;
struct SkIPoint;
-class GrFragmentProcessor;
-class GrTexture;
/**
* Base class for image filters. If one is installed in the paint, then
@@ -75,21 +75,28 @@ public:
private:
SkMatrix fCTM;
SkIRect fClipBounds;
- Cache* fCache;
+ Cache* fCache;
};
class Proxy {
public:
- virtual ~Proxy() {};
-
- virtual SkBaseDevice* createDevice(int width, int height) = 0;
+ Proxy(SkBaseDevice* device, const SkSurfaceProps& props)
+ : fDevice(device)
+ , fProps(props.flags(), kUnknown_SkPixelGeometry)
+ {}
+
+ SkBaseDevice* createDevice(int width, int height);
// returns true if the proxy handled the filter itself. if this returns
// false then the filter's code will be called.
- virtual bool filterImage(const SkImageFilter*, const SkBitmap& src,
- const Context&,
- SkBitmap* result, SkIPoint* offset) = 0;
- virtual const SkSurfaceProps* surfaceProps() const = 0;
+ bool filterImage(const SkImageFilter*, const SkBitmap& src, const SkImageFilter::Context&,
+ SkBitmap* result, SkIPoint* offset);
+ const SkSurfaceProps& surfaceProps() const { return fProps; }
+
+ private:
+ SkBaseDevice* fDevice;
+ const SkSurfaceProps fProps;
};
+
/**
* Request a new (result) image to be created from the src image.
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 26b76df9be..30778fc130 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -9,7 +9,6 @@
#include "SkCanvasPriv.h"
#include "SkBitmapDevice.h"
#include "SkColorFilter.h"
-#include "SkDeviceImageFilterProxy.h"
#include "SkDeviceProperties.h"
#include "SkDraw.h"
#include "SkDrawable.h"
@@ -1245,7 +1244,7 @@ void SkCanvas::internalDrawDevice(SkBaseDevice* srcDev, int x, int y,
SkImageFilter* filter = paint->getImageFilter();
SkIPoint pos = { x - iter.getX(), y - iter.getY() };
if (filter && !dstDev->canHandleImageFilter(filter)) {
- SkDeviceImageFilterProxy proxy(dstDev, fProps);
+ SkImageFilter::Proxy proxy(dstDev, fProps);
SkBitmap dst;
SkIPoint offset = SkIPoint::Make(0, 0);
const SkBitmap& src = srcDev->accessBitmap(false);
@@ -1297,7 +1296,7 @@ void SkCanvas::onDrawSprite(const SkBitmap& bitmap, int x, int y, const SkPaint*
SkImageFilter* filter = paint->getImageFilter();
SkIPoint pos = { x - iter.getX(), y - iter.getY() };
if (filter && !iter.fDevice->canHandleImageFilter(filter)) {
- SkDeviceImageFilterProxy proxy(iter.fDevice, fProps);
+ SkImageFilter::Proxy proxy(iter.fDevice, fProps);
SkBitmap dst;
SkIPoint offset = SkIPoint::Make(0, 0);
SkMatrix matrix = *iter.fMatrix;
diff --git a/src/core/SkDeviceImageFilterProxy.h b/src/core/SkDeviceImageFilterProxy.h
deleted file mode 100644
index 5d0a61eddf..0000000000
--- a/src/core/SkDeviceImageFilterProxy.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2012 The Android Open Source Project
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef SkDeviceImageFilterProxy_DEFINED
-#define SkDeviceImageFilterProxy_DEFINED
-
-#include "SkBitmapDevice.h"
-#include "SkDevice.h"
-#include "SkImageFilter.h"
-#include "SkSurfaceProps.h"
-
-class SkDeviceImageFilterProxy : public SkImageFilter::Proxy {
-public:
- SkDeviceImageFilterProxy(SkBaseDevice* device, const SkSurfaceProps& props)
- : fDevice(device)
- , fProps(props.flags(), kUnknown_SkPixelGeometry)
- {}
-
- SkBaseDevice* createDevice(int w, int h) override {
- SkBaseDevice::CreateInfo cinfo(SkImageInfo::MakeN32Premul(w, h),
- SkBaseDevice::kNever_TileUsage,
- kUnknown_SkPixelGeometry,
- true /*forImageFilter*/);
- SkBaseDevice* dev = fDevice->onCreateDevice(cinfo, NULL);
- if (NULL == dev) {
- dev = SkBitmapDevice::Create(cinfo.fInfo);
- }
- return dev;
- }
- bool filterImage(const SkImageFilter* filter, const SkBitmap& src,
- const SkImageFilter::Context& ctx, SkBitmap* res, SkIPoint* offset) override {
- return fDevice->filterImage(filter, src, ctx, res, offset);
- }
- const SkSurfaceProps* surfaceProps() const override {
- return &fProps;
- }
-
-private:
- SkBaseDevice* fDevice;
- const SkSurfaceProps fProps;
-};
-
-#endif
diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp
index 91b3bc3d4a..f5122040e9 100644
--- a/src/core/SkImageFilter.cpp
+++ b/src/core/SkImageFilter.cpp
@@ -523,3 +523,26 @@ SkImageFilter::Cache* SkImageFilter::Cache::Get() {
void SkImageFilter::PurgeCache() {
cache.get()->purge();
}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+#include "SkBitmapDevice.h"
+
+SkBaseDevice* SkImageFilter::Proxy::createDevice(int w, int h) {
+ SkBaseDevice::CreateInfo cinfo(SkImageInfo::MakeN32Premul(w, h),
+ SkBaseDevice::kNever_TileUsage,
+ kUnknown_SkPixelGeometry,
+ true /*forImageFilter*/);
+ SkBaseDevice* dev = fDevice->onCreateDevice(cinfo, NULL);
+ if (NULL == dev) {
+ dev = SkBitmapDevice::Create(cinfo.fInfo);
+ }
+ return dev;
+}
+
+bool SkImageFilter::Proxy::filterImage(const SkImageFilter* filter, const SkBitmap& src,
+ const SkImageFilter::Context& ctx,
+ SkBitmap* result, SkIPoint* offset) {
+ return fDevice->filterImage(filter, src, ctx, result, offset);
+}
+
diff --git a/src/effects/SkPictureImageFilter.cpp b/src/effects/SkPictureImageFilter.cpp
index baae6f8c67..cb61cdd1b8 100644
--- a/src/effects/SkPictureImageFilter.cpp
+++ b/src/effects/SkPictureImageFilter.cpp
@@ -133,7 +133,7 @@ void SkPictureImageFilter::drawPictureAtDeviceResolution(Proxy* proxy, SkBaseDev
// Pass explicit surface props, as the simplified canvas constructor discards device properties.
// FIXME: switch back to the public constructor (and unfriend) after
// https://code.google.com/p/skia/issues/detail?id=3142 is fixed.
- SkCanvas canvas(device, proxy->surfaceProps(), SkCanvas::kDefault_InitFlags);
+ SkCanvas canvas(device, &proxy->surfaceProps(), SkCanvas::kDefault_InitFlags);
canvas.translate(-SkIntToScalar(deviceBounds.fLeft), -SkIntToScalar(deviceBounds.fTop));
canvas.concat(ctx.ctm());
@@ -156,14 +156,14 @@ void SkPictureImageFilter::drawPictureAtLocalResolution(Proxy* proxy, SkBaseDevi
// Pass explicit surface props, as the simplified canvas constructor discards device properties.
// FIXME: switch back to the public constructor (and unfriend) after
// https://code.google.com/p/skia/issues/detail?id=3142 is fixed.
- SkCanvas localCanvas(localDevice, proxy->surfaceProps(), SkCanvas::kDefault_InitFlags);
+ SkCanvas localCanvas(localDevice, &proxy->surfaceProps(), SkCanvas::kDefault_InitFlags);
localCanvas.translate(-SkIntToScalar(localIBounds.fLeft), -SkIntToScalar(localIBounds.fTop));
localCanvas.drawPicture(fPicture);
// Pass explicit surface props, as the simplified canvas constructor discards device properties.
// FIXME: switch back to the public constructor (and unfriend) after
// https://code.google.com/p/skia/issues/detail?id=3142 is fixed.
- SkCanvas canvas(device, proxy->surfaceProps(), SkCanvas::kDefault_InitFlags);
+ SkCanvas canvas(device, &proxy->surfaceProps(), SkCanvas::kDefault_InitFlags);
canvas.translate(-SkIntToScalar(deviceBounds.fLeft), -SkIntToScalar(deviceBounds.fTop));
canvas.concat(ctx.ctm());
diff --git a/src/gpu/GrLayerHoister.cpp b/src/gpu/GrLayerHoister.cpp
index 67e3c19a2f..5cc5fa3c02 100644
--- a/src/gpu/GrLayerHoister.cpp
+++ b/src/gpu/GrLayerHoister.cpp
@@ -11,7 +11,6 @@
#include "SkBigPicture.h"
#include "SkCanvas.h"
-#include "SkDeviceImageFilterProxy.h"
#include "SkDeviceProperties.h"
#include "SkGpuDevice.h"
#include "SkGrPixelRef.h"
@@ -315,7 +314,7 @@ void GrLayerHoister::FilterLayer(GrContext* context,
SkAutoTUnref<SkImageFilter::Cache> cache(SkImageFilter::Cache::Create(kDefaultCacheSize));
SkImageFilter::Context filterContext(totMat, clipBounds, cache);
- SkDeviceImageFilterProxy proxy(device, SkSurfaceProps(0, kUnknown_SkPixelGeometry));
+ SkImageFilter::Proxy proxy(device, SkSurfaceProps(0, kUnknown_SkPixelGeometry));
const SkBitmap src = wrap_texture(layer->texture());
if (!layer->filter()->filterImage(&proxy, src, filterContext, &filteredBitmap, &offset)) {
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index beed2fab28..8bd5b5ebd5 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -18,7 +18,6 @@
#include "GrTextContext.h"
#include "GrTracing.h"
#include "SkCanvasPriv.h"
-#include "SkDeviceImageFilterProxy.h"
#include "SkDrawProcs.h"
#include "SkErrorInternals.h"
#include "SkGlyphCache.h"
@@ -1243,7 +1242,7 @@ bool SkGpuDevice::filterTexture(GrContext* context, GrTexture* texture,
// FIXME: plumb actual surface props such that we don't have to lie about the flags here
// (https://code.google.com/p/skia/issues/detail?id=3148).
- SkDeviceImageFilterProxy proxy(this, SkSurfaceProps(0, getLeakyProperties().pixelGeometry()));
+ SkImageFilter::Proxy proxy(this, SkSurfaceProps(0, getLeakyProperties().pixelGeometry()));
if (filter->canFilterImageGPU()) {
return filter->filterImageGPU(&proxy, wrap_texture(texture, width, height),
diff --git a/tests/ImageFilterTest.cpp b/tests/ImageFilterTest.cpp
index 0076ac56fb..fc709da5af 100644
--- a/tests/ImageFilterTest.cpp
+++ b/tests/ImageFilterTest.cpp
@@ -13,7 +13,6 @@
#include "SkColorFilterImageFilter.h"
#include "SkColorMatrixFilter.h"
#include "SkComposeImageFilter.h"
-#include "SkDeviceImageFilterProxy.h"
#include "SkDisplacementMapEffect.h"
#include "SkDropShadowImageFilter.h"
#include "SkFlattenableSerialization.h"
@@ -272,7 +271,7 @@ static void test_crop_rects(SkBaseDevice* device, skiatest::Reporter* reporter)
SkBitmap bitmap;
bitmap.allocN32Pixels(100, 100);
bitmap.eraseARGB(0, 0, 0, 0);
- SkDeviceImageFilterProxy proxy(device, SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType));
+ SkImageFilter::Proxy proxy(device, SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType));
SkImageFilter::CropRect inputCropRect(SkRect::MakeXYWH(8, 13, 80, 80));
SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(20, 30, 60, 60));
@@ -352,7 +351,7 @@ static void test_negative_blur_sigma(SkBaseDevice* device, skiatest::Reporter* r
// Check that SkBlurImageFilter will accept a negative sigma, either in
// the given arguments or after CTM application.
int width = 32, height = 32;
- SkDeviceImageFilterProxy proxy(device, SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType));
+ SkImageFilter::Proxy proxy(device, SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType));
SkScalar five = SkIntToScalar(5);
SkAutoTUnref<SkBlurImageFilter> positiveFilter(
@@ -888,7 +887,7 @@ DEF_TEST(ImageFilterClippedPictureImageFilter, reporter) {
SkBitmap bitmap;
bitmap.allocN32Pixels(2, 2);
SkBitmapDevice device(bitmap);
- SkDeviceImageFilterProxy proxy(&device, SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType));
+ SkImageFilter::Proxy proxy(&device, SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType));
REPORTER_ASSERT(reporter, !imageFilter->filterImage(&proxy, bitmap, ctx, &result, &offset));
}
@@ -1131,7 +1130,7 @@ DEF_TEST(ComposedImageFilterOffset, reporter) {
bitmap.allocN32Pixels(100, 100);
bitmap.eraseARGB(0, 0, 0, 0);
SkBitmapDevice device(bitmap);
- SkDeviceImageFilterProxy proxy(&device, SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType));
+ SkImageFilter::Proxy proxy(&device, SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType));
SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(1, 0, 20, 20));
SkAutoTUnref<SkImageFilter> offsetFilter(SkOffsetImageFilter::Create(0, 0, NULL, &cropRect));