aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar ajuma <ajuma@chromium.org>2016-01-12 14:17:30 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-01-12 14:17:30 -0800
commit1554ec0689f3072edac22b6c1afa096bfc4225e4 (patch)
tree41a3cf7f97b317253c5850dc26241b63986e26f7
parent7f9b2e4a45775e8cdd3f98260a66c0c6e1840550 (diff)
Delete SkRectShaderImageFilter
-rw-r--r--gyp/effects.gypi2
-rw-r--r--include/effects/SkRectShaderImageFilter.h52
-rw-r--r--src/effects/SkRectShaderImageFilter.cpp94
-rw-r--r--src/ports/SkGlobalInitialization_chromium.cpp2
-rw-r--r--src/ports/SkGlobalInitialization_default.cpp2
-rw-r--r--tests/ShaderImageFilterTest.cpp61
6 files changed, 0 insertions, 213 deletions
diff --git a/gyp/effects.gypi b/gyp/effects.gypi
index 0e5083ae40..fd1710cee1 100644
--- a/gyp/effects.gypi
+++ b/gyp/effects.gypi
@@ -58,7 +58,6 @@
'<(skia_src_path)/effects/SkPerlinNoiseShader.cpp',
'<(skia_src_path)/effects/SkPictureImageFilter.cpp',
'<(skia_src_path)/effects/SkPixelXorXfermode.cpp',
- '<(skia_src_path)/effects/SkRectShaderImageFilter.cpp',
'<(skia_src_path)/effects/SkTableColorFilter.cpp',
'<(skia_src_path)/effects/SkTableMaskFilter.cpp',
'<(skia_src_path)/effects/SkTestImageFilters.cpp',
@@ -114,7 +113,6 @@
'<(skia_include_path)/effects/SkPaintImageFilter.h',
'<(skia_include_path)/effects/SkPerlinNoiseShader.h',
'<(skia_include_path)/effects/SkPixelXorXfermode.h',
- '<(skia_include_path)/effects/SkRectShaderImageFilter.h',
'<(skia_include_path)/effects/SkTableColorFilter.h',
'<(skia_include_path)/effects/SkTableMaskFilter.h',
'<(skia_include_path)/effects/SkTileImageFilter.h',
diff --git a/include/effects/SkRectShaderImageFilter.h b/include/effects/SkRectShaderImageFilter.h
deleted file mode 100644
index 9ac116ae5f..0000000000
--- a/include/effects/SkRectShaderImageFilter.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2013 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef SkRectShaderImageFilter_DEFINED
-#define SkRectShaderImageFilter_DEFINED
-
-#include "SkImageFilter.h"
-#include "SkRect.h"
-
-class SkShader;
-
-class SK_API SkRectShaderImageFilter : public SkImageFilter {
-public:
- /** Create a new image filter which fills the given rectangle with pixels
- * produced by the given SkShader. If no rectangle is specified, an output
- * is produced with the same bounds as the input primitive (even though
- * the input primitive's pixels are not used for processing).
- * @param s Shader to call for processing. Cannot be NULL. Will be
- * ref'ed by the new image filter.
- * @param rect Rectangle of output pixels in which to apply the shader.
- * If NULL or a given crop edge is not specified, the source
- * primitive's bounds are used instead.
- */
- SK_ATTR_DEPRECATED("use Create(SkShader*, const CropRect*)")
- static SkImageFilter* Create(SkShader* s, const SkRect& rect);
- static SkImageFilter* Create(SkShader* s, const CropRect* rect = NULL);
-
- bool canComputeFastBounds() const override;
-
- SK_TO_STRING_OVERRIDE()
- SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkRectShaderImageFilter)
-
-protected:
- virtual ~SkRectShaderImageFilter();
-
- void flatten(SkWriteBuffer&) const override;
- bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, SkBitmap* result,
- SkIPoint* loc) const override;
-
-private:
- SkRectShaderImageFilter(SkShader* s, const CropRect* rect);
-
- SkShader* fShader;
-
- typedef SkImageFilter INHERITED;
-};
-
-#endif
diff --git a/src/effects/SkRectShaderImageFilter.cpp b/src/effects/SkRectShaderImageFilter.cpp
deleted file mode 100644
index b3cdd896f1..0000000000
--- a/src/effects/SkRectShaderImageFilter.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright 2013 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "SkRectShaderImageFilter.h"
-#include "SkBitmap.h"
-#include "SkCanvas.h"
-#include "SkDevice.h"
-#include "SkReadBuffer.h"
-#include "SkWriteBuffer.h"
-#include "SkShader.h"
-
-SkImageFilter* SkRectShaderImageFilter::Create(SkShader* s, const SkRect& rect) {
- SkASSERT(s);
- uint32_t flags = CropRect::kHasAll_CropEdge;
- if (rect.width() == 0 || rect.height() == 0) {
- flags = 0x0;
- }
- CropRect cropRect(rect, flags);
- return s ? new SkRectShaderImageFilter(s, &cropRect) : nullptr;
-}
-
-SkImageFilter* SkRectShaderImageFilter::Create(SkShader* s, const CropRect* cropRect) {
- SkASSERT(s);
- return s ? new SkRectShaderImageFilter(s, cropRect) : nullptr;
-}
-
-SkRectShaderImageFilter::SkRectShaderImageFilter(SkShader* s, const CropRect* cropRect)
- : INHERITED(0, nullptr, cropRect)
- , fShader(SkRef(s)) {
-}
-
-SkFlattenable* SkRectShaderImageFilter::CreateProc(SkReadBuffer& buffer) {
- SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 0);
- SkAutoTUnref<SkShader> shader(buffer.readShader());
- return Create(shader.get(), &common.cropRect());
-}
-
-void SkRectShaderImageFilter::flatten(SkWriteBuffer& buffer) const {
- this->INHERITED::flatten(buffer);
- buffer.writeFlattenable(fShader);
-}
-
-SkRectShaderImageFilter::~SkRectShaderImageFilter() {
- fShader->unref();
-}
-
-bool SkRectShaderImageFilter::onFilterImage(Proxy* proxy,
- const SkBitmap& source,
- const Context& ctx,
- SkBitmap* result,
- SkIPoint* offset) const {
- SkIRect bounds;
- if (!this->applyCropRect(ctx, source, SkIPoint::Make(0, 0), &bounds)) {
- return false;
- }
-
- SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(),
- bounds.height()));
- if (nullptr == device.get()) {
- return false;
- }
- SkCanvas canvas(device.get());
-
- SkPaint paint;
- SkMatrix matrix(ctx.ctm());
- matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top()));
- SkSafeUnref(paint.setShader(fShader->newWithLocalMatrix(matrix)));
-
- SkRect rect = SkRect::MakeWH(SkIntToScalar(bounds.width()), SkIntToScalar(bounds.height()));
- canvas.drawRect(rect, paint);
-
- *result = device.get()->accessBitmap(false);
- offset->fX = bounds.fLeft;
- offset->fY = bounds.fTop;
- return true;
-}
-
-bool SkRectShaderImageFilter::canComputeFastBounds() const {
- // http:skbug.com/4627: "make computeFastBounds and onFilterBounds() CropRect-aware"
- // computeFastBounds() doesn't currently take the crop rect into account,
- // so we can't compute it. If a full crop rect is set, we should return true here.
- return false;
-}
-
-#ifndef SK_IGNORE_TO_STRING
-void SkRectShaderImageFilter::toString(SkString* str) const {
- str->appendf("SkRectShaderImageFilter: (");
- str->append(")");
-}
-#endif
diff --git a/src/ports/SkGlobalInitialization_chromium.cpp b/src/ports/SkGlobalInitialization_chromium.cpp
index 2c590c4c70..0a592e3b92 100644
--- a/src/ports/SkGlobalInitialization_chromium.cpp
+++ b/src/ports/SkGlobalInitialization_chromium.cpp
@@ -59,7 +59,6 @@
#include "SkPictureImageFilter.h"
#include "SkPictureShader.h"
#include "SkPixelXorXfermode.h"
-#include "SkRectShaderImageFilter.h"
#include "SkTableColorFilter.h"
#include "SkTestImageFilters.h"
#include "SkTileImageFilter.h"
@@ -121,7 +120,6 @@ public:
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkPictureImageFilter)
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkPictureShader)
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkPixelXorXfermode)
- SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkRectShaderImageFilter)
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSumPathEffect)
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkTileImageFilter)
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkMatrixImageFilter)
diff --git a/src/ports/SkGlobalInitialization_default.cpp b/src/ports/SkGlobalInitialization_default.cpp
index d73476624d..337f8b9e67 100644
--- a/src/ports/SkGlobalInitialization_default.cpp
+++ b/src/ports/SkGlobalInitialization_default.cpp
@@ -55,7 +55,6 @@
#include "SkPictureImageFilter.h"
#include "SkPictureShader.h"
#include "SkPixelXorXfermode.h"
-#include "SkRectShaderImageFilter.h"
#include "SkTableColorFilter.h"
#include "SkTestImageFilters.h"
#include "SkTileImageFilter.h"
@@ -100,7 +99,6 @@ public:
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkPictureImageFilter)
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkPictureShader)
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkPixelXorXfermode)
- SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkRectShaderImageFilter)
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSumPathEffect)
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkTileImageFilter)
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkMatrixImageFilter)
diff --git a/tests/ShaderImageFilterTest.cpp b/tests/ShaderImageFilterTest.cpp
deleted file mode 100644
index 45fb5ca9a1..0000000000
--- a/tests/ShaderImageFilterTest.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright 2011 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "SkCanvas.h"
-#include "SkGradientShader.h"
-#include "SkRectShaderImageFilter.h"
-#include "SkShader.h"
-#include "Test.h"
-
-DEF_TEST(ShaderImageFilter, reporter) {
- int w = 10, h = 10;
- SkRect r = SkRect::MakeWH(SkIntToScalar(w), SkIntToScalar(h)); // Make small 10x10 gradient
-
- SkBitmap filterResult, shaderResult;
-
- filterResult.allocN32Pixels(w, h);
- SkCanvas canvasFilter(filterResult);
- canvasFilter.clear(0x00000000);
-
- shaderResult.allocN32Pixels(w, h);
- SkCanvas canvasShader(shaderResult);
- canvasShader.clear(0x00000000);
-
- SkPoint center = SkPoint::Make(SkIntToScalar(5), SkIntToScalar(5));
- SkColor colors[] = {SK_ColorBLUE, SK_ColorRED, SK_ColorGREEN};
- SkScalar pos[] = {0, SK_ScalarHalf, SK_Scalar1};
- SkScalar radius = SkIntToScalar(5);
-
- // Test using the image filter
- {
- SkShader* s = SkGradientShader::CreateRadial(
- center, radius, colors, pos, SK_ARRAY_COUNT(colors), SkShader::kClamp_TileMode);
- SkPaint paint;
- SkImageFilter::CropRect cr(r);
- paint.setImageFilter(SkRectShaderImageFilter::Create(s, &cr))->unref();
- canvasFilter.drawRect(r, paint);
- s->unref();
- }
-
- // Test using the shader directly
- {
- SkShader* s = SkGradientShader::CreateRadial(
- center, radius, colors, pos, SK_ARRAY_COUNT(colors), SkShader::kClamp_TileMode);
- SkPaint paint;
- paint.setShader(s)->unref();
- canvasShader.drawRect(r, paint);
- }
-
- // Assert that both paths yielded the same result
- for (int y = 0; y < r.height(); ++y) {
- const SkPMColor* filterPtr = filterResult.getAddr32(0, y);
- const SkPMColor* shaderPtr = shaderResult.getAddr32(0, y);
- for (int x = 0; x < r.width(); ++x, ++filterPtr, ++shaderPtr) {
- REPORTER_ASSERT(reporter, *filterPtr == *shaderPtr);
- }
- }
-}