Implement support for a Context parameter in image filters
Some upcoming work (support for expanding crop rects) requires the clip bounds to be available during filter traversal. This change replaces the SkMatrix parameter in the onFilterImage() traversals with a Context parameter. It contains the CTM, as well as the clip bounds. BUG=skia: R=reed@google.com Review URL: https://codereview.chromium.org/189913021 git-svn-id: http://skia.googlecode.com/svn/trunk@13803 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
0d30c51c6c
commit
4cb543d605
@ -25,7 +25,7 @@ public:
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(FailImageFilter)
|
||||
protected:
|
||||
FailImageFilter() : INHERITED(0) {}
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
|
||||
SkBitmap* result, SkIPoint* offset) const {
|
||||
return false;
|
||||
}
|
||||
@ -51,7 +51,7 @@ public:
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(IdentityImageFilter)
|
||||
protected:
|
||||
IdentityImageFilter() : INHERITED(0) {}
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
|
||||
SkBitmap* result, SkIPoint* offset) const {
|
||||
*result = src;
|
||||
return true;
|
||||
|
@ -29,19 +29,19 @@ public:
|
||||
SimpleOffsetFilter(SkScalar dx, SkScalar dy, SkImageFilter* input)
|
||||
: SkImageFilter(input), fDX(dx), fDY(dy) {}
|
||||
|
||||
virtual bool onFilterImage(Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm,
|
||||
virtual bool onFilterImage(Proxy* proxy, const SkBitmap& src, const Context& ctx,
|
||||
SkBitmap* dst, SkIPoint* offset) const SK_OVERRIDE {
|
||||
SkBitmap source = src;
|
||||
SkImageFilter* input = getInput(0);
|
||||
SkIPoint srcOffset = SkIPoint::Make(0, 0);
|
||||
if (NULL != input && !input->filterImage(proxy, src, ctm, &source, &srcOffset)) {
|
||||
if (NULL != input && !input->filterImage(proxy, src, ctx, &source, &srcOffset)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SkIRect bounds;
|
||||
source.getBounds(&bounds);
|
||||
|
||||
if (!this->applyCropRect(&bounds, ctm)) {
|
||||
if (!this->applyCropRect(&bounds, ctx.ctm())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -248,7 +248,7 @@ protected:
|
||||
* If the device does not recognize or support this filter,
|
||||
* it just returns false and leaves result and offset unchanged.
|
||||
*/
|
||||
virtual bool filterImage(const SkImageFilter*, const SkBitmap&, const SkMatrix&,
|
||||
virtual bool filterImage(const SkImageFilter*, const SkBitmap&, const SkImageFilter::Context&,
|
||||
SkBitmap* result, SkIPoint* offset) SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "SkCanvas.h"
|
||||
#include "SkColor.h"
|
||||
#include "SkDeviceProperties.h"
|
||||
#include "SkImageFilter.h"
|
||||
|
||||
// getDeviceCapabilities() is not called by skia, but this flag keeps it around
|
||||
// for clients that have "override" annotations on their subclass. These overrides
|
||||
@ -375,7 +376,8 @@ protected:
|
||||
* If the device does not recognize or support this filter,
|
||||
* it just returns false and leaves result and offset unchanged.
|
||||
*/
|
||||
virtual bool filterImage(const SkImageFilter*, const SkBitmap&, const SkMatrix&,
|
||||
virtual bool filterImage(const SkImageFilter*, const SkBitmap&,
|
||||
const SkImageFilter::Context& ctx,
|
||||
SkBitmap* result, SkIPoint* offset) = 0;
|
||||
|
||||
// This is equal kBGRA_Premul_Config8888 or kRGBA_Premul_Config8888 if
|
||||
|
@ -9,12 +9,12 @@
|
||||
#define SkImageFilter_DEFINED
|
||||
|
||||
#include "SkFlattenable.h"
|
||||
#include "SkMatrix.h"
|
||||
#include "SkRect.h"
|
||||
|
||||
class SkBitmap;
|
||||
class SkColorFilter;
|
||||
class SkBaseDevice;
|
||||
class SkMatrix;
|
||||
struct SkIPoint;
|
||||
class SkShader;
|
||||
class GrEffectRef;
|
||||
@ -49,6 +49,18 @@ public:
|
||||
uint32_t fFlags;
|
||||
};
|
||||
|
||||
class Context {
|
||||
public:
|
||||
Context(const SkMatrix& ctm, const SkIRect& clipBounds) :
|
||||
fCTM(ctm), fClipBounds(clipBounds) {
|
||||
}
|
||||
const SkMatrix& ctm() const { return fCTM; }
|
||||
const SkIRect& clipBounds() const { return fClipBounds; }
|
||||
private:
|
||||
SkMatrix fCTM;
|
||||
SkIRect fClipBounds;
|
||||
};
|
||||
|
||||
class Proxy {
|
||||
public:
|
||||
virtual ~Proxy() {};
|
||||
@ -59,7 +71,7 @@ public:
|
||||
// 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 SkMatrix& ctm,
|
||||
const Context&,
|
||||
SkBitmap* result, SkIPoint* offset) = 0;
|
||||
};
|
||||
|
||||
@ -76,7 +88,7 @@ public:
|
||||
* If the result image cannot be created, return false, in which case both
|
||||
* the result and offset parameters will be ignored by the caller.
|
||||
*/
|
||||
bool filterImage(Proxy*, const SkBitmap& src, const SkMatrix& ctm,
|
||||
bool filterImage(Proxy*, const SkBitmap& src, const Context&,
|
||||
SkBitmap* result, SkIPoint* offset) const;
|
||||
|
||||
/**
|
||||
@ -104,7 +116,7 @@ public:
|
||||
* relative to the src when it is drawn. The default implementation does
|
||||
* single-pass processing using asNewEffect().
|
||||
*/
|
||||
virtual bool filterImageGPU(Proxy*, const SkBitmap& src, const SkMatrix& ctm,
|
||||
virtual bool filterImageGPU(Proxy*, const SkBitmap& src, const Context&,
|
||||
SkBitmap* result, SkIPoint* offset) const;
|
||||
|
||||
/**
|
||||
@ -156,7 +168,7 @@ public:
|
||||
* Recursively evaluate this filter on the GPU. If the filter has no GPU
|
||||
* implementation, it will be processed in software and uploaded to the GPU.
|
||||
*/
|
||||
bool getInputResultGPU(SkImageFilter::Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm,
|
||||
bool getInputResultGPU(SkImageFilter::Proxy* proxy, const SkBitmap& src, const Context&,
|
||||
SkBitmap* result, SkIPoint* offset) const;
|
||||
#endif
|
||||
|
||||
@ -200,7 +212,7 @@ protected:
|
||||
* case both the result and offset parameters will be ignored by the
|
||||
* caller.
|
||||
*/
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
|
||||
SkBitmap* result, SkIPoint* offset) const;
|
||||
// Given the bounds of the destination rect to be filled in device
|
||||
// coordinates (first parameter), and the CTM, compute (conservatively)
|
||||
|
@ -38,12 +38,12 @@ protected:
|
||||
SkBicubicImageFilter(SkReadBuffer& buffer);
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
|
||||
SkBitmap* result, SkIPoint* loc) const SK_OVERRIDE;
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
virtual bool canFilterImageGPU() const SK_OVERRIDE { return true; }
|
||||
virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm,
|
||||
virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context& ctx,
|
||||
SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE;
|
||||
#endif
|
||||
|
||||
|
@ -27,7 +27,7 @@ public:
|
||||
protected:
|
||||
explicit SkBitmapSource(SkReadBuffer& buffer);
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
|
||||
SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE;
|
||||
virtual bool onFilterBounds(const SkIRect& src, const SkMatrix& ctm, SkIRect* dst) const SK_OVERRIDE;
|
||||
|
||||
|
@ -28,13 +28,13 @@ protected:
|
||||
explicit SkBlurImageFilter(SkReadBuffer& buffer);
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
|
||||
SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE;
|
||||
virtual bool onFilterBounds(const SkIRect& src, const SkMatrix&,
|
||||
SkIRect* dst) const SK_OVERRIDE;
|
||||
|
||||
bool canFilterImageGPU() const SK_OVERRIDE { return true; }
|
||||
virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm,
|
||||
virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context& ctx,
|
||||
SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE;
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
|
||||
|
@ -25,7 +25,7 @@ protected:
|
||||
SkColorFilterImageFilter(SkReadBuffer& buffer);
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
|
||||
SkBitmap* result, SkIPoint* loc) const SK_OVERRIDE;
|
||||
|
||||
virtual bool asColorFilter(SkColorFilter**) const SK_OVERRIDE;
|
||||
|
@ -23,7 +23,7 @@ public:
|
||||
protected:
|
||||
explicit SkComposeImageFilter(SkReadBuffer& buffer);
|
||||
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
|
||||
SkBitmap* result, SkIPoint* loc) const SK_OVERRIDE;
|
||||
virtual bool onFilterBounds(const SkIRect&, const SkMatrix&, SkIRect*) const SK_OVERRIDE;
|
||||
|
||||
|
@ -36,7 +36,7 @@ public:
|
||||
|
||||
virtual bool onFilterImage(Proxy* proxy,
|
||||
const SkBitmap& src,
|
||||
const SkMatrix& ctm,
|
||||
const Context& ctx,
|
||||
SkBitmap* dst,
|
||||
SkIPoint* offset) const SK_OVERRIDE;
|
||||
virtual void computeFastBounds(const SkRect& src, SkRect* dst) const SK_OVERRIDE;
|
||||
@ -46,7 +46,7 @@ public:
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
virtual bool canFilterImageGPU() const SK_OVERRIDE { return true; }
|
||||
virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm,
|
||||
virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context& ctx,
|
||||
SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE;
|
||||
#endif
|
||||
|
||||
|
@ -28,7 +28,7 @@ public:
|
||||
protected:
|
||||
explicit SkDropShadowImageFilter(SkReadBuffer&);
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& source, const SkMatrix&, SkBitmap* result, SkIPoint* loc) const SK_OVERRIDE;
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& source, const Context&, SkBitmap* result, SkIPoint* loc) const SK_OVERRIDE;
|
||||
virtual bool onFilterBounds(const SkIRect& src, const SkMatrix&,
|
||||
SkIRect* dst) const SK_OVERRIDE;
|
||||
|
||||
|
@ -24,7 +24,7 @@ protected:
|
||||
explicit SkMagnifierImageFilter(SkReadBuffer& buffer);
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
|
||||
SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE;
|
||||
#if SK_SUPPORT_GPU
|
||||
virtual bool asNewEffect(GrEffectRef** effect, GrTexture* texture, const SkMatrix& matrix, const SkIRect& bounds) const SK_OVERRIDE;
|
||||
|
@ -71,13 +71,13 @@ protected:
|
||||
SkMatrixConvolutionImageFilter(SkReadBuffer& buffer);
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
|
||||
SkBitmap* result, SkIPoint* loc) const SK_OVERRIDE;
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
virtual bool asNewEffect(GrEffectRef** effect,
|
||||
GrTexture*,
|
||||
const SkMatrix& matrix,
|
||||
const SkMatrix& ctm,
|
||||
const SkIRect& bounds) const SK_OVERRIDE;
|
||||
#endif
|
||||
|
||||
|
@ -33,7 +33,7 @@ protected:
|
||||
SkMergeImageFilter(SkReadBuffer& buffer);
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
|
||||
SkBitmap* result, SkIPoint* loc) const SK_OVERRIDE;
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
|
||||
|
@ -32,14 +32,14 @@ protected:
|
||||
SkMorphologyImageFilter(int radiusX, int radiusY, SkImageFilter* input,
|
||||
const CropRect* cropRect);
|
||||
bool filterImageGeneric(Proc procX, Proc procY,
|
||||
Proxy*, const SkBitmap& src, const SkMatrix&,
|
||||
Proxy*, const SkBitmap& src, const Context&,
|
||||
SkBitmap* result, SkIPoint* offset) const;
|
||||
SkMorphologyImageFilter(SkReadBuffer& buffer);
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
#if SK_SUPPORT_GPU
|
||||
virtual bool canFilterImageGPU() const SK_OVERRIDE { return true; }
|
||||
bool filterImageGPUGeneric(bool dilate, Proxy* proxy, const SkBitmap& src,
|
||||
const SkMatrix& ctm, SkBitmap* result,
|
||||
const Context& ctm, SkBitmap* result,
|
||||
SkIPoint* offset) const;
|
||||
#endif
|
||||
|
||||
@ -58,10 +58,10 @@ public:
|
||||
return SkNEW_ARGS(SkDilateImageFilter, (radiusX, radiusY, input, cropRect));
|
||||
}
|
||||
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
|
||||
SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE;
|
||||
#if SK_SUPPORT_GPU
|
||||
virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm,
|
||||
virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context&,
|
||||
SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE;
|
||||
#endif
|
||||
|
||||
@ -90,10 +90,10 @@ public:
|
||||
return SkNEW_ARGS(SkErodeImageFilter, (radiusX, radiusY, input, cropRect));
|
||||
}
|
||||
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
|
||||
SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE;
|
||||
#if SK_SUPPORT_GPU
|
||||
virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm,
|
||||
virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context&,
|
||||
SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE;
|
||||
#endif
|
||||
|
||||
|
@ -26,7 +26,7 @@ protected:
|
||||
SkOffsetImageFilter(SkReadBuffer& buffer);
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
|
||||
SkBitmap* result, SkIPoint* loc) const SK_OVERRIDE;
|
||||
virtual bool onFilterBounds(const SkIRect&, const SkMatrix&, SkIRect*) const SK_OVERRIDE;
|
||||
|
||||
|
@ -40,7 +40,7 @@ protected:
|
||||
*/
|
||||
explicit SkPictureImageFilter(SkReadBuffer&);
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
|
||||
SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE;
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
|
||||
|
@ -37,7 +37,7 @@ protected:
|
||||
SkRectShaderImageFilter(SkReadBuffer& buffer);
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
|
||||
SkBitmap* result, SkIPoint* loc) const SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
|
@ -43,7 +43,7 @@ protected:
|
||||
SkResizeImageFilter(SkReadBuffer& buffer);
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
|
||||
SkBitmap* result, SkIPoint* loc) const SK_OVERRIDE;
|
||||
virtual bool onFilterBounds(const SkIRect& src, const SkMatrix&,
|
||||
SkIRect* dst) const SK_OVERRIDE;
|
||||
|
@ -18,7 +18,7 @@ protected:
|
||||
SkDownSampleImageFilter(SkReadBuffer& buffer);
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
|
||||
SkBitmap* result, SkIPoint* loc) const SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
return SkNEW_ARGS(SkTileImageFilter, (srcRect, dstRect, input));
|
||||
}
|
||||
|
||||
virtual bool onFilterImage(Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm,
|
||||
virtual bool onFilterImage(Proxy* proxy, const SkBitmap& src, const Context& ctx,
|
||||
SkBitmap* dst, SkIPoint* offset) const SK_OVERRIDE;
|
||||
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTileImageFilter)
|
||||
|
@ -33,12 +33,12 @@ public:
|
||||
|
||||
virtual bool onFilterImage(Proxy* proxy,
|
||||
const SkBitmap& src,
|
||||
const SkMatrix& ctm,
|
||||
const Context& ctx,
|
||||
SkBitmap* dst,
|
||||
SkIPoint* offset) const SK_OVERRIDE;
|
||||
#if SK_SUPPORT_GPU
|
||||
virtual bool canFilterImageGPU() const SK_OVERRIDE { return !cropRectIsSet(); }
|
||||
virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm,
|
||||
virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context& ctx,
|
||||
SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE;
|
||||
#endif
|
||||
|
||||
|
@ -140,7 +140,8 @@ public:
|
||||
virtual void makeRenderTargetCurrent();
|
||||
|
||||
virtual bool canHandleImageFilter(const SkImageFilter*) SK_OVERRIDE;
|
||||
virtual bool filterImage(const SkImageFilter*, const SkBitmap&, const SkMatrix&,
|
||||
virtual bool filterImage(const SkImageFilter*, const SkBitmap&,
|
||||
const SkImageFilter::Context&,
|
||||
SkBitmap*, SkIPoint*) SK_OVERRIDE;
|
||||
|
||||
class SkAutoCachedTexture; // used internally
|
||||
|
@ -164,7 +164,7 @@ bool SkBitmapDevice::canHandleImageFilter(const SkImageFilter*) {
|
||||
}
|
||||
|
||||
bool SkBitmapDevice::filterImage(const SkImageFilter* filter, const SkBitmap& src,
|
||||
const SkMatrix& ctm, SkBitmap* result,
|
||||
const SkImageFilter::Context& ctx, SkBitmap* result,
|
||||
SkIPoint* offset) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1164,7 +1164,9 @@ void SkCanvas::internalDrawDevice(SkBaseDevice* srcDev, int x, int y,
|
||||
const SkBitmap& src = srcDev->accessBitmap(false);
|
||||
SkMatrix matrix = *iter.fMatrix;
|
||||
matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y));
|
||||
if (filter->filterImage(&proxy, src, matrix, &dst, &offset)) {
|
||||
SkIRect clipBounds = SkIRect::MakeWH(srcDev->width(), srcDev->height());
|
||||
SkImageFilter::Context ctx(matrix, clipBounds);
|
||||
if (filter->filterImage(&proxy, src, ctx, &dst, &offset)) {
|
||||
SkPaint tmpUnfiltered(*paint);
|
||||
tmpUnfiltered.setImageFilter(NULL);
|
||||
dstDev->drawSprite(iter, dst, pos.x() + offset.x(), pos.y() + offset.y(),
|
||||
@ -1202,7 +1204,9 @@ void SkCanvas::drawSprite(const SkBitmap& bitmap, int x, int y,
|
||||
SkIPoint offset = SkIPoint::Make(0, 0);
|
||||
SkMatrix matrix = *iter.fMatrix;
|
||||
matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y));
|
||||
if (filter->filterImage(&proxy, bitmap, matrix, &dst, &offset)) {
|
||||
SkIRect clipBounds = SkIRect::MakeWH(bitmap.width(), bitmap.height());
|
||||
SkImageFilter::Context ctx(matrix, clipBounds);
|
||||
if (filter->filterImage(&proxy, bitmap, ctx, &dst, &offset)) {
|
||||
SkPaint tmpUnfiltered(*paint);
|
||||
tmpUnfiltered.setImageFilter(NULL);
|
||||
iter.fDevice->drawSprite(iter, dst, pos.x() + offset.x(), pos.y() + offset.y(),
|
||||
|
@ -21,9 +21,9 @@ public:
|
||||
return fDevice->canHandleImageFilter(filter);
|
||||
}
|
||||
virtual bool filterImage(const SkImageFilter* filter, const SkBitmap& src,
|
||||
const SkMatrix& ctm,
|
||||
const SkImageFilter::Context& ctx,
|
||||
SkBitmap* result, SkIPoint* offset) SK_OVERRIDE {
|
||||
return fDevice->filterImage(filter, src, ctm, result, offset);
|
||||
return fDevice->filterImage(filter, src, ctx, result, offset);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -93,7 +93,7 @@ void SkImageFilter::flatten(SkWriteBuffer& buffer) const {
|
||||
}
|
||||
|
||||
bool SkImageFilter::filterImage(Proxy* proxy, const SkBitmap& src,
|
||||
const SkMatrix& ctm,
|
||||
const Context& context,
|
||||
SkBitmap* result, SkIPoint* offset) const {
|
||||
SkASSERT(result);
|
||||
SkASSERT(offset);
|
||||
@ -101,8 +101,8 @@ bool SkImageFilter::filterImage(Proxy* proxy, const SkBitmap& src,
|
||||
* 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, offset)) ||
|
||||
this->onFilterImage(proxy, src, ctm, result, offset);
|
||||
return (proxy && proxy->filterImage(this, src, context, result, offset)) ||
|
||||
this->onFilterImage(proxy, src, context, result, offset);
|
||||
}
|
||||
|
||||
bool SkImageFilter::filterBounds(const SkIRect& src, const SkMatrix& ctm,
|
||||
@ -134,7 +134,7 @@ void SkImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) const {
|
||||
}
|
||||
}
|
||||
|
||||
bool SkImageFilter::onFilterImage(Proxy*, const SkBitmap&, const SkMatrix&,
|
||||
bool SkImageFilter::onFilterImage(Proxy*, const SkBitmap&, const Context&,
|
||||
SkBitmap*, SkIPoint*) const {
|
||||
return false;
|
||||
}
|
||||
@ -143,21 +143,21 @@ bool SkImageFilter::canFilterImageGPU() const {
|
||||
return this->asNewEffect(NULL, NULL, SkMatrix::I(), SkIRect());
|
||||
}
|
||||
|
||||
bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm,
|
||||
bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context& ctx,
|
||||
SkBitmap* result, SkIPoint* offset) const {
|
||||
#if SK_SUPPORT_GPU
|
||||
SkBitmap input = src;
|
||||
SkASSERT(fInputCount == 1);
|
||||
SkIPoint srcOffset = SkIPoint::Make(0, 0);
|
||||
if (this->getInput(0) &&
|
||||
!this->getInput(0)->getInputResultGPU(proxy, src, ctm, &input, &srcOffset)) {
|
||||
!this->getInput(0)->getInputResultGPU(proxy, src, ctx, &input, &srcOffset)) {
|
||||
return false;
|
||||
}
|
||||
GrTexture* srcTexture = input.getTexture();
|
||||
SkIRect bounds;
|
||||
src.getBounds(&bounds);
|
||||
bounds.offset(srcOffset);
|
||||
if (!this->applyCropRect(&bounds, ctm)) {
|
||||
if (!this->applyCropRect(&bounds, ctx.ctm())) {
|
||||
return false;
|
||||
}
|
||||
SkRect srcRect = SkRect::Make(bounds);
|
||||
@ -179,7 +179,7 @@ bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMa
|
||||
offset->fX = bounds.left();
|
||||
offset->fY = bounds.top();
|
||||
bounds.offset(-srcOffset);
|
||||
SkMatrix matrix(ctm);
|
||||
SkMatrix matrix(ctx.ctm());
|
||||
matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top()));
|
||||
this->asNewEffect(&effect, srcTexture, matrix, bounds);
|
||||
SkASSERT(effect);
|
||||
@ -253,7 +253,7 @@ void SkImageFilter::WrapTexture(GrTexture* texture, int width, int height, SkBit
|
||||
}
|
||||
|
||||
bool SkImageFilter::getInputResultGPU(SkImageFilter::Proxy* proxy,
|
||||
const SkBitmap& src, const SkMatrix& ctm,
|
||||
const SkBitmap& src, const Context& ctx,
|
||||
SkBitmap* result, SkIPoint* offset) const {
|
||||
// Ensure that GrContext calls under filterImage and filterImageGPU below will see an identity
|
||||
// matrix with no clip and that the matrix, clip, and render target set before this function was
|
||||
@ -261,9 +261,9 @@ bool SkImageFilter::getInputResultGPU(SkImageFilter::Proxy* proxy,
|
||||
GrContext* context = src.getTexture()->getContext();
|
||||
GrContext::AutoWideOpenIdentityDraw awoid(context, NULL);
|
||||
if (this->canFilterImageGPU()) {
|
||||
return this->filterImageGPU(proxy, src, ctm, result, offset);
|
||||
return this->filterImageGPU(proxy, src, ctx, result, offset);
|
||||
} else {
|
||||
if (this->filterImage(proxy, src, ctm, result, offset)) {
|
||||
if (this->filterImage(proxy, src, ctx, result, offset)) {
|
||||
if (!result->getTexture()) {
|
||||
SkImageInfo info;
|
||||
if (!result->asImageInfo(&info)) {
|
||||
|
@ -21,7 +21,7 @@ protected:
|
||||
explicit SkAlphaThresholdFilterImpl(SkReadBuffer& buffer);
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
|
||||
SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE;
|
||||
#if SK_SUPPORT_GPU
|
||||
virtual bool asNewEffect(GrEffectRef** effect, GrTexture* texture,
|
||||
@ -304,7 +304,7 @@ void SkAlphaThresholdFilterImpl::flatten(SkWriteBuffer& buffer) const {
|
||||
}
|
||||
|
||||
bool SkAlphaThresholdFilterImpl::onFilterImage(Proxy*, const SkBitmap& src,
|
||||
const SkMatrix& matrix, SkBitmap* dst,
|
||||
const Context& ctx, SkBitmap* dst,
|
||||
SkIPoint* offset) const {
|
||||
SkASSERT(src.colorType() == kPMColor_SkColorType);
|
||||
|
||||
@ -313,7 +313,7 @@ bool SkAlphaThresholdFilterImpl::onFilterImage(Proxy*, const SkBitmap& src,
|
||||
}
|
||||
|
||||
SkMatrix localInverse;
|
||||
if (!matrix.invert(&localInverse)) {
|
||||
if (!ctx.ctm().invert(&localInverse)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -82,12 +82,12 @@ inline SkPMColor cubicBlend(const SkScalar c[16], SkScalar t, SkPMColor c0, SkPM
|
||||
|
||||
bool SkBicubicImageFilter::onFilterImage(Proxy* proxy,
|
||||
const SkBitmap& source,
|
||||
const SkMatrix& matrix,
|
||||
const Context& ctx,
|
||||
SkBitmap* result,
|
||||
SkIPoint* offset) const {
|
||||
SkBitmap src = source;
|
||||
SkIPoint srcOffset = SkIPoint::Make(0, 0);
|
||||
if (getInput(0) && !getInput(0)->filterImage(proxy, source, matrix, &src, &srcOffset)) {
|
||||
if (getInput(0) && !getInput(0)->filterImage(proxy, source, ctx, &src, &srcOffset)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -168,10 +168,10 @@ bool SkBicubicImageFilter::onFilterImage(Proxy* proxy,
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
|
||||
bool SkBicubicImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm,
|
||||
bool SkBicubicImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context& ctx,
|
||||
SkBitmap* result, SkIPoint* offset) const {
|
||||
SkBitmap srcBM = src;
|
||||
if (getInput(0) && !getInput(0)->getInputResultGPU(proxy, src, ctm, &srcBM, offset)) {
|
||||
if (getInput(0) && !getInput(0)->getInputResultGPU(proxy, src, ctx, &srcBM, offset)) {
|
||||
return false;
|
||||
}
|
||||
GrTexture* srcTexture = srcBM.getTexture();
|
||||
|
@ -42,11 +42,11 @@ void SkBitmapSource::flatten(SkWriteBuffer& buffer) const {
|
||||
buffer.writeRect(fDstRect);
|
||||
}
|
||||
|
||||
bool SkBitmapSource::onFilterImage(Proxy* proxy, const SkBitmap&, const SkMatrix& matrix,
|
||||
bool SkBitmapSource::onFilterImage(Proxy* proxy, const SkBitmap&, const Context& ctx,
|
||||
SkBitmap* result, SkIPoint* offset) const {
|
||||
SkRect bounds, dstRect;
|
||||
fBitmap.getBounds(&bounds);
|
||||
matrix.mapRect(&dstRect, fDstRect);
|
||||
ctx.ctm().mapRect(&dstRect, fDstRect);
|
||||
if (fSrcRect == bounds && dstRect == bounds) {
|
||||
// No regions cropped out or resized; return entire bitmap.
|
||||
*result = fBitmap;
|
||||
|
@ -134,11 +134,11 @@ static void getBox3Params(SkScalar s, int *kernelSize, int* kernelSize3, int *lo
|
||||
}
|
||||
|
||||
bool SkBlurImageFilter::onFilterImage(Proxy* proxy,
|
||||
const SkBitmap& source, const SkMatrix& ctm,
|
||||
const SkBitmap& source, const Context& ctx,
|
||||
SkBitmap* dst, SkIPoint* offset) const {
|
||||
SkBitmap src = source;
|
||||
SkIPoint srcOffset = SkIPoint::Make(0, 0);
|
||||
if (getInput(0) && !getInput(0)->filterImage(proxy, source, ctm, &src, &srcOffset)) {
|
||||
if (getInput(0) && !getInput(0)->filterImage(proxy, source, ctx, &src, &srcOffset)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -154,7 +154,7 @@ bool SkBlurImageFilter::onFilterImage(Proxy* proxy,
|
||||
SkIRect srcBounds, dstBounds;
|
||||
src.getBounds(&srcBounds);
|
||||
srcBounds.offset(srcOffset);
|
||||
if (!this->applyCropRect(&srcBounds, ctm)) {
|
||||
if (!this->applyCropRect(&srcBounds, ctx.ctm())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -165,7 +165,7 @@ bool SkBlurImageFilter::onFilterImage(Proxy* proxy,
|
||||
}
|
||||
|
||||
SkVector sigma, localSigma = SkVector::Make(fSigma.width(), fSigma.height());
|
||||
ctm.mapVectors(&sigma, &localSigma, 1);
|
||||
ctx.ctm().mapVectors(&sigma, &localSigma, 1);
|
||||
|
||||
int kernelSizeX, kernelSizeX3, lowOffsetX, highOffsetX;
|
||||
int kernelSizeY, kernelSizeY3, lowOffsetY, highOffsetY;
|
||||
@ -250,23 +250,23 @@ bool SkBlurImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SkBlurImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm,
|
||||
bool SkBlurImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context& ctx,
|
||||
SkBitmap* result, SkIPoint* offset) const {
|
||||
#if SK_SUPPORT_GPU
|
||||
SkBitmap input = src;
|
||||
SkIPoint srcOffset = SkIPoint::Make(0, 0);
|
||||
if (getInput(0) && !getInput(0)->getInputResultGPU(proxy, src, ctm, &input, &srcOffset)) {
|
||||
if (getInput(0) && !getInput(0)->getInputResultGPU(proxy, src, ctx, &input, &srcOffset)) {
|
||||
return false;
|
||||
}
|
||||
GrTexture* source = input.getTexture();
|
||||
SkIRect rect;
|
||||
src.getBounds(&rect);
|
||||
rect.offset(srcOffset);
|
||||
if (!this->applyCropRect(&rect, ctm)) {
|
||||
if (!this->applyCropRect(&rect, ctx.ctm())) {
|
||||
return false;
|
||||
}
|
||||
SkVector sigma, localSigma = SkVector::Make(fSigma.width(), fSigma.height());
|
||||
ctm.mapVectors(&sigma, &localSigma, 1);
|
||||
ctx.ctm().mapVectors(&sigma, &localSigma, 1);
|
||||
offset->fX = rect.fLeft;
|
||||
offset->fY = rect.fTop;
|
||||
rect.offset(-srcOffset);
|
||||
|
@ -99,19 +99,19 @@ SkColorFilterImageFilter::~SkColorFilterImageFilter() {
|
||||
}
|
||||
|
||||
bool SkColorFilterImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& source,
|
||||
const SkMatrix& matrix,
|
||||
const Context& ctx,
|
||||
SkBitmap* result,
|
||||
SkIPoint* offset) const {
|
||||
SkBitmap src = source;
|
||||
SkIPoint srcOffset = SkIPoint::Make(0, 0);
|
||||
if (getInput(0) && !getInput(0)->filterImage(proxy, source, matrix, &src, &srcOffset)) {
|
||||
if (getInput(0) && !getInput(0)->filterImage(proxy, source, ctx, &src, &srcOffset)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SkIRect bounds;
|
||||
src.getBounds(&bounds);
|
||||
bounds.offset(srcOffset);
|
||||
if (!this->applyCropRect(&bounds, matrix)) {
|
||||
if (!this->applyCropRect(&bounds, ctx.ctm())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ SkComposeImageFilter::~SkComposeImageFilter() {
|
||||
|
||||
bool SkComposeImageFilter::onFilterImage(Proxy* proxy,
|
||||
const SkBitmap& src,
|
||||
const SkMatrix& ctm,
|
||||
const Context& ctx,
|
||||
SkBitmap* result,
|
||||
SkIPoint* offset) const {
|
||||
SkImageFilter* outer = getInput(0);
|
||||
@ -26,12 +26,12 @@ bool SkComposeImageFilter::onFilterImage(Proxy* proxy,
|
||||
}
|
||||
|
||||
if (!outer || !inner) {
|
||||
return (outer ? outer : inner)->filterImage(proxy, src, ctm, result, offset);
|
||||
return (outer ? outer : inner)->filterImage(proxy, src, ctx, result, offset);
|
||||
}
|
||||
|
||||
SkBitmap tmp;
|
||||
return inner->filterImage(proxy, src, ctm, &tmp, offset) &&
|
||||
outer->filterImage(proxy, tmp, ctm, result, offset);
|
||||
return inner->filterImage(proxy, src, ctx, &tmp, offset) &&
|
||||
outer->filterImage(proxy, tmp, ctx, result, offset);
|
||||
}
|
||||
|
||||
bool SkComposeImageFilter::onFilterBounds(const SkIRect& src,
|
||||
|
@ -194,15 +194,15 @@ void SkDisplacementMapEffect::flatten(SkWriteBuffer& buffer) const {
|
||||
|
||||
bool SkDisplacementMapEffect::onFilterImage(Proxy* proxy,
|
||||
const SkBitmap& src,
|
||||
const SkMatrix& ctm,
|
||||
const Context& ctx,
|
||||
SkBitmap* dst,
|
||||
SkIPoint* offset) const {
|
||||
SkBitmap displ = src, color = src;
|
||||
const SkImageFilter* colorInput = getColorInput();
|
||||
const SkImageFilter* displInput = getDisplacementInput();
|
||||
SkIPoint colorOffset = SkIPoint::Make(0, 0), displOffset = SkIPoint::Make(0, 0);
|
||||
if ((colorInput && !colorInput->filterImage(proxy, src, ctm, &color, &colorOffset)) ||
|
||||
(displInput && !displInput->filterImage(proxy, src, ctm, &displ, &displOffset))) {
|
||||
if ((colorInput && !colorInput->filterImage(proxy, src, ctx, &color, &colorOffset)) ||
|
||||
(displInput && !displInput->filterImage(proxy, src, ctx, &displ, &displOffset))) {
|
||||
return false;
|
||||
}
|
||||
if ((displ.colorType() != kPMColor_SkColorType) ||
|
||||
@ -217,13 +217,13 @@ bool SkDisplacementMapEffect::onFilterImage(Proxy* proxy,
|
||||
SkIRect bounds;
|
||||
color.getBounds(&bounds);
|
||||
bounds.offset(colorOffset);
|
||||
if (!this->applyCropRect(&bounds, ctm)) {
|
||||
if (!this->applyCropRect(&bounds, ctx.ctm())) {
|
||||
return false;
|
||||
}
|
||||
SkIRect displBounds;
|
||||
displ.getBounds(&displBounds);
|
||||
displBounds.offset(displOffset);
|
||||
if (!this->applyCropRect(&displBounds, ctm)) {
|
||||
if (!this->applyCropRect(&displBounds, ctx.ctm())) {
|
||||
return false;
|
||||
}
|
||||
if (!bounds.intersect(displBounds)) {
|
||||
@ -236,7 +236,7 @@ bool SkDisplacementMapEffect::onFilterImage(Proxy* proxy,
|
||||
}
|
||||
|
||||
SkVector scale = SkVector::Make(fScale, fScale);
|
||||
ctm.mapVectors(&scale, 1);
|
||||
ctx.ctm().mapVectors(&scale, 1);
|
||||
SkIRect colorBounds = bounds;
|
||||
colorBounds.offset(-colorOffset);
|
||||
|
||||
@ -348,11 +348,11 @@ private:
|
||||
typedef GrEffect INHERITED;
|
||||
};
|
||||
|
||||
bool SkDisplacementMapEffect::filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm,
|
||||
bool SkDisplacementMapEffect::filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context& ctx,
|
||||
SkBitmap* result, SkIPoint* offset) const {
|
||||
SkBitmap colorBM = src;
|
||||
SkIPoint colorOffset = SkIPoint::Make(0, 0);
|
||||
if (getColorInput() && !getColorInput()->getInputResultGPU(proxy, src, ctm, &colorBM,
|
||||
if (getColorInput() && !getColorInput()->getInputResultGPU(proxy, src, ctx, &colorBM,
|
||||
&colorOffset)) {
|
||||
return false;
|
||||
}
|
||||
@ -360,7 +360,7 @@ bool SkDisplacementMapEffect::filterImageGPU(Proxy* proxy, const SkBitmap& src,
|
||||
SkBitmap displacementBM = src;
|
||||
SkIPoint displacementOffset = SkIPoint::Make(0, 0);
|
||||
if (getDisplacementInput() &&
|
||||
!getDisplacementInput()->getInputResultGPU(proxy, src, ctm, &displacementBM,
|
||||
!getDisplacementInput()->getInputResultGPU(proxy, src, ctx, &displacementBM,
|
||||
&displacementOffset)) {
|
||||
return false;
|
||||
}
|
||||
@ -379,17 +379,17 @@ bool SkDisplacementMapEffect::filterImageGPU(Proxy* proxy, const SkBitmap& src,
|
||||
GrContext::AutoRenderTarget art(context, dst->asRenderTarget());
|
||||
|
||||
SkVector scale = SkVector::Make(fScale, fScale);
|
||||
ctm.mapVectors(&scale, 1);
|
||||
ctx.ctm().mapVectors(&scale, 1);
|
||||
SkIRect bounds;
|
||||
colorBM.getBounds(&bounds);
|
||||
bounds.offset(colorOffset);
|
||||
if (!this->applyCropRect(&bounds, ctm)) {
|
||||
if (!this->applyCropRect(&bounds, ctx.ctm())) {
|
||||
return false;
|
||||
}
|
||||
SkIRect displBounds;
|
||||
displacementBM.getBounds(&displBounds);
|
||||
displBounds.offset(displacementOffset);
|
||||
if (!this->applyCropRect(&displBounds, ctm)) {
|
||||
if (!this->applyCropRect(&displBounds, ctx.ctm())) {
|
||||
return false;
|
||||
}
|
||||
if (!bounds.intersect(displBounds)) {
|
||||
|
@ -58,17 +58,17 @@ void SkDropShadowImageFilter::flatten(SkWriteBuffer& buffer) const
|
||||
buffer.writeColor(fColor);
|
||||
}
|
||||
|
||||
bool SkDropShadowImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& source, const SkMatrix& matrix, SkBitmap* result, SkIPoint* offset) const
|
||||
bool SkDropShadowImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& source, const Context& ctx, SkBitmap* result, SkIPoint* offset) const
|
||||
{
|
||||
SkBitmap src = source;
|
||||
SkIPoint srcOffset = SkIPoint::Make(0, 0);
|
||||
if (getInput(0) && !getInput(0)->filterImage(proxy, source, matrix, &src, &srcOffset))
|
||||
if (getInput(0) && !getInput(0)->filterImage(proxy, source, ctx, &src, &srcOffset))
|
||||
return false;
|
||||
|
||||
SkIRect bounds;
|
||||
src.getBounds(&bounds);
|
||||
bounds.offset(srcOffset);
|
||||
if (!this->applyCropRect(&bounds, matrix)) {
|
||||
if (!this->applyCropRect(&bounds, ctx.ctm())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ bool SkDropShadowImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& source
|
||||
SkCanvas canvas(device.get());
|
||||
|
||||
SkVector sigma, localSigma = SkVector::Make(fSigmaX, fSigmaY);
|
||||
matrix.mapVectors(&sigma, &localSigma, 1);
|
||||
ctx.ctm().mapVectors(&sigma, &localSigma, 1);
|
||||
sigma.fX = SkMaxScalar(0, sigma.fX);
|
||||
sigma.fY = SkMaxScalar(0, sigma.fY);
|
||||
SkAutoTUnref<SkImageFilter> blurFilter(SkBlurImageFilter::Create(sigma.fX, sigma.fY));
|
||||
@ -89,7 +89,7 @@ bool SkDropShadowImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& source
|
||||
paint.setColorFilter(colorFilter.get());
|
||||
paint.setXfermodeMode(SkXfermode::kSrcOver_Mode);
|
||||
SkVector offsetVec, localOffsetVec = SkVector::Make(fDx, fDy);
|
||||
matrix.mapVectors(&offsetVec, &localOffsetVec, 1);
|
||||
ctx.ctm().mapVectors(&offsetVec, &localOffsetVec, 1);
|
||||
canvas.translate(-SkIntToScalar(bounds.fLeft), -SkIntToScalar(bounds.fTop));
|
||||
canvas.drawBitmap(src, offsetVec.fX, offsetVec.fY, &paint);
|
||||
canvas.drawBitmap(src, 0, 0);
|
||||
|
@ -271,7 +271,7 @@ public:
|
||||
protected:
|
||||
explicit SkDiffuseLightingImageFilter(SkReadBuffer& buffer);
|
||||
virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE;
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
|
||||
SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE;
|
||||
#if SK_SUPPORT_GPU
|
||||
virtual bool asNewEffect(GrEffectRef** effect, GrTexture*, const SkMatrix& matrix, const SkIRect& bounds) const SK_OVERRIDE;
|
||||
@ -293,7 +293,7 @@ public:
|
||||
protected:
|
||||
explicit SkSpecularLightingImageFilter(SkReadBuffer& buffer);
|
||||
virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE;
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
|
||||
SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE;
|
||||
#if SK_SUPPORT_GPU
|
||||
virtual bool asNewEffect(GrEffectRef** effect, GrTexture*, const SkMatrix& matrix, const SkIRect& bounds) const SK_OVERRIDE;
|
||||
@ -933,13 +933,13 @@ void SkDiffuseLightingImageFilter::flatten(SkWriteBuffer& buffer) const {
|
||||
|
||||
bool SkDiffuseLightingImageFilter::onFilterImage(Proxy* proxy,
|
||||
const SkBitmap& source,
|
||||
const SkMatrix& ctm,
|
||||
const Context& ctx,
|
||||
SkBitmap* dst,
|
||||
SkIPoint* offset) const {
|
||||
SkImageFilter* input = getInput(0);
|
||||
SkBitmap src = source;
|
||||
SkIPoint srcOffset = SkIPoint::Make(0, 0);
|
||||
if (input && !input->filterImage(proxy, source, ctm, &src, &srcOffset)) {
|
||||
if (input && !input->filterImage(proxy, source, ctx, &src, &srcOffset)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -954,7 +954,7 @@ bool SkDiffuseLightingImageFilter::onFilterImage(Proxy* proxy,
|
||||
SkIRect bounds;
|
||||
src.getBounds(&bounds);
|
||||
bounds.offset(srcOffset);
|
||||
if (!this->applyCropRect(&bounds, ctm)) {
|
||||
if (!this->applyCropRect(&bounds, ctx.ctm())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -967,7 +967,7 @@ bool SkDiffuseLightingImageFilter::onFilterImage(Proxy* proxy,
|
||||
return false;
|
||||
}
|
||||
|
||||
SkAutoTUnref<SkLight> transformedLight(light()->transform(ctm));
|
||||
SkAutoTUnref<SkLight> transformedLight(light()->transform(ctx.ctm()));
|
||||
|
||||
DiffuseLightingType lightingType(fKD);
|
||||
offset->fX = bounds.left();
|
||||
@ -1026,13 +1026,13 @@ void SkSpecularLightingImageFilter::flatten(SkWriteBuffer& buffer) const {
|
||||
|
||||
bool SkSpecularLightingImageFilter::onFilterImage(Proxy* proxy,
|
||||
const SkBitmap& source,
|
||||
const SkMatrix& ctm,
|
||||
const Context& ctx,
|
||||
SkBitmap* dst,
|
||||
SkIPoint* offset) const {
|
||||
SkImageFilter* input = getInput(0);
|
||||
SkBitmap src = source;
|
||||
SkIPoint srcOffset = SkIPoint::Make(0, 0);
|
||||
if (input && !input->filterImage(proxy, source, ctm, &src, &srcOffset)) {
|
||||
if (input && !input->filterImage(proxy, source, ctx, &src, &srcOffset)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1047,7 +1047,7 @@ bool SkSpecularLightingImageFilter::onFilterImage(Proxy* proxy,
|
||||
SkIRect bounds;
|
||||
src.getBounds(&bounds);
|
||||
bounds.offset(srcOffset);
|
||||
if (!this->applyCropRect(&bounds, ctm)) {
|
||||
if (!this->applyCropRect(&bounds, ctx.ctm())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1065,7 +1065,7 @@ bool SkSpecularLightingImageFilter::onFilterImage(Proxy* proxy,
|
||||
offset->fX = bounds.left();
|
||||
offset->fY = bounds.top();
|
||||
bounds.offset(-srcOffset);
|
||||
SkAutoTUnref<SkLight> transformedLight(light()->transform(ctm));
|
||||
SkAutoTUnref<SkLight> transformedLight(light()->transform(ctx.ctm()));
|
||||
switch (transformedLight->type()) {
|
||||
case SkLight::kDistant_LightType:
|
||||
lightBitmap<SpecularLightingType, SkDistantLight>(lightingType, transformedLight, src, dst, surfaceScale(), bounds);
|
||||
|
@ -280,7 +280,7 @@ void SkMagnifierImageFilter::flatten(SkWriteBuffer& buffer) const {
|
||||
}
|
||||
|
||||
bool SkMagnifierImageFilter::onFilterImage(Proxy*, const SkBitmap& src,
|
||||
const SkMatrix&, SkBitmap* dst,
|
||||
const Context&, SkBitmap* dst,
|
||||
SkIPoint* offset) const {
|
||||
SkASSERT(src.colorType() == kPMColor_SkColorType);
|
||||
SkASSERT(fSrcRect.width() < src.width());
|
||||
|
@ -251,12 +251,12 @@ static SkBitmap unpremultiplyBitmap(const SkBitmap& src)
|
||||
|
||||
bool SkMatrixConvolutionImageFilter::onFilterImage(Proxy* proxy,
|
||||
const SkBitmap& source,
|
||||
const SkMatrix& matrix,
|
||||
const Context& ctx,
|
||||
SkBitmap* result,
|
||||
SkIPoint* offset) const {
|
||||
SkBitmap src = source;
|
||||
SkIPoint srcOffset = SkIPoint::Make(0, 0);
|
||||
if (getInput(0) && !getInput(0)->filterImage(proxy, source, matrix, &src, &srcOffset)) {
|
||||
if (getInput(0) && !getInput(0)->filterImage(proxy, source, ctx, &src, &srcOffset)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -267,7 +267,7 @@ bool SkMatrixConvolutionImageFilter::onFilterImage(Proxy* proxy,
|
||||
SkIRect bounds;
|
||||
src.getBounds(&bounds);
|
||||
bounds.offset(srcOffset);
|
||||
if (!this->applyCropRect(&bounds, matrix)) {
|
||||
if (!this->applyCropRect(&bounds, ctx.ctm())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ SkMergeImageFilter::~SkMergeImageFilter() {
|
||||
}
|
||||
|
||||
bool SkMergeImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src,
|
||||
const SkMatrix& ctm,
|
||||
const Context& ctx,
|
||||
SkBitmap* result, SkIPoint* offset) const {
|
||||
if (countInputs() < 1) {
|
||||
return false;
|
||||
@ -74,7 +74,7 @@ bool SkMergeImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src,
|
||||
|
||||
SkIRect bounds;
|
||||
src.getBounds(&bounds);
|
||||
if (!this->applyCropRect(&bounds, ctm)) {
|
||||
if (!this->applyCropRect(&bounds, ctx.ctm())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -95,7 +95,7 @@ bool SkMergeImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src,
|
||||
SkIPoint pos = SkIPoint::Make(0, 0);
|
||||
SkImageFilter* filter = getInput(i);
|
||||
if (filter) {
|
||||
if (!filter->filterImage(proxy, src, ctm, &tmp, &pos)) {
|
||||
if (!filter->filterImage(proxy, src, ctx, &tmp, &pos)) {
|
||||
return false;
|
||||
}
|
||||
srcPtr = &tmp;
|
||||
|
@ -140,12 +140,12 @@ bool SkMorphologyImageFilter::filterImageGeneric(SkMorphologyImageFilter::Proc p
|
||||
SkMorphologyImageFilter::Proc procY,
|
||||
Proxy* proxy,
|
||||
const SkBitmap& source,
|
||||
const SkMatrix& ctm,
|
||||
const Context& ctx,
|
||||
SkBitmap* dst,
|
||||
SkIPoint* offset) const {
|
||||
SkBitmap src = source;
|
||||
SkIPoint srcOffset = SkIPoint::Make(0, 0);
|
||||
if (getInput(0) && !getInput(0)->filterImage(proxy, source, ctm, &src, &srcOffset)) {
|
||||
if (getInput(0) && !getInput(0)->filterImage(proxy, source, ctx, &src, &srcOffset)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -156,7 +156,7 @@ bool SkMorphologyImageFilter::filterImageGeneric(SkMorphologyImageFilter::Proc p
|
||||
SkIRect bounds;
|
||||
src.getBounds(&bounds);
|
||||
bounds.offset(srcOffset);
|
||||
if (!this->applyCropRect(&bounds, ctm)) {
|
||||
if (!this->applyCropRect(&bounds, ctx.ctm())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -173,7 +173,7 @@ bool SkMorphologyImageFilter::filterImageGeneric(SkMorphologyImageFilter::Proc p
|
||||
|
||||
SkVector radius = SkVector::Make(SkIntToScalar(this->radius().width()),
|
||||
SkIntToScalar(this->radius().height()));
|
||||
ctm.mapVectors(&radius, 1);
|
||||
ctx.ctm().mapVectors(&radius, 1);
|
||||
int width = SkScalarFloorToInt(radius.fX);
|
||||
int height = SkScalarFloorToInt(radius.fY);
|
||||
|
||||
@ -212,7 +212,7 @@ bool SkMorphologyImageFilter::filterImageGeneric(SkMorphologyImageFilter::Proc p
|
||||
}
|
||||
|
||||
bool SkErodeImageFilter::onFilterImage(Proxy* proxy,
|
||||
const SkBitmap& source, const SkMatrix& ctm,
|
||||
const SkBitmap& source, const Context& ctx,
|
||||
SkBitmap* dst, SkIPoint* offset) const {
|
||||
Proc erodeXProc = SkMorphologyGetPlatformProc(kErodeX_SkMorphologyProcType);
|
||||
if (!erodeXProc) {
|
||||
@ -222,11 +222,11 @@ bool SkErodeImageFilter::onFilterImage(Proxy* proxy,
|
||||
if (!erodeYProc) {
|
||||
erodeYProc = erode<kY>;
|
||||
}
|
||||
return this->filterImageGeneric(erodeXProc, erodeYProc, proxy, source, ctm, dst, offset);
|
||||
return this->filterImageGeneric(erodeXProc, erodeYProc, proxy, source, ctx, dst, offset);
|
||||
}
|
||||
|
||||
bool SkDilateImageFilter::onFilterImage(Proxy* proxy,
|
||||
const SkBitmap& source, const SkMatrix& ctm,
|
||||
const SkBitmap& source, const Context& ctx,
|
||||
SkBitmap* dst, SkIPoint* offset) const {
|
||||
Proc dilateXProc = SkMorphologyGetPlatformProc(kDilateX_SkMorphologyProcType);
|
||||
if (!dilateXProc) {
|
||||
@ -236,7 +236,7 @@ bool SkDilateImageFilter::onFilterImage(Proxy* proxy,
|
||||
if (!dilateYProc) {
|
||||
dilateYProc = dilate<kY>;
|
||||
}
|
||||
return this->filterImageGeneric(dilateXProc, dilateYProc, proxy, source, ctm, dst, offset);
|
||||
return this->filterImageGeneric(dilateXProc, dilateYProc, proxy, source, ctx, dst, offset);
|
||||
}
|
||||
|
||||
void SkMorphologyImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) const {
|
||||
@ -538,23 +538,23 @@ bool apply_morphology(const SkBitmap& input,
|
||||
bool SkMorphologyImageFilter::filterImageGPUGeneric(bool dilate,
|
||||
Proxy* proxy,
|
||||
const SkBitmap& src,
|
||||
const SkMatrix& ctm,
|
||||
const Context& ctx,
|
||||
SkBitmap* result,
|
||||
SkIPoint* offset) const {
|
||||
SkBitmap input = src;
|
||||
SkIPoint srcOffset = SkIPoint::Make(0, 0);
|
||||
if (getInput(0) && !getInput(0)->getInputResultGPU(proxy, src, ctm, &input, &srcOffset)) {
|
||||
if (getInput(0) && !getInput(0)->getInputResultGPU(proxy, src, ctx, &input, &srcOffset)) {
|
||||
return false;
|
||||
}
|
||||
SkIRect bounds;
|
||||
input.getBounds(&bounds);
|
||||
bounds.offset(srcOffset);
|
||||
if (!this->applyCropRect(&bounds, ctm)) {
|
||||
if (!this->applyCropRect(&bounds, ctx.ctm())) {
|
||||
return false;
|
||||
}
|
||||
SkVector radius = SkVector::Make(SkIntToScalar(this->radius().width()),
|
||||
SkIntToScalar(this->radius().height()));
|
||||
ctm.mapVectors(&radius, 1);
|
||||
ctx.ctm().mapVectors(&radius, 1);
|
||||
int width = SkScalarFloorToInt(radius.fX);
|
||||
int height = SkScalarFloorToInt(radius.fY);
|
||||
|
||||
@ -581,14 +581,14 @@ bool SkMorphologyImageFilter::filterImageGPUGeneric(bool dilate,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SkDilateImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm,
|
||||
bool SkDilateImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context& ctx,
|
||||
SkBitmap* result, SkIPoint* offset) const {
|
||||
return this->filterImageGPUGeneric(true, proxy, src, ctm, result, offset);
|
||||
return this->filterImageGPUGeneric(true, proxy, src, ctx, result, offset);
|
||||
}
|
||||
|
||||
bool SkErodeImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm,
|
||||
bool SkErodeImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context& ctx,
|
||||
SkBitmap* result, SkIPoint* offset) const {
|
||||
return this->filterImageGPUGeneric(false, proxy, src, ctm, result, offset);
|
||||
return this->filterImageGPUGeneric(false, proxy, src, ctx, result, offset);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include "SkPaint.h"
|
||||
|
||||
bool SkOffsetImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& source,
|
||||
const SkMatrix& matrix,
|
||||
const Context& ctx,
|
||||
SkBitmap* result,
|
||||
SkIPoint* offset) const {
|
||||
SkImageFilter* input = getInput(0);
|
||||
@ -26,18 +26,18 @@ bool SkOffsetImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& source,
|
||||
#else
|
||||
if (!cropRectIsSet()) {
|
||||
#endif
|
||||
if (input && !input->filterImage(proxy, source, matrix, &src, &srcOffset)) {
|
||||
if (input && !input->filterImage(proxy, source, ctx, &src, &srcOffset)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SkVector vec;
|
||||
matrix.mapVectors(&vec, &fOffset, 1);
|
||||
ctx.ctm().mapVectors(&vec, &fOffset, 1);
|
||||
|
||||
offset->fX = srcOffset.fX + SkScalarRoundToInt(vec.fX);
|
||||
offset->fY = srcOffset.fY + SkScalarRoundToInt(vec.fY);
|
||||
*result = src;
|
||||
} else {
|
||||
if (input && !input->filterImage(proxy, source, matrix, &src, &srcOffset)) {
|
||||
if (input && !input->filterImage(proxy, source, ctx, &src, &srcOffset)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@ bool SkOffsetImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& source,
|
||||
src.getBounds(&bounds);
|
||||
bounds.offset(srcOffset);
|
||||
|
||||
if (!applyCropRect(&bounds, matrix)) {
|
||||
if (!applyCropRect(&bounds, ctx.ctm())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ bool SkOffsetImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& source,
|
||||
canvas.translate(SkIntToScalar(srcOffset.fX - bounds.fLeft),
|
||||
SkIntToScalar(srcOffset.fY - bounds.fTop));
|
||||
SkVector vec;
|
||||
matrix.mapVectors(&vec, &fOffset, 1);
|
||||
ctx.ctm().mapVectors(&vec, &fOffset, 1);
|
||||
canvas.drawBitmap(src, vec.x(), vec.y(), &paint);
|
||||
*result = device->accessBitmap(false);
|
||||
offset->fX = bounds.fLeft;
|
||||
|
@ -58,8 +58,8 @@ void SkPictureImageFilter::flatten(SkWriteBuffer& buffer) const {
|
||||
buffer.writeRect(fCropRect);
|
||||
}
|
||||
|
||||
bool SkPictureImageFilter::onFilterImage(Proxy* proxy, const SkBitmap&, const SkMatrix& matrix,
|
||||
SkBitmap* result, SkIPoint* offset) const {
|
||||
bool SkPictureImageFilter::onFilterImage(Proxy* proxy, const SkBitmap&, const Context& ctx,
|
||||
SkBitmap* result, SkIPoint* offset) const {
|
||||
if (!fPicture) {
|
||||
offset->fX = offset->fY = 0;
|
||||
return true;
|
||||
@ -67,7 +67,7 @@ bool SkPictureImageFilter::onFilterImage(Proxy* proxy, const SkBitmap&, const Sk
|
||||
|
||||
SkRect floatBounds;
|
||||
SkIRect bounds;
|
||||
matrix.mapRect(&floatBounds, fCropRect);
|
||||
ctx.ctm().mapRect(&floatBounds, fCropRect);
|
||||
floatBounds.roundOut(&bounds);
|
||||
|
||||
if (bounds.isEmpty()) {
|
||||
@ -84,7 +84,7 @@ bool SkPictureImageFilter::onFilterImage(Proxy* proxy, const SkBitmap&, const Sk
|
||||
SkPaint paint;
|
||||
|
||||
canvas.translate(-SkIntToScalar(bounds.fLeft), -SkIntToScalar(bounds.fTop));
|
||||
canvas.concat(matrix);
|
||||
canvas.concat(ctx.ctm());
|
||||
canvas.drawPicture(*fPicture);
|
||||
|
||||
*result = device.get()->accessBitmap(false);
|
||||
|
@ -52,12 +52,12 @@ SkRectShaderImageFilter::~SkRectShaderImageFilter() {
|
||||
|
||||
bool SkRectShaderImageFilter::onFilterImage(Proxy* proxy,
|
||||
const SkBitmap& source,
|
||||
const SkMatrix& ctm,
|
||||
const Context& ctx,
|
||||
SkBitmap* result,
|
||||
SkIPoint* offset) const {
|
||||
SkIRect bounds;
|
||||
source.getBounds(&bounds);
|
||||
if (!this->applyCropRect(&bounds, ctm)) {
|
||||
if (!this->applyCropRect(&bounds, ctx.ctm())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -69,7 +69,7 @@ bool SkRectShaderImageFilter::onFilterImage(Proxy* proxy,
|
||||
SkCanvas canvas(device.get());
|
||||
SkPaint paint;
|
||||
paint.setShader(fShader);
|
||||
SkMatrix matrix(ctm);
|
||||
SkMatrix matrix(ctx.ctm());
|
||||
matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top()));
|
||||
fShader->setLocalMatrix(matrix);
|
||||
SkRect rect = SkRect::MakeWH(SkIntToScalar(bounds.width()), SkIntToScalar(bounds.height()));
|
||||
|
@ -42,12 +42,12 @@ SkResizeImageFilter::~SkResizeImageFilter() {
|
||||
|
||||
bool SkResizeImageFilter::onFilterImage(Proxy* proxy,
|
||||
const SkBitmap& source,
|
||||
const SkMatrix& ctm,
|
||||
const Context& ctx,
|
||||
SkBitmap* result,
|
||||
SkIPoint* offset) const {
|
||||
SkBitmap src = source;
|
||||
SkIPoint srcOffset = SkIPoint::Make(0, 0);
|
||||
if (getInput(0) && !getInput(0)->filterImage(proxy, source, ctm, &src, &srcOffset)) {
|
||||
if (getInput(0) && !getInput(0)->filterImage(proxy, source, ctx, &src, &srcOffset)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -57,11 +57,11 @@ bool SkResizeImageFilter::onFilterImage(Proxy* proxy,
|
||||
srcBounds.offset(srcOffset);
|
||||
SkRect srcRect = SkRect::Make(srcBounds);
|
||||
SkMatrix matrix;
|
||||
if (!ctm.invert(&matrix)) {
|
||||
if (!ctx.ctm().invert(&matrix)) {
|
||||
return false;
|
||||
}
|
||||
matrix.postScale(fSx, fSy);
|
||||
matrix.postConcat(ctm);
|
||||
matrix.postConcat(ctx.ctm());
|
||||
matrix.mapRect(&dstRect, srcRect);
|
||||
dstRect.roundOut(&dstBounds);
|
||||
|
||||
|
@ -22,7 +22,7 @@ public:
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool SkDownSampleImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src,
|
||||
const SkMatrix&,
|
||||
const Context&,
|
||||
SkBitmap* result, SkIPoint*) const {
|
||||
SkScalar scale = fScale;
|
||||
if (scale > SK_Scalar1 || scale <= 0) {
|
||||
|
@ -16,17 +16,17 @@
|
||||
#include "SkShader.h"
|
||||
#include "SkValidationUtils.h"
|
||||
|
||||
bool SkTileImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm,
|
||||
bool SkTileImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src, const SkImageFilter::Context& ctx,
|
||||
SkBitmap* dst, SkIPoint* offset) const {
|
||||
SkBitmap source = src;
|
||||
SkImageFilter* input = getInput(0);
|
||||
SkIPoint srcOffset = SkIPoint::Make(0, 0);
|
||||
if (input && !input->filterImage(proxy, src, ctm, &source, &srcOffset)) {
|
||||
if (input && !input->filterImage(proxy, src, ctx, &source, &srcOffset)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SkRect dstRect;
|
||||
ctm.mapRect(&dstRect, fDstRect);
|
||||
ctx.ctm().mapRect(&dstRect, fDstRect);
|
||||
SkIRect dstIRect;
|
||||
dstRect.roundOut(&dstIRect);
|
||||
int w = dstIRect.width();
|
||||
@ -36,7 +36,7 @@ bool SkTileImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src, const S
|
||||
}
|
||||
|
||||
SkRect srcRect;
|
||||
ctm.mapRect(&srcRect, fSrcRect);
|
||||
ctx.ctm().mapRect(&srcRect, fSrcRect);
|
||||
SkIRect srcIRect;
|
||||
srcRect.roundOut(&srcIRect);
|
||||
srcIRect.offset(-srcOffset);
|
||||
|
@ -44,7 +44,7 @@ void SkXfermodeImageFilter::flatten(SkWriteBuffer& buffer) const {
|
||||
|
||||
bool SkXfermodeImageFilter::onFilterImage(Proxy* proxy,
|
||||
const SkBitmap& src,
|
||||
const SkMatrix& ctm,
|
||||
const Context& ctx,
|
||||
SkBitmap* dst,
|
||||
SkIPoint* offset) const {
|
||||
SkBitmap background = src, foreground = src;
|
||||
@ -52,12 +52,12 @@ bool SkXfermodeImageFilter::onFilterImage(Proxy* proxy,
|
||||
SkImageFilter* foregroundInput = getInput(1);
|
||||
SkIPoint backgroundOffset = SkIPoint::Make(0, 0);
|
||||
if (backgroundInput &&
|
||||
!backgroundInput->filterImage(proxy, src, ctm, &background, &backgroundOffset)) {
|
||||
!backgroundInput->filterImage(proxy, src, ctx, &background, &backgroundOffset)) {
|
||||
return false;
|
||||
}
|
||||
SkIPoint foregroundOffset = SkIPoint::Make(0, 0);
|
||||
if (foregroundInput &&
|
||||
!foregroundInput->filterImage(proxy, src, ctm, &foreground, &foregroundOffset)) {
|
||||
!foregroundInput->filterImage(proxy, src, ctx, &foreground, &foregroundOffset)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -67,7 +67,7 @@ bool SkXfermodeImageFilter::onFilterImage(Proxy* proxy,
|
||||
foreground.getBounds(&foregroundBounds);
|
||||
foregroundBounds.offset(foregroundOffset);
|
||||
bounds.join(foregroundBounds);
|
||||
if (!applyCropRect(&bounds, ctm)) {
|
||||
if (!applyCropRect(&bounds, ctx.ctm())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -97,19 +97,19 @@ bool SkXfermodeImageFilter::onFilterImage(Proxy* proxy,
|
||||
|
||||
bool SkXfermodeImageFilter::filterImageGPU(Proxy* proxy,
|
||||
const SkBitmap& src,
|
||||
const SkMatrix& ctm,
|
||||
const Context& ctx,
|
||||
SkBitmap* result,
|
||||
SkIPoint* offset) const {
|
||||
SkBitmap background = src;
|
||||
SkIPoint backgroundOffset = SkIPoint::Make(0, 0);
|
||||
if (getInput(0) && !getInput(0)->getInputResultGPU(proxy, src, ctm, &background,
|
||||
if (getInput(0) && !getInput(0)->getInputResultGPU(proxy, src, ctx, &background,
|
||||
&backgroundOffset)) {
|
||||
return false;
|
||||
}
|
||||
GrTexture* backgroundTex = background.getTexture();
|
||||
SkBitmap foreground = src;
|
||||
SkIPoint foregroundOffset = SkIPoint::Make(0, 0);
|
||||
if (getInput(1) && !getInput(1)->getInputResultGPU(proxy, src, ctm, &foreground,
|
||||
if (getInput(1) && !getInput(1)->getInputResultGPU(proxy, src, ctx, &foreground,
|
||||
&foregroundOffset)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1588,8 +1588,8 @@ void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap,
|
||||
|
||||
static bool filter_texture(SkBaseDevice* device, GrContext* context,
|
||||
GrTexture* texture, const SkImageFilter* filter,
|
||||
int w, int h, const SkMatrix& ctm, SkBitmap* result,
|
||||
SkIPoint* offset) {
|
||||
int w, int h, const SkImageFilter::Context& ctx,
|
||||
SkBitmap* result, SkIPoint* offset) {
|
||||
SkASSERT(filter);
|
||||
SkDeviceImageFilterProxy proxy(device);
|
||||
|
||||
@ -1597,7 +1597,7 @@ static bool filter_texture(SkBaseDevice* device, GrContext* context,
|
||||
// Save the render target and set it to NULL, so we don't accidentally draw to it in the
|
||||
// filter. Also set the clip wide open and the matrix to identity.
|
||||
GrContext::AutoWideOpenIdentityDraw awo(context, NULL);
|
||||
return filter->filterImageGPU(&proxy, wrap_texture(texture), ctm, result, offset);
|
||||
return filter->filterImageGPU(&proxy, wrap_texture(texture), ctx, result, offset);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@ -1628,7 +1628,9 @@ void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap,
|
||||
SkIPoint offset = SkIPoint::Make(0, 0);
|
||||
SkMatrix matrix(*draw.fMatrix);
|
||||
matrix.postTranslate(SkIntToScalar(-left), SkIntToScalar(-top));
|
||||
if (filter_texture(this, fContext, texture, filter, w, h, matrix, &filteredBitmap,
|
||||
SkIRect clipBounds = SkIRect::MakeWH(bitmap.width(), bitmap.height());
|
||||
SkImageFilter::Context ctx(matrix, clipBounds);
|
||||
if (filter_texture(this, fContext, texture, filter, w, h, ctx, &filteredBitmap,
|
||||
&offset)) {
|
||||
texture = (GrTexture*) filteredBitmap.getTexture();
|
||||
w = filteredBitmap.width();
|
||||
@ -1734,7 +1736,9 @@ void SkGpuDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device,
|
||||
SkIPoint offset = SkIPoint::Make(0, 0);
|
||||
SkMatrix matrix(*draw.fMatrix);
|
||||
matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y));
|
||||
if (filter_texture(this, fContext, devTex, filter, w, h, matrix, &filteredBitmap,
|
||||
SkIRect clipBounds = SkIRect::MakeWH(devTex->width(), devTex->height());
|
||||
SkImageFilter::Context ctx(matrix, clipBounds);
|
||||
if (filter_texture(this, fContext, devTex, filter, w, h, ctx, &filteredBitmap,
|
||||
&offset)) {
|
||||
devTex = filteredBitmap.getTexture();
|
||||
w = filteredBitmap.width();
|
||||
@ -1771,7 +1775,7 @@ bool SkGpuDevice::canHandleImageFilter(const SkImageFilter* filter) {
|
||||
}
|
||||
|
||||
bool SkGpuDevice::filterImage(const SkImageFilter* filter, const SkBitmap& src,
|
||||
const SkMatrix& ctm,
|
||||
const SkImageFilter::Context& ctx,
|
||||
SkBitmap* result, SkIPoint* offset) {
|
||||
// want explicitly our impl, so guard against a subclass of us overriding it
|
||||
if (!this->SkGpuDevice::canHandleImageFilter(filter)) {
|
||||
@ -1788,8 +1792,8 @@ bool SkGpuDevice::filterImage(const SkImageFilter* filter, const SkBitmap& src,
|
||||
// must be pushed upstack.
|
||||
SkAutoCachedTexture act(this, src, NULL, &texture);
|
||||
|
||||
return filter_texture(this, fContext, texture, filter, src.width(), src.height(), ctm, result,
|
||||
offset);
|
||||
return filter_texture(this, fContext, texture, filter, src.width(), src.height(), ctx,
|
||||
result, offset);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -250,7 +250,7 @@ protected:
|
||||
return false;
|
||||
}
|
||||
virtual bool filterImage(const SkImageFilter*, const SkBitmap&,
|
||||
const SkMatrix&, SkBitmap*, SkIPoint*) SK_OVERRIDE {
|
||||
const SkImageFilter::Context&, SkBitmap*, SkIPoint*) SK_OVERRIDE {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -307,7 +307,7 @@ protected:
|
||||
virtual void unlockPixels() SK_OVERRIDE { NothingToDo(); }
|
||||
virtual bool allowImageFilter(const SkImageFilter*) SK_OVERRIDE { return false; }
|
||||
virtual bool canHandleImageFilter(const SkImageFilter*) SK_OVERRIDE { return false; }
|
||||
virtual bool filterImage(const SkImageFilter*, const SkBitmap&, const SkMatrix&,
|
||||
virtual bool filterImage(const SkImageFilter*, const SkBitmap&, const SkImageFilter::Context&,
|
||||
SkBitmap* result, SkIPoint* offset) SK_OVERRIDE {
|
||||
return false;
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ public:
|
||||
virtual void unlockPixels() SK_OVERRIDE { nothing_to_do(); }
|
||||
virtual bool allowImageFilter(const SkImageFilter*) SK_OVERRIDE { return false; }
|
||||
virtual bool canHandleImageFilter(const SkImageFilter*) SK_OVERRIDE { return false; }
|
||||
virtual bool filterImage(const SkImageFilter*, const SkBitmap&, const SkMatrix&,
|
||||
virtual bool filterImage(const SkImageFilter*, const SkBitmap&, const SkImageFilter::Context&,
|
||||
SkBitmap* result, SkIPoint* offset) SK_OVERRIDE {
|
||||
return false;
|
||||
}
|
||||
|
@ -43,9 +43,9 @@ public:
|
||||
: SkImageFilter(0), fReporter(reporter), fExpectedMatrix(expectedMatrix) {
|
||||
}
|
||||
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix& ctm,
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context& ctx,
|
||||
SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE {
|
||||
REPORTER_ASSERT(fReporter, ctm == fExpectedMatrix);
|
||||
REPORTER_ASSERT(fReporter, ctx.ctm() == fExpectedMatrix);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -190,8 +190,9 @@ DEF_TEST(ImageFilter, reporter) {
|
||||
SkDeviceImageFilterProxy proxy(&device);
|
||||
SkIPoint loc = SkIPoint::Make(0, 0);
|
||||
// An empty input should early return and return false
|
||||
SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeEmpty());
|
||||
REPORTER_ASSERT(reporter,
|
||||
!bicubic->filterImage(&proxy, bitmap, SkMatrix::I(), &result, &loc));
|
||||
!bicubic->filterImage(&proxy, bitmap, ctx, &result, &loc));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -245,7 +246,8 @@ static void test_crop_rects(SkBaseDevice* device, skiatest::Reporter* reporter)
|
||||
SkIPoint offset;
|
||||
SkString str;
|
||||
str.printf("filter %d", static_cast<int>(i));
|
||||
REPORTER_ASSERT_MESSAGE(reporter, filter->filterImage(&proxy, bitmap, SkMatrix::I(), &result, &offset), str.c_str());
|
||||
SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeEmpty());
|
||||
REPORTER_ASSERT_MESSAGE(reporter, filter->filterImage(&proxy, bitmap, ctx, &result, &offset), str.c_str());
|
||||
REPORTER_ASSERT_MESSAGE(reporter, offset.fX == 20 && offset.fY == 30, str.c_str());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user