From bf2768bab9f3b21c03a8f9a75dc891231d5857cc Mon Sep 17 00:00:00 2001 From: "senorblanco@chromium.org" Date: Mon, 20 Aug 2012 15:43:14 +0000 Subject: [PATCH] Refactor SkImageFilter into its own .cpp file. Review URL: https://codereview.appspot.com/6465073/ git-svn-id: http://skia.googlecode.com/svn/trunk@5188 2bbb7eff-a529-9590-31e7-b0007b416f81 --- gyp/core.gypi | 2 ++ include/core/SkImageFilter.h | 2 -- include/effects/SkBlurImageFilter.h | 1 + include/effects/SkMorphologyImageFilter.h | 1 + src/core/SkImageFilter.cpp | 54 +++++++++++++++++++++++++++++++ src/core/SkPaint.cpp | 47 --------------------------- 6 files changed, 58 insertions(+), 49 deletions(-) create mode 100644 src/core/SkImageFilter.cpp diff --git a/gyp/core.gypi b/gyp/core.gypi index 2f44ca0..3a36987 100644 --- a/gyp/core.gypi +++ b/gyp/core.gypi @@ -86,6 +86,7 @@ '<(skia_src_path)/core/SkGlyphCache.h', '<(skia_src_path)/core/SkGraphics.cpp', '<(skia_src_path)/core/SkInstCnt.cpp', + '<(skia_src_path)/core/SkImageFilter.cpp', '<(skia_src_path)/core/SkLineClipper.cpp', '<(skia_src_path)/core/SkMallocPixelRef.cpp', '<(skia_src_path)/core/SkMask.cpp', @@ -191,6 +192,7 @@ '<(skia_include_path)/core/SkFontHost.h', '<(skia_include_path)/core/SkGeometry.h', '<(skia_include_path)/core/SkGraphics.h', + '<(skia_include_path)/core/SkImageFilter.h', '<(skia_include_path)/core/SkInstCnt.h', '<(skia_include_path)/core/SkMallocPixelRef.h', '<(skia_include_path)/core/SkMask.h', diff --git a/include/core/SkImageFilter.h b/include/core/SkImageFilter.h index 1c0a051..e4705c4 100644 --- a/include/core/SkImageFilter.h +++ b/include/core/SkImageFilter.h @@ -9,14 +9,12 @@ #define SkImageFilter_DEFINED #include "SkFlattenable.h" -#include "SkSize.h" class SkBitmap; class SkDevice; class SkMatrix; struct SkIPoint; struct SkIRect; -struct SkPoint; struct SkRect; class GrCustomStage; class GrTexture; diff --git a/include/effects/SkBlurImageFilter.h b/include/effects/SkBlurImageFilter.h index 82828f6..9e86f7a 100644 --- a/include/effects/SkBlurImageFilter.h +++ b/include/effects/SkBlurImageFilter.h @@ -10,6 +10,7 @@ #define SkBlurImageFilter_DEFINED #include "SkSingleInputImageFilter.h" +#include "SkSize.h" class SK_API SkBlurImageFilter : public SkSingleInputImageFilter { public: diff --git a/include/effects/SkMorphologyImageFilter.h b/include/effects/SkMorphologyImageFilter.h index 706b62f..f4f96e1 100644 --- a/include/effects/SkMorphologyImageFilter.h +++ b/include/effects/SkMorphologyImageFilter.h @@ -10,6 +10,7 @@ #define SkMorphologyImageFilter_DEFINED #include "SkSingleInputImageFilter.h" +#include "SkSize.h" class SK_API SkMorphologyImageFilter : public SkSingleInputImageFilter { public: diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp new file mode 100644 index 0000000..21582bd --- /dev/null +++ b/src/core/SkImageFilter.cpp @@ -0,0 +1,54 @@ +/* + * 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. + */ + +#include "SkImageFilter.h" +#include "SkRect.h" + +SK_DEFINE_INST_COUNT(SkImageFilter) + +bool SkImageFilter::filterImage(Proxy* proxy, const SkBitmap& src, + const SkMatrix& ctm, + SkBitmap* result, SkIPoint* loc) { + SkASSERT(result); + SkASSERT(loc); + /* + * Give the proxy first shot at the filter. If it returns false, ask + * the filter to do it. + */ + return (proxy && proxy->filterImage(this, src, ctm, result, loc)) || + this->onFilterImage(proxy, src, ctm, result, loc); +} + +bool SkImageFilter::filterBounds(const SkIRect& src, const SkMatrix& ctm, + SkIRect* dst) { + SkASSERT(&src); + SkASSERT(dst); + return this->onFilterBounds(src, ctm, dst); +} + +bool SkImageFilter::onFilterImage(Proxy*, const SkBitmap&, const SkMatrix&, + SkBitmap*, SkIPoint*) { + return false; +} + +bool SkImageFilter::canFilterImageGPU() const { + return false; +} + +GrTexture* SkImageFilter::onFilterImageGPU(GrTexture* texture, const SkRect& rect) { + return NULL; +} + +bool SkImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm, + SkIRect* dst) { + *dst = src; + return true; +} + +bool SkImageFilter::asNewCustomStage(GrCustomStage**, GrTexture*) const { + return false; +} diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp index 0f1aecf..06058ab 100644 --- a/src/core/SkPaint.cpp +++ b/src/core/SkPaint.cpp @@ -2304,53 +2304,6 @@ bool SkPaint::nothingToDraw() const { //////////// Move these to their own file soon. -SK_DEFINE_INST_COUNT(SkImageFilter) - -bool SkImageFilter::filterImage(Proxy* proxy, const SkBitmap& src, - const SkMatrix& ctm, - SkBitmap* result, SkIPoint* loc) { - SkASSERT(result); - SkASSERT(loc); - /* - * Give the proxy first shot at the filter. If it returns false, ask - * the filter to do it. - */ - return (proxy && proxy->filterImage(this, src, ctm, result, loc)) || - this->onFilterImage(proxy, src, ctm, result, loc); -} - -bool SkImageFilter::filterBounds(const SkIRect& src, const SkMatrix& ctm, - SkIRect* dst) { - SkASSERT(&src); - SkASSERT(dst); - return this->onFilterBounds(src, ctm, dst); -} - -bool SkImageFilter::onFilterImage(Proxy*, const SkBitmap&, const SkMatrix&, - SkBitmap*, SkIPoint*) { - return false; -} - -bool SkImageFilter::canFilterImageGPU() const { - return false; -} - -GrTexture* SkImageFilter::onFilterImageGPU(GrTexture* texture, const SkRect& rect) { - return NULL; -} - -bool SkImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm, - SkIRect* dst) { - *dst = src; - return true; -} - -bool SkImageFilter::asNewCustomStage(GrCustomStage**, GrTexture*) const { - return false; -} - -//////////////////// - SK_DEFINE_INST_COUNT(SkDrawLooper) bool SkDrawLooper::canComputeFastBounds(const SkPaint& paint) { -- 2.7.4