friend class SkDraw;
friend class SkDrawIter;
friend class SkDeviceFilteredPaint;
- friend class SkImageFilter::DeviceProxy;
friend class SkNoPixelsBitmapDevice;
friend class SkSurface_Raster;
kNever_TileUsage, //!< the created device will never be drawn tiled
};
- class Proxy {
- public:
- virtual ~Proxy() {}
-
- virtual SkBaseDevice* createDevice(int width, int height,
- TileUsage usage = kNever_TileUsage) = 0;
- };
-
- class DeviceProxy : public Proxy {
- public:
- DeviceProxy(SkBaseDevice* device) : fDevice(device) {}
-
- SkBaseDevice* createDevice(int width, int height,
- TileUsage usage = kNever_TileUsage) override;
-
- private:
- SkBaseDevice* fDevice;
- };
-
/**
* Request a new (result) image to be created from the src image.
*
#if SK_SUPPORT_GPU
static sk_sp<SkSpecialImage> DrawWithFP(GrContext* context,
sk_sp<GrFragmentProcessor> fp,
- const SkIRect& bounds,
- SkImageFilter::Proxy* proxy);
+ const SkIRect& bounds);
#endif
/**
* The size of the crop rect should be
* used as the size of the destination image. The origin of this rect
* should be used to offset access to the input images, and should also
- * be added to the "offset" parameter in onFilterImage and
- * filterImageGPU(). (The latter ensures that the resulting buffer is
- * drawn in the correct location.)
+ * be added to the "offset" parameter in onFilterImage.
*/
bool cropRectIsSet() const { return fCropRect.flags() != 0x0; }
}
#endif
-
- sk_sp<SkSpecialImage> filterInput(int index,
- SkSpecialImage* src,
- const Context&,
- SkIPoint* offset) const;
-
SK_TO_STRING_PUREVIRT()
SK_DEFINE_FLATTENABLE_TYPE(SkImageFilter)
* Offset is the amount to translate the resulting image relative to the
* src when it is drawn. This is an out-param.
*
- * If the result image cannot be created, this should false, in which
- * case both the result and offset parameters will be ignored by the
- * caller.
+ * If the result image cannot be created (either because of error or if, say, the result
+ * is entirely clipped out), this should return nullptr.
+ * Callers that affect transparent black should explicitly handle nullptr
+ * results and press on. In the error case this behavior will produce a better result
+ * than nothing and is necessary for the clipped out case.
+ * If the return value is nullptr then offset should be ignored.
*/
- virtual bool onFilterImageDeprecated(Proxy*, const SkBitmap& src, const Context&,
- SkBitmap* result, SkIPoint* offset) const;
-
virtual sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* src, const Context&,
- SkIPoint* offset) const;
+ SkIPoint* offset) const = 0;
/**
* This function recurses into its inputs with the given rect (first
virtual SkIRect onFilterNodeBounds(const SkIRect&, const SkMatrix&, MapDirection) const;
// Helper function which invokes filter processing on the input at the
- // specified "index". If the input is null, it leaves "result" and
- // "offset" untouched, and returns true. If the input is non-null, it
- // calls filterImage() on that input, and returns true on success.
- // i.e., return !getInput(index) || getInput(index)->filterImage(...);
- bool filterInputDeprecated(int index, Proxy*, const SkBitmap& src, const Context&,
- SkBitmap* result, SkIPoint* offset) const;
+ // specified "index". If the input is null, it returns "src" and leaves
+ // "offset" untouched. If the input is non-null, it
+ // calls filterImage() on that input, and returns the result.
+ sk_sp<SkSpecialImage> filterInput(int index,
+ SkSpecialImage* src,
+ const Context&,
+ SkIPoint* offset) const;
/**
* Return true (and return a ref'd colorfilter) if this node in the DAG is just a
static void PurgeCache();
void init(sk_sp<SkImageFilter>* inputs, int inputCount, const CropRect* cropRect);
- bool filterImageDeprecated(Proxy*, const SkBitmap& src, const Context&,
- SkBitmap* result, SkIPoint* offset) const;
bool usesSrcInput() const { return fUsesSrcInput; }
virtual bool affectsTransparentBlack() const { return false; }
SkImageFilter* filter = paint->getImageFilter();
SkIPoint pos = { x - iter.getX(), y - iter.getY() };
if (filter) {
- SkImageFilter::DeviceProxy proxy(dstDev);
SkIPoint offset = SkIPoint::Make(0, 0);
const SkBitmap& srcBM = srcDev->accessBitmap(false);
SkMatrix matrix = *iter.fMatrix;
SkAutoTUnref<SkImageFilter::Cache> cache(dstDev->getImageFilterCache());
SkImageFilter::Context ctx(matrix, clipBounds, cache.get());
- sk_sp<SkSpecialImage> srcImg(SkSpecialImage::internal_fromBM(&proxy, srcBM,
+ sk_sp<SkSpecialImage> srcImg(SkSpecialImage::internal_fromBM(srcBM,
&dstDev->surfaceProps()));
if (!srcImg) {
continue; // something disastrous happened
SkImageFilter* filter = paint.getImageFilter();
SkASSERT(filter);
- SkImageFilter::DeviceProxy proxy(this);
SkIPoint offset = SkIPoint::Make(0, 0);
SkMatrix matrix = *draw.fMatrix;
matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y));
SkAutoTUnref<SkImageFilter::Cache> cache(this->getImageFilterCache());
SkImageFilter::Context ctx(matrix, clipBounds, cache.get());
- sk_sp<SkSpecialImage> srcImg(SkSpecialImage::internal_fromBM(&proxy, bitmap,
- &this->surfaceProps()));
+ sk_sp<SkSpecialImage> srcImg(SkSpecialImage::internal_fromBM(bitmap, &this->surfaceProps()));
if (!srcImg) {
return; // something disastrous happened
}
// Keep the result on the GPU - this is still required for some
// image filters that don't support GPU in all cases
GrContext* context = src->getContext();
- result = result->makeTextureImage(src->internal_getProxy(), context);
+ result = result->makeTextureImage(context);
}
#endif
return result;
}
-bool SkImageFilter::filterImageDeprecated(Proxy* proxy, const SkBitmap& src,
- const Context& context,
- SkBitmap* result, SkIPoint* offset) const {
- SkASSERT(result);
- SkASSERT(offset);
- uint32_t srcGenID = fUsesSrcInput ? src.getGenerationID() : 0;
- Cache::Key key(fUniqueID, context.ctm(), context.clipBounds(),
- srcGenID, SkIRect::MakeWH(0, 0));
- if (context.cache()) {
- if (context.cache()->get(key, result, offset)) {
- return true;
- }
- }
- if (this->onFilterImageDeprecated(proxy, src, context, result, offset)) {
- if (context.cache()) {
- context.cache()->set(key, *result, *offset);
- SkAutoMutexAcquire mutex(fMutex);
- fCacheKeys.push_back(key);
- }
- return true;
- }
- return false;
-}
-
-bool SkImageFilter::filterInputDeprecated(int index, Proxy* proxy, const SkBitmap& src,
- const Context& ctx,
- SkBitmap* result, SkIPoint* offset) const {
- SkImageFilter* input = this->getInput(index);
- if (!input) {
- return true;
- }
-
- // SRGBTODO: Don't handle sRGB here, in anticipation of this code path being deleted.
- sk_sp<SkSpecialImage> specialSrc(SkSpecialImage::internal_fromBM(proxy, src, nullptr));
- if (!specialSrc) {
- return false;
- }
-
- sk_sp<SkSpecialImage> tmp(input->onFilterImage(specialSrc.get(),
- this->mapContext(ctx),
- offset));
- if (!tmp) {
- return false;
- }
-
- return tmp->internal_getBM(result);
-}
-
SkIRect SkImageFilter::filterBounds(const SkIRect& src, const SkMatrix& ctm,
MapDirection direction) const {
if (kReverse_MapDirection == direction) {
return true;
}
-bool SkImageFilter::onFilterImageDeprecated(Proxy*, const SkBitmap&, const Context&,
- SkBitmap*, SkIPoint*) const {
- // Only classes that now use the new SkSpecialImage-based path will not have
- // onFilterImageDeprecated methods. For those classes we should never be
- // calling this method.
- SkASSERT(0);
- return false;
-}
-
-// SkImageFilter-derived classes that do not yet have their own onFilterImage
-// implementation convert back to calling the deprecated filterImage method
-sk_sp<SkSpecialImage> SkImageFilter::onFilterImage(SkSpecialImage* src, const Context& ctx,
- SkIPoint* offset) const {
- SkBitmap srcBM, resultBM;
-
- if (!src->internal_getBM(&srcBM)) {
- return nullptr;
- }
-
- // This is the only valid call to the old filterImage path
- if (!this->filterImageDeprecated(src->internal_getProxy(), srcBM, ctx, &resultBM, offset)) {
- return nullptr;
- }
-
- return SkSpecialImage::internal_fromBM(src->internal_getProxy(), resultBM, &src->props());
-}
-
#if SK_SUPPORT_GPU
sk_sp<SkSpecialImage> SkImageFilter::DrawWithFP(GrContext* context,
sk_sp<GrFragmentProcessor> fp,
- const SkIRect& bounds,
- SkImageFilter::Proxy* proxy) {
+ const SkIRect& bounds) {
GrPaint paint;
paint.addColorFragmentProcessor(fp.get());
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
GrClip clip(dstRect);
drawContext->fillRectToRect(clip, paint, SkMatrix::I(), dstRect, srcRect);
- return SkSpecialImage::MakeFromGpu(proxy,
- SkIRect::MakeWH(bounds.width(), bounds.height()),
+ return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(bounds.width(), bounds.height()),
kNeedNewImageUniqueID_SpecialImage,
dst.get());
Cache::Get()->purge();
}
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-SkBaseDevice* SkImageFilter::DeviceProxy::createDevice(int w, int h, TileUsage usage) {
- SkBaseDevice::CreateInfo cinfo(SkImageInfo::MakeN32Premul(w, h),
- kPossible_TileUsage == usage ? SkBaseDevice::kPossible_TileUsage
- : SkBaseDevice::kNever_TileUsage,
- kUnknown_SkPixelGeometry,
- false, /* preserveLCDText */
- true /*forImageFilter*/);
- SkBaseDevice* dev = fDevice->onCreateDevice(cinfo, nullptr);
- if (nullptr == dev) {
- const SkSurfaceProps surfaceProps(fDevice->fSurfaceProps.flags(),
- kUnknown_SkPixelGeometry);
- dev = SkBitmapDevice::Create(cinfo.fInfo, surfaceProps);
- }
- return dev;
-}
///////////////////////////////////////////////////////////////////////////////
class SkSpecialImage_Base : public SkSpecialImage {
public:
- SkSpecialImage_Base(SkImageFilter::Proxy* proxy, const SkIRect& subset, uint32_t uniqueID,
- const SkSurfaceProps* props)
- : INHERITED(proxy, subset, uniqueID, props) {
+ SkSpecialImage_Base(const SkIRect& subset, uint32_t uniqueID, const SkSurfaceProps* props)
+ : INHERITED(subset, uniqueID, props) {
}
- virtual ~SkSpecialImage_Base() { }
+ ~SkSpecialImage_Base() override { }
virtual void onDraw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) const = 0;
return static_cast<const SkSpecialImage_Base*>(image);
}
-SkSpecialImage::SkSpecialImage(SkImageFilter::Proxy* proxy,
- const SkIRect& subset,
+SkSpecialImage::SkSpecialImage(const SkIRect& subset,
uint32_t uniqueID,
const SkSurfaceProps* props)
: fProps(SkSurfacePropsCopyOrDefault(props))
, fSubset(subset)
- , fUniqueID(kNeedNewImageUniqueID_SpecialImage == uniqueID ? SkNextID::ImageID() : uniqueID)
- , fProxy(proxy) {
+ , fUniqueID(kNeedNewImageUniqueID_SpecialImage == uniqueID ? SkNextID::ImageID() : uniqueID) {
}
-sk_sp<SkSpecialImage> SkSpecialImage::makeTextureImage(SkImageFilter::Proxy* proxy,
- GrContext* context) {
+sk_sp<SkSpecialImage> SkSpecialImage::makeTextureImage(GrContext* context) {
#if SK_SUPPORT_GPU
if (!context) {
return nullptr;
}
if (bmp.empty()) {
- return SkSpecialImage::MakeFromRaster(proxy, SkIRect::MakeEmpty(), bmp, &this->props());
+ return SkSpecialImage::MakeFromRaster(SkIRect::MakeEmpty(), bmp, &this->props());
}
SkAutoTUnref<GrTexture> resultTex(
SkAlphaType at = this->isOpaque() ? kOpaque_SkAlphaType : kPremul_SkAlphaType;
- return SkSpecialImage::MakeFromGpu(proxy,
- SkIRect::MakeWH(resultTex->width(), resultTex->height()),
+ return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(resultTex->width(), resultTex->height()),
this->uniqueID(),
resultTex, &this->props(), at);
#else
#include "SkGrPixelRef.h"
#endif
-sk_sp<SkSpecialImage> SkSpecialImage::internal_fromBM(SkImageFilter::Proxy* proxy,
- const SkBitmap& src,
+sk_sp<SkSpecialImage> SkSpecialImage::internal_fromBM(const SkBitmap& src,
const SkSurfaceProps* props) {
// Need to test offset case! (see skbug.com/4967)
if (src.getTexture()) {
- return SkSpecialImage::MakeFromGpu(proxy,
- src.bounds(),
+ return SkSpecialImage::MakeFromGpu(src.bounds(),
src.getGenerationID(),
src.getTexture(),
props);
}
- return SkSpecialImage::MakeFromRaster(proxy, src.bounds(), src, props);
+ return SkSpecialImage::MakeFromRaster(src.bounds(), src, props);
}
bool SkSpecialImage::internal_getBM(SkBitmap* result) {
return ib->getBitmapDeprecated(result);
}
-SkImageFilter::Proxy* SkSpecialImage::internal_getProxy() const {
- return fProxy;
-}
-
///////////////////////////////////////////////////////////////////////////////
#include "SkImage.h"
#if SK_SUPPORT_GPU
class SkSpecialImage_Image : public SkSpecialImage_Base {
public:
- SkSpecialImage_Image(SkImageFilter::Proxy* proxy,
- const SkIRect& subset,
+ SkSpecialImage_Image(const SkIRect& subset,
sk_sp<SkImage> image,
const SkSurfaceProps* props)
- : INHERITED(proxy, subset, image->uniqueID(), props)
+ : INHERITED(subset, image->uniqueID(), props)
, fImage(image) {
}
GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(info, *texture->getContext()->caps());
desc.fFlags = kRenderTarget_GrSurfaceFlag;
- return SkSpecialSurface::MakeRenderTarget(this->proxy(), texture->getContext(), desc);
+ return SkSpecialSurface::MakeRenderTarget(texture->getContext(), desc);
}
#endif
- return SkSpecialSurface::MakeRaster(this->proxy(), info, nullptr);
+ return SkSpecialSurface::MakeRaster(info, nullptr);
}
sk_sp<SkSpecialImage> onMakeSubset(const SkIRect& subset) const override {
return nullptr;
}
- return SkSpecialImage::MakeFromImage(this->internal_getProxy(),
- SkIRect::MakeWH(subset.width(), subset.height()),
+ return SkSpecialImage::MakeFromImage(SkIRect::MakeWH(subset.width(), subset.height()),
subsetImg,
&this->props());
}
}
#endif
-sk_sp<SkSpecialImage> SkSpecialImage::MakeFromImage(SkImageFilter::Proxy* proxy,
- const SkIRect& subset,
+sk_sp<SkSpecialImage> SkSpecialImage::MakeFromImage(const SkIRect& subset,
sk_sp<SkImage> image,
const SkSurfaceProps* props) {
SkASSERT(rect_fits(subset, image->width(), image->height()));
- return sk_make_sp<SkSpecialImage_Image>(proxy, subset, image, props);
+ return sk_make_sp<SkSpecialImage_Image>(subset, image, props);
}
///////////////////////////////////////////////////////////////////////////////
class SkSpecialImage_Raster : public SkSpecialImage_Base {
public:
- SkSpecialImage_Raster(SkImageFilter::Proxy* proxy, const SkIRect& subset, const SkBitmap& bm,
- const SkSurfaceProps* props)
- : INHERITED(proxy, subset, bm.getGenerationID(), props)
+ SkSpecialImage_Raster(const SkIRect& subset, const SkBitmap& bm, const SkSurfaceProps* props)
+ : INHERITED(subset, bm.getGenerationID(), props)
, fBitmap(bm) {
if (bm.pixelRef() && bm.pixelRef()->isPreLocked()) {
// we only preemptively lock if there is no chance of triggering something expensive
}
}
- SkSpecialImage_Raster(SkImageFilter::Proxy* proxy,
- const SkIRect& subset,
+ SkSpecialImage_Raster(const SkIRect& subset,
const SkPixmap& pixmap,
RasterReleaseProc releaseProc,
ReleaseContext context,
const SkSurfaceProps* props)
- : INHERITED(proxy, subset, kNeedNewImageUniqueID_SpecialImage, props) {
+ : INHERITED(subset, kNeedNewImageUniqueID_SpecialImage, props) {
fBitmap.installPixels(pixmap.info(), pixmap.writable_addr(),
pixmap.rowBytes(), pixmap.ctable(),
releaseProc, context);
}
sk_sp<SkSpecialSurface> onMakeSurface(const SkImageInfo& info) const override {
- return SkSpecialSurface::MakeRaster(this->proxy(), info, nullptr);
+ return SkSpecialSurface::MakeRaster(info, nullptr);
}
sk_sp<SkSpecialImage> onMakeSubset(const SkIRect& subset) const override {
return nullptr;
}
- return SkSpecialImage::MakeFromRaster(this->internal_getProxy(),
- SkIRect::MakeWH(subset.width(), subset.height()),
+ return SkSpecialImage::MakeFromRaster(SkIRect::MakeWH(subset.width(), subset.height()),
subsetBM,
&this->props());
}
typedef SkSpecialImage_Base INHERITED;
};
-sk_sp<SkSpecialImage> SkSpecialImage::MakeFromRaster(SkImageFilter::Proxy* proxy,
- const SkIRect& subset,
+sk_sp<SkSpecialImage> SkSpecialImage::MakeFromRaster(const SkIRect& subset,
const SkBitmap& bm,
const SkSurfaceProps* props) {
SkASSERT(nullptr == bm.getTexture());
SkASSERT(rect_fits(subset, bm.width(), bm.height()));
- return sk_make_sp<SkSpecialImage_Raster>(proxy, subset, bm, props);
+ return sk_make_sp<SkSpecialImage_Raster>(subset, bm, props);
}
-sk_sp<SkSpecialImage> SkSpecialImage::MakeFromPixmap(SkImageFilter::Proxy* proxy,
- const SkIRect& subset,
+sk_sp<SkSpecialImage> SkSpecialImage::MakeFromPixmap(const SkIRect& subset,
const SkPixmap& src,
RasterReleaseProc releaseProc,
ReleaseContext context,
return nullptr;
}
- return sk_make_sp<SkSpecialImage_Raster>(proxy, subset, src, releaseProc, context, props);
+ return sk_make_sp<SkSpecialImage_Raster>(subset, src, releaseProc, context, props);
}
class SkSpecialImage_Gpu : public SkSpecialImage_Base {
public:
- SkSpecialImage_Gpu(SkImageFilter::Proxy* proxy, const SkIRect& subset,
+ SkSpecialImage_Gpu(const SkIRect& subset,
uint32_t uniqueID, GrTexture* tex, SkAlphaType at,
const SkSurfaceProps* props)
- : INHERITED(proxy, subset, uniqueID, props)
+ : INHERITED(subset, uniqueID, props)
, fTexture(SkRef(tex))
, fAlphaType(at)
, fAddedRasterVersionToCache(false) {
GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(info, *fTexture->getContext()->caps());
desc.fFlags = kRenderTarget_GrSurfaceFlag;
- return SkSpecialSurface::MakeRenderTarget(this->proxy(), fTexture->getContext(), desc);
+ return SkSpecialSurface::MakeRenderTarget(fTexture->getContext(), desc);
}
sk_sp<SkSpecialImage> onMakeSubset(const SkIRect& subset) const override {
- return SkSpecialImage::MakeFromGpu(this->internal_getProxy(),
- subset,
+ return SkSpecialImage::MakeFromGpu(subset,
this->uniqueID(),
fTexture,
&this->props(),
typedef SkSpecialImage_Base INHERITED;
};
-sk_sp<SkSpecialImage> SkSpecialImage::MakeFromGpu(SkImageFilter::Proxy* proxy,
- const SkIRect& subset,
+sk_sp<SkSpecialImage> SkSpecialImage::MakeFromGpu(const SkIRect& subset,
uint32_t uniqueID,
GrTexture* tex,
const SkSurfaceProps* props,
SkAlphaType at) {
SkASSERT(rect_fits(subset, tex->width(), tex->height()));
- return sk_make_sp<SkSpecialImage_Gpu>(proxy, subset, uniqueID, tex, at, props);
+ return sk_make_sp<SkSpecialImage_Gpu>(subset, uniqueID, tex, at, props);
}
#else
-sk_sp<SkSpecialImage> SkSpecialImage::MakeFromGpu(SkImageFilter::Proxy* proxy,
- const SkIRect& subset,
+sk_sp<SkSpecialImage> SkSpecialImage::MakeFromGpu(const SkIRect& subset,
uint32_t uniqueID,
GrTexture* tex,
const SkSurfaceProps* props,
* transformation is required, the returned image may be the same as this special image.
* If this special image is from a different GrContext, this will fail.
*/
- sk_sp<SkSpecialImage> makeTextureImage(SkImageFilter::Proxy*, GrContext*);
+ sk_sp<SkSpecialImage> makeTextureImage(GrContext*);
/**
* Draw this SpecialImage into the canvas.
*/
void draw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) const;
- static sk_sp<SkSpecialImage> MakeFromImage(SkImageFilter::Proxy*,
- const SkIRect& subset,
+ static sk_sp<SkSpecialImage> MakeFromImage(const SkIRect& subset,
sk_sp<SkImage>,
const SkSurfaceProps* = nullptr);
- static sk_sp<SkSpecialImage> MakeFromRaster(SkImageFilter::Proxy*,
- const SkIRect& subset,
+ static sk_sp<SkSpecialImage> MakeFromRaster(const SkIRect& subset,
const SkBitmap&,
const SkSurfaceProps* = nullptr);
- static sk_sp<SkSpecialImage> MakeFromGpu(SkImageFilter::Proxy*,
- const SkIRect& subset,
+ static sk_sp<SkSpecialImage> MakeFromGpu(const SkIRect& subset,
uint32_t uniqueID,
GrTexture*,
const SkSurfaceProps* = nullptr,
SkAlphaType at = kPremul_SkAlphaType);
- static sk_sp<SkSpecialImage> MakeFromPixmap(SkImageFilter::Proxy*,
- const SkIRect& subset,
+ static sk_sp<SkSpecialImage> MakeFromPixmap(const SkIRect& subset,
const SkPixmap&,
RasterReleaseProc,
ReleaseContext,
// These three internal methods will go away (see skbug.com/4965)
bool internal_getBM(SkBitmap* result);
- static sk_sp<SkSpecialImage> internal_fromBM(SkImageFilter::Proxy*, const SkBitmap&,
- const SkSurfaceProps*);
- SkImageFilter::Proxy* internal_getProxy() const;
+ static sk_sp<SkSpecialImage> internal_fromBM(const SkBitmap&, const SkSurfaceProps*);
// TODO: hide this when GrLayerHoister uses SkSpecialImages more fully (see skbug.com/5063)
/**
bool getROPixels(SkBitmap*) const;
protected:
- SkSpecialImage(SkImageFilter::Proxy*, const SkIRect& subset, uint32_t uniqueID,
- const SkSurfaceProps*);
-
- // The following 2 are for testing and shouldn't be used.
- friend class TestingSpecialImageAccess;
- friend class TestingSpecialSurfaceAccess;
-
- // TODO: remove this ASAP (see skbug.com/4965)
- SkImageFilter::Proxy* proxy() const { return fProxy; }
+ SkSpecialImage(const SkIRect& subset, uint32_t uniqueID, const SkSurfaceProps*);
private:
const SkSurfaceProps fProps;
const SkIRect fSubset;
const uint32_t fUniqueID;
- // TODO: remove this ASAP (see skbug.com/4965)
- SkImageFilter::Proxy* fProxy;
-
typedef SkRefCnt INHERITED;
};
///////////////////////////////////////////////////////////////////////////////
class SkSpecialSurface_Base : public SkSpecialSurface {
public:
- SkSpecialSurface_Base(SkImageFilter::Proxy* proxy,
- const SkIRect& subset, const SkSurfaceProps* props)
- : INHERITED(proxy, subset, props)
+ SkSpecialSurface_Base(const SkIRect& subset, const SkSurfaceProps* props)
+ : INHERITED(subset, props)
, fCanvas(nullptr) {
}
return static_cast<SkSpecialSurface_Base*>(surface);
}
-SkSpecialSurface::SkSpecialSurface(SkImageFilter::Proxy* proxy,
- const SkIRect& subset,
+SkSpecialSurface::SkSpecialSurface(const SkIRect& subset,
const SkSurfaceProps* props)
: fProps(SkSurfacePropsCopyOrDefault(props).flags(), kUnknown_SkPixelGeometry)
- , fSubset(subset)
- , fProxy(proxy) {
+ , fSubset(subset) {
SkASSERT(fSubset.width() > 0);
SkASSERT(fSubset.height() > 0);
}
class SkSpecialSurface_Raster : public SkSpecialSurface_Base {
public:
- SkSpecialSurface_Raster(SkImageFilter::Proxy* proxy,
- SkPixelRef* pr,
+ SkSpecialSurface_Raster(SkPixelRef* pr,
const SkIRect& subset,
const SkSurfaceProps* props)
- : INHERITED(proxy, subset, props) {
+ : INHERITED(subset, props) {
const SkImageInfo& info = pr->info();
fBitmap.setInfo(info, info.minRowBytes());
~SkSpecialSurface_Raster() override { }
sk_sp<SkSpecialImage> onMakeImageSnapshot() override {
- return SkSpecialImage::MakeFromRaster(this->proxy(), this->subset(), fBitmap,
- &this->props());
+ return SkSpecialImage::MakeFromRaster(this->subset(), fBitmap, &this->props());
}
private:
typedef SkSpecialSurface_Base INHERITED;
};
-sk_sp<SkSpecialSurface> SkSpecialSurface::MakeFromBitmap(SkImageFilter::Proxy* proxy,
- const SkIRect& subset, SkBitmap& bm,
+sk_sp<SkSpecialSurface> SkSpecialSurface::MakeFromBitmap(const SkIRect& subset, SkBitmap& bm,
const SkSurfaceProps* props) {
- return sk_make_sp<SkSpecialSurface_Raster>(proxy, bm.pixelRef(), subset, props);
+ return sk_make_sp<SkSpecialSurface_Raster>(bm.pixelRef(), subset, props);
}
-sk_sp<SkSpecialSurface> SkSpecialSurface::MakeRaster(SkImageFilter::Proxy* proxy,
- const SkImageInfo& info,
+sk_sp<SkSpecialSurface> SkSpecialSurface::MakeRaster(const SkImageInfo& info,
const SkSurfaceProps* props) {
SkAutoTUnref<SkPixelRef> pr(SkMallocPixelRef::NewZeroed(info, 0, nullptr));
if (nullptr == pr.get()) {
const SkIRect subset = SkIRect::MakeWH(pr->info().width(), pr->info().height());
- return sk_make_sp<SkSpecialSurface_Raster>(proxy, pr, subset, props);
+ return sk_make_sp<SkSpecialSurface_Raster>(pr, subset, props);
}
#if SK_SUPPORT_GPU
class SkSpecialSurface_Gpu : public SkSpecialSurface_Base {
public:
- SkSpecialSurface_Gpu(SkImageFilter::Proxy* proxy,
- GrTexture* texture,
+ SkSpecialSurface_Gpu(GrTexture* texture,
const SkIRect& subset,
const SkSurfaceProps* props)
- : INHERITED(proxy, subset, props)
+ : INHERITED(subset, props)
, fTexture(SkRef(texture)) {
SkASSERT(fTexture->asRenderTarget());
~SkSpecialSurface_Gpu() override { }
sk_sp<SkSpecialImage> onMakeImageSnapshot() override {
- return SkSpecialImage::MakeFromGpu(this->proxy(), this->subset(),
+ return SkSpecialImage::MakeFromGpu(this->subset(),
kNeedNewImageUniqueID_SpecialImage, fTexture,
&this->props());
}
typedef SkSpecialSurface_Base INHERITED;
};
-sk_sp<SkSpecialSurface> SkSpecialSurface::MakeFromTexture(SkImageFilter::Proxy* proxy,
- const SkIRect& subset,
+sk_sp<SkSpecialSurface> SkSpecialSurface::MakeFromTexture(const SkIRect& subset,
GrTexture* texture,
const SkSurfaceProps* props) {
if (!texture->asRenderTarget()) {
return nullptr;
}
- return sk_make_sp<SkSpecialSurface_Gpu>(proxy, texture, subset, props);
+ return sk_make_sp<SkSpecialSurface_Gpu>(texture, subset, props);
}
-sk_sp<SkSpecialSurface> SkSpecialSurface::MakeRenderTarget(SkImageFilter::Proxy* proxy,
- GrContext* context,
+sk_sp<SkSpecialSurface> SkSpecialSurface::MakeRenderTarget(GrContext* context,
const GrSurfaceDesc& desc,
const SkSurfaceProps* props) {
if (!context || !SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag)) {
const SkIRect subset = SkIRect::MakeWH(desc.fWidth, desc.fHeight);
- return sk_make_sp<SkSpecialSurface_Gpu>(proxy, temp, subset, props);
+ return sk_make_sp<SkSpecialSurface_Gpu>(temp, subset, props);
}
#else
-sk_sp<SkSpecialSurface> SkSpecialSurface::MakeFromTexture(SkImageFilter::Proxy* proxy,
- const SkIRect& subset,
+sk_sp<SkSpecialSurface> SkSpecialSurface::MakeFromTexture(const SkIRect& subset,
GrTexture*,
const SkSurfaceProps*) {
return nullptr;
}
-sk_sp<SkSpecialSurface> SkSpecialSurface::MakeRenderTarget(SkImageFilter::Proxy* proxy,
- GrContext* context,
+sk_sp<SkSpecialSurface> SkSpecialSurface::MakeRenderTarget(GrContext* context,
const GrSurfaceDesc& desc,
const SkSurfaceProps* props) {
return nullptr;
/**
* Use an existing (renderTarget-capable) GrTexture as the backing store.
*/
- static sk_sp<SkSpecialSurface> MakeFromTexture(SkImageFilter::Proxy* proxy,
- const SkIRect& subset, GrTexture*,
+ static sk_sp<SkSpecialSurface> MakeFromTexture(const SkIRect& subset, GrTexture*,
const SkSurfaceProps* = nullptr);
/**
* Allocate a new GPU-backed SkSpecialSurface. If the requested surface cannot
* be created, nullptr will be returned.
*/
- static sk_sp<SkSpecialSurface> MakeRenderTarget(SkImageFilter::Proxy* proxy,
- GrContext*, const GrSurfaceDesc&,
+ static sk_sp<SkSpecialSurface> MakeRenderTarget(GrContext*, const GrSurfaceDesc&,
const SkSurfaceProps* = nullptr);
/**
* Use and existing SkBitmap as the backing store.
*/
- static sk_sp<SkSpecialSurface> MakeFromBitmap(SkImageFilter::Proxy* proxy,
- const SkIRect& subset, SkBitmap& bm,
+ static sk_sp<SkSpecialSurface> MakeFromBitmap(const SkIRect& subset, SkBitmap& bm,
const SkSurfaceProps* = nullptr);
/**
* If the requested surface cannot be created, or the request is not a
* supported configuration, nullptr will be returned.
*/
- static sk_sp<SkSpecialSurface> MakeRaster(SkImageFilter::Proxy* proxy,
- const SkImageInfo&,
+ static sk_sp<SkSpecialSurface> MakeRaster(const SkImageInfo&,
const SkSurfaceProps* = nullptr);
protected:
- SkSpecialSurface(SkImageFilter::Proxy*, const SkIRect& subset, const SkSurfaceProps*);
+ SkSpecialSurface(const SkIRect& subset, const SkSurfaceProps*);
// For testing only
friend class TestingSpecialSurfaceAccess;
const SkIRect& subset() const { return fSubset; }
- // TODO: remove this ASAP (see skbug.com/4965)
- SkImageFilter::Proxy* proxy() const { return fProxy; }
-
private:
const SkSurfaceProps fProps;
const SkIRect fSubset;
- // TODO: remove this ASAP (see skbug.com/4965)
- SkImageFilter::Proxy* fProxy;
-
typedef SkRefCnt INHERITED;
};
return nullptr;
}
- return DrawWithFP(context, std::move(fp), bounds, source->internal_getProxy());
+ return DrawWithFP(context, std::move(fp), bounds);
}
#endif
offset->fX = bounds.left();
offset->fY = bounds.top();
- return SkSpecialImage::MakeFromRaster(source->internal_getProxy(),
- SkIRect::MakeWH(bounds.width(), bounds.height()),
+ return SkSpecialImage::MakeFromRaster(SkIRect::MakeWH(bounds.width(), bounds.height()),
dst);
}
return nullptr;
}
- return SkSpecialImage::MakeFromGpu(source->internal_getProxy(),
- SkIRect::MakeWH(dstBounds.width(), dstBounds.height()),
+ return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(dstBounds.width(), dstBounds.height()),
kNeedNewImageUniqueID_SpecialImage,
tex, &source->props());
}
SkOpts::box_blur_xy(t, h, dstBoundsT, d, kernelSizeY3, highOffsetY, highOffsetY, h, w);
}
- return SkSpecialImage::MakeFromRaster(source->internal_getProxy(),
- SkIRect::MakeWH(dstBounds.width(),
+ return SkSpecialImage::MakeFromRaster(SkIRect::MakeWH(dstBounds.width(),
dstBounds.height()),
dst, &source->props());
}
offset->fX = bounds.left();
offset->fY = bounds.top();
- return SkSpecialImage::MakeFromGpu(source->internal_getProxy(),
- SkIRect::MakeWH(bounds.width(), bounds.height()),
+ return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(bounds.width(), bounds.height()),
kNeedNewImageUniqueID_SpecialImage,
dst);
}
offset->fX = bounds.left();
offset->fY = bounds.top();
- return SkSpecialImage::MakeFromRaster(source->internal_getProxy(),
- SkIRect::MakeWH(bounds.width(), bounds.height()),
+ return SkSpecialImage::MakeFromRaster(SkIRect::MakeWH(bounds.width(), bounds.height()),
dst);
}
if (fSrcRect == bounds && dstRect == bounds) {
// No regions cropped out or resized; return entire image.
offset->fX = offset->fY = 0;
- return SkSpecialImage::MakeFromImage(source->internal_getProxy(),
- SkIRect::MakeWH(fImage->width(), fImage->height()),
+ return SkSpecialImage::MakeFromImage(SkIRect::MakeWH(fImage->width(), fImage->height()),
fImage,
&source->props());
}
this->drawRect(drawContext.get(), inputTexture.get(), matrix, clip, bottomRight,
kBottomRight_BoundaryMode, pSrcBounds, offsetBounds);
- return SkSpecialImage::MakeFromGpu(source->internal_getProxy(),
- SkIRect::MakeWH(offsetBounds.width(), offsetBounds.height()),
+ return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(offsetBounds.width(), offsetBounds.height()),
kNeedNewImageUniqueID_SpecialImage,
dst.get());
}
break;
}
- return SkSpecialImage::MakeFromRaster(source->internal_getProxy(),
- SkIRect::MakeWH(bounds.width(), bounds.height()),
+ return SkSpecialImage::MakeFromRaster(SkIRect::MakeWH(bounds.width(), bounds.height()),
dst);
}
break;
}
- return SkSpecialImage::MakeFromRaster(source->internal_getProxy(),
- SkIRect::MakeWH(bounds.width(), bounds.height()),
- dst);
+ return SkSpecialImage::MakeFromRaster(SkIRect::MakeWH(bounds.width(), bounds.height()), dst);
}
#ifndef SK_IGNORE_TO_STRING
return nullptr;
}
- return DrawWithFP(context, std::move(fp), bounds, source->internal_getProxy());
+ return DrawWithFP(context, std::move(fp), bounds);
}
#endif
offset->fX = bounds.left();
offset->fY = bounds.top();
- return SkSpecialImage::MakeFromRaster(source->internal_getProxy(),
- SkIRect::MakeWH(bounds.width(), bounds.height()),
+ return SkSpecialImage::MakeFromRaster(SkIRect::MakeWH(bounds.width(), bounds.height()),
dst);
}
return nullptr;
}
- return DrawWithFP(context, std::move(fp), bounds, source->internal_getProxy());
+ return DrawWithFP(context, std::move(fp), bounds);
}
#endif
this->filterInteriorPixels(inputBM, &dst, interior, bounds);
this->filterBorderPixels(inputBM, &dst, right, bounds);
this->filterBorderPixels(inputBM, &dst, bottom, bounds);
- return SkSpecialImage::MakeFromRaster(source->internal_getProxy(),
- SkIRect::MakeWH(bounds.width(), bounds.height()),
+ return SkSpecialImage::MakeFromRaster(SkIRect::MakeWH(bounds.width(), bounds.height()),
dst);
}
srcTexture.reset(scratch);
}
- return SkSpecialImage::MakeFromGpu(input->internal_getProxy(),
- SkIRect::MakeWH(rect.width(), rect.height()),
+ return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(rect.width(), rect.height()),
kNeedNewImageUniqueID_SpecialImage,
srcTexture, &input->props());
}
offset->fX = bounds.left();
offset->fY = bounds.top();
- return SkSpecialImage::MakeFromRaster(source->internal_getProxy(),
- SkIRect::MakeWH(bounds.width(), bounds.height()),
+ return SkSpecialImage::MakeFromRaster(SkIRect::MakeWH(bounds.width(), bounds.height()),
dst, &source->props());
}
matrix.setTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top()));
drawContext->drawRect(GrClip::WideOpen(), paint, matrix, SkRect::Make(bounds));
- return SkSpecialImage::MakeFromGpu(source->internal_getProxy(),
- SkIRect::MakeWH(bounds.width(), bounds.height()),
+ return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(bounds.width(), bounds.height()),
kNeedNewImageUniqueID_SpecialImage,
dst.get());
}
SkAutoTUnref<SkImageFilter::Cache> cache(SkImageFilter::Cache::Create(kDefaultCacheSize));
SkImageFilter::Context filterContext(totMat, clipBounds, cache);
- SkImageFilter::DeviceProxy proxy(device);
-
// TODO: should the layer hoister store stand alone layers as SkSpecialImages internally?
const SkIRect subset = SkIRect::MakeWH(layer->texture()->width(), layer->texture()->height());
- sk_sp<SkSpecialImage> img(SkSpecialImage::MakeFromGpu(&proxy, subset,
+ sk_sp<SkSpecialImage> img(SkSpecialImage::MakeFromGpu(subset,
kNeedNewImageUniqueID_SpecialImage,
layer->texture(),
&device->surfaceProps()));
const SkIRect& full = SkIRect::MakeWH(kFullSize, kFullSize);
- sk_sp<SkSpecialImage> fullImg(SkSpecialImage::MakeFromRaster(nullptr, full, srcBM));
+ sk_sp<SkSpecialImage> fullImg(SkSpecialImage::MakeFromRaster(full, srcBM));
const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize);
- sk_sp<SkSpecialImage> subsetImg(SkSpecialImage::MakeFromRaster(nullptr, subset, srcBM));
+ sk_sp<SkSpecialImage> subsetImg(SkSpecialImage::MakeFromRaster(subset, srcBM));
test_find_existing(reporter, fullImg, subsetImg);
test_dont_find_if_diff_key(reporter, fullImg, subsetImg);
static void test_image_backed(skiatest::Reporter* reporter, const sk_sp<SkImage>& srcImage) {
const SkIRect& full = SkIRect::MakeWH(kFullSize, kFullSize);
- sk_sp<SkSpecialImage> fullImg(SkSpecialImage::MakeFromImage(nullptr, full, srcImage));
+ sk_sp<SkSpecialImage> fullImg(SkSpecialImage::MakeFromImage(full, srcImage));
const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize);
- sk_sp<SkSpecialImage> subsetImg(SkSpecialImage::MakeFromImage(nullptr, subset, srcImage));
+ sk_sp<SkSpecialImage> subsetImg(SkSpecialImage::MakeFromImage(subset, srcImage));
test_find_existing(reporter, fullImg, subsetImg);
test_dont_find_if_diff_key(reporter, fullImg, subsetImg);
const SkIRect& full = SkIRect::MakeWH(kFullSize, kFullSize);
- sk_sp<SkSpecialImage> fullImg(SkSpecialImage::MakeFromGpu(nullptr, full,
+ sk_sp<SkSpecialImage> fullImg(SkSpecialImage::MakeFromGpu(full,
kNeedNewImageUniqueID_SpecialImage,
srcTexture));
const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize);
- sk_sp<SkSpecialImage> subsetImg(SkSpecialImage::MakeFromGpu(nullptr, subset,
+ sk_sp<SkSpecialImage> subsetImg(SkSpecialImage::MakeFromGpu(subset,
kNeedNewImageUniqueID_SpecialImage,
srcTexture));
*/
#include "SkBitmap.h"
-#include "SkBitmapDevice.h"
#include "SkBlurImageFilter.h"
#include "SkCanvas.h"
#include "SkColorFilterImageFilter.h"
#include "SkTileImageFilter.h"
#include "SkXfermodeImageFilter.h"
#include "Test.h"
-#include "TestingSpecialImageAccess.h"
#if SK_SUPPORT_GPU
#include "GrContext.h"
-#include "SkGpuDevice.h"
#endif
static const int kBitmapSize = 4;
return SkColorFilterImageFilter::Make(std::move(filter), std::move(input), cropRect);
}
-static sk_sp<SkSpecialSurface> create_empty_special_surface(GrContext* context,
- SkImageFilter::Proxy* proxy,
- int widthHeight) {
+static sk_sp<SkSpecialSurface> create_empty_special_surface(GrContext* context, int widthHeight) {
if (context) {
GrSurfaceDesc desc;
desc.fConfig = kSkia8888_GrPixelConfig;
desc.fFlags = kRenderTarget_GrSurfaceFlag;
desc.fWidth = widthHeight;
desc.fHeight = widthHeight;
- return SkSpecialSurface::MakeRenderTarget(proxy, context, desc);
+ return SkSpecialSurface::MakeRenderTarget(context, desc);
} else {
const SkImageInfo info = SkImageInfo::MakeN32(widthHeight, widthHeight,
kOpaque_SkAlphaType);
- return SkSpecialSurface::MakeRaster(proxy, info);
+ return SkSpecialSurface::MakeRaster(info);
}
}
-static sk_sp<SkSpecialImage> create_empty_special_image(GrContext* context,
- SkImageFilter::Proxy* proxy,
- int widthHeight) {
- sk_sp<SkSpecialSurface> surf(create_empty_special_surface(context, proxy, widthHeight));
+static sk_sp<SkSpecialImage> create_empty_special_image(GrContext* context, int widthHeight) {
+ sk_sp<SkSpecialSurface> surf(create_empty_special_surface(context, widthHeight));
SkASSERT(surf);
}
}
-static void test_crop_rects(SkImageFilter::Proxy* proxy,
- skiatest::Reporter* reporter,
+static void test_crop_rects(skiatest::Reporter* reporter,
GrContext* context) {
// Check that all filters offset to their absolute crop rect,
// unaffected by the input crop rect.
// Tests pass by not asserting.
- sk_sp<SkSpecialImage> srcImg(create_empty_special_image(context, proxy, 100));
+ sk_sp<SkSpecialImage> srcImg(create_empty_special_image(context, 100));
SkASSERT(srcImg);
SkImageFilter::CropRect inputCropRect(SkRect::MakeXYWH(8, 13, 80, 80));
}
}
-static void test_negative_blur_sigma(SkImageFilter::Proxy* proxy,
- skiatest::Reporter* reporter,
+static void test_negative_blur_sigma(skiatest::Reporter* reporter,
GrContext* context) {
// Check that SkBlurImageFilter will accept a negative sigma, either in
// the given arguments or after CTM application.
sk_sp<SkImageFilter> negativeFilter(SkBlurImageFilter::Make(-five, five, nullptr));
SkBitmap gradient = make_gradient_circle(width, height);
- sk_sp<SkSpecialImage> imgSrc(SkSpecialImage::MakeFromRaster(proxy,
- SkIRect::MakeWH(width, height),
+ sk_sp<SkSpecialImage> imgSrc(SkSpecialImage::MakeFromRaster(SkIRect::MakeWH(width, height),
gradient));
SkIPoint offset;
}
}
-typedef void (*PFTest)(SkImageFilter::Proxy* proxy,
- skiatest::Reporter* reporter,
- GrContext* context);
-
-static void run_raster_test(skiatest::Reporter* reporter,
- int widthHeight,
- PFTest test) {
- const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
-
- const SkImageInfo info = SkImageInfo::MakeN32Premul(widthHeight, widthHeight);
-
- sk_sp<SkBaseDevice> device(SkBitmapDevice::Create(info, props));
- SkImageFilter::DeviceProxy proxy(device.get());
-
- (*test)(&proxy, reporter, nullptr);
-}
-
-#if SK_SUPPORT_GPU
-static void run_gpu_test(skiatest::Reporter* reporter,
- GrContext* context,
- int widthHeight,
- PFTest test) {
- const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
-
- sk_sp<SkGpuDevice> device(SkGpuDevice::Create(context,
- SkBudgeted::kNo,
- SkImageInfo::MakeN32Premul(widthHeight,
- widthHeight),
- 0,
- &props,
- SkGpuDevice::kUninit_InitContents));
- SkImageFilter::DeviceProxy proxy(device.get());
-
- (*test)(&proxy, reporter, context);
-}
-#endif
-
DEF_TEST(ImageFilterNegativeBlurSigma, reporter) {
- run_raster_test(reporter, 100, test_negative_blur_sigma);
+ test_negative_blur_sigma(reporter, nullptr);
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageFilterNegativeBlurSigma_Gpu, reporter, ctxInfo) {
- run_gpu_test(reporter, ctxInfo.fGrContext, 100, test_negative_blur_sigma);
+ test_negative_blur_sigma(reporter, ctxInfo.fGrContext);
}
#endif
-static void test_zero_blur_sigma(SkImageFilter::Proxy* proxy,
- skiatest::Reporter* reporter,
- GrContext* context) {
+static void test_zero_blur_sigma(skiatest::Reporter* reporter, GrContext* context) {
// Check that SkBlurImageFilter with a zero sigma and a non-zero srcOffset works correctly.
SkImageFilter::CropRect cropRect(SkRect::Make(SkIRect::MakeXYWH(5, 0, 5, 10)));
sk_sp<SkImageFilter> input(SkOffsetImageFilter::Make(0, 0, nullptr, &cropRect));
sk_sp<SkImageFilter> filter(SkBlurImageFilter::Make(0, 0, std::move(input), &cropRect));
- sk_sp<SkSpecialSurface> surf(create_empty_special_surface(context, proxy, 10));
+ sk_sp<SkSpecialSurface> surf(create_empty_special_surface(context, 10));
surf->getCanvas()->clear(SK_ColorGREEN);
sk_sp<SkSpecialImage> image(surf->makeImageSnapshot());
}
DEF_TEST(ImageFilterZeroBlurSigma, reporter) {
- run_raster_test(reporter, 100, test_zero_blur_sigma);
+ test_zero_blur_sigma(reporter, nullptr);
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageFilterZeroBlurSigma_Gpu, reporter, ctxInfo) {
- run_gpu_test(reporter, ctxInfo.fGrContext, 100, test_zero_blur_sigma);
+ test_zero_blur_sigma(reporter, ctxInfo.fGrContext);
}
#endif
// Tests that, even when an upstream filter has returned null (due to failure or clipping), a
// downstream filter that affects transparent black still does so even with a nullptr input.
-static void test_fail_affects_transparent_black(SkImageFilter::Proxy* proxy,
- skiatest::Reporter* reporter,
- GrContext* context) {
+static void test_fail_affects_transparent_black(skiatest::Reporter* reporter, GrContext* context) {
sk_sp<FailImageFilter> failFilter(new FailImageFilter());
- sk_sp<SkSpecialImage> source(create_empty_special_image(context, proxy, 5));
+ sk_sp<SkSpecialImage> source(create_empty_special_image(context, 5));
SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeXYWH(0, 0, 1, 1), nullptr);
sk_sp<SkColorFilter> green(SkColorFilter::MakeModeFilter(SK_ColorGREEN, SkXfermode::kSrc_Mode));
SkASSERT(green->affectsTransparentBlack());
}
DEF_TEST(ImageFilterFailAffectsTransparentBlack, reporter) {
- run_raster_test(reporter, 100, test_fail_affects_transparent_black);
+ test_fail_affects_transparent_black(reporter, nullptr);
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageFilterFailAffectsTransparentBlack_Gpu, reporter, ctxInfo) {
- run_gpu_test(reporter, ctxInfo.fGrContext, 100, test_fail_affects_transparent_black);
+ test_fail_affects_transparent_black(reporter, ctxInfo.fGrContext);
}
#endif
}
}
-static void test_imagefilter_merge_result_size(SkImageFilter::Proxy* proxy,
- skiatest::Reporter* reporter,
- GrContext* context) {
+static void test_imagefilter_merge_result_size(skiatest::Reporter* reporter, GrContext* context) {
SkBitmap greenBM;
greenBM.allocN32Pixels(20, 20);
greenBM.eraseColor(SK_ColorGREEN);
sk_sp<SkImageFilter> source(SkImageSource::Make(std::move(greenImage)));
sk_sp<SkImageFilter> merge(SkMergeImageFilter::Make(source, source));
- sk_sp<SkSpecialImage> srcImg(create_empty_special_image(context, proxy, 1));
+ sk_sp<SkSpecialImage> srcImg(create_empty_special_image(context, 1));
SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeXYWH(0, 0, 100, 100), nullptr);
SkIPoint offset;
}
DEF_TEST(ImageFilterMergeResultSize, reporter) {
- run_raster_test(reporter, 100, test_imagefilter_merge_result_size);
+ test_imagefilter_merge_result_size(reporter, nullptr);
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ImageFilterMergeResultSize_Gpu, reporter, ctxInfo) {
- run_gpu_test(reporter, ctxInfo.fGrContext, 100, test_imagefilter_merge_result_size);
+ test_imagefilter_merge_result_size(reporter, ctxInfo.fGrContext);
}
#endif
canvas.restore();
}
-static void test_big_kernel(SkImageFilter::Proxy* proxy,
- skiatest::Reporter* reporter,
- GrContext* context) {
+static void test_big_kernel(skiatest::Reporter* reporter, GrContext* context) {
// Check that a kernel that is too big for the GPU still works
SkScalar identityKernel[49] = {
0, 0, 0, 0, 0, 0, 0,
SkMatrixConvolutionImageFilter::kClamp_TileMode,
true, nullptr));
- sk_sp<SkSpecialImage> srcImg(create_empty_special_image(context, proxy, 100));
+ sk_sp<SkSpecialImage> srcImg(create_empty_special_image(context, 100));
SkASSERT(srcImg);
SkIPoint offset;
}
DEF_TEST(ImageFilterMatrixConvolutionBigKernel, reporter) {
- run_raster_test(reporter, 100, test_big_kernel);
+ test_big_kernel(reporter, nullptr);
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ImageFilterMatrixConvolutionBigKernel_Gpu,
reporter, ctxInfo) {
- run_gpu_test(reporter, ctxInfo.fGrContext, 100, test_big_kernel);
+ test_big_kernel(reporter, ctxInfo.fGrContext);
}
#endif
DEF_TEST(ImageFilterCropRect, reporter) {
- run_raster_test(reporter, 100, test_crop_rects);
+ test_crop_rects(reporter, nullptr);
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageFilterCropRect_Gpu, reporter, ctxInfo) {
- run_gpu_test(reporter, ctxInfo.fGrContext, 100, test_crop_rects);
+ test_crop_rects(reporter, ctxInfo.fGrContext);
}
#endif
? pixel != SK_ColorGREEN : pixel == SK_ColorGREEN);
}
-static void test_clipped_picture_imagefilter(SkImageFilter::Proxy* proxy,
- skiatest::Reporter* reporter,
- GrContext* context) {
+static void test_clipped_picture_imagefilter(skiatest::Reporter* reporter, GrContext* context) {
sk_sp<SkPicture> picture;
{
picture = recorder.finishRecordingAsPicture();
}
- sk_sp<SkSpecialImage> srcImg(create_empty_special_image(context, proxy, 2));
+ sk_sp<SkSpecialImage> srcImg(create_empty_special_image(context, 2));
sk_sp<SkImageFilter> imageFilter(SkPictureImageFilter::Make(picture));
}
DEF_TEST(ImageFilterClippedPictureImageFilter, reporter) {
- run_raster_test(reporter, 2, test_clipped_picture_imagefilter);
+ test_clipped_picture_imagefilter(reporter, nullptr);
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageFilterClippedPictureImageFilter_Gpu, reporter, ctxInfo) {
- run_gpu_test(reporter, ctxInfo.fGrContext, 2, test_clipped_picture_imagefilter);
+ test_clipped_picture_imagefilter(reporter, ctxInfo.fGrContext);
}
#endif
test_xfermode_cropped_input(&canvas, reporter);
}
-static void test_composed_imagefilter_offset(SkImageFilter::Proxy* proxy,
- skiatest::Reporter* reporter,
- GrContext* context) {
- sk_sp<SkSpecialImage> srcImg(create_empty_special_image(context, proxy, 100));
+static void test_composed_imagefilter_offset(skiatest::Reporter* reporter, GrContext* context) {
+ sk_sp<SkSpecialImage> srcImg(create_empty_special_image(context, 100));
SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(1, 0, 20, 20));
sk_sp<SkImageFilter> offsetFilter(SkOffsetImageFilter::Make(0, 0, nullptr, &cropRect));
}
DEF_TEST(ComposedImageFilterOffset, reporter) {
- run_raster_test(reporter, 100, test_composed_imagefilter_offset);
+ test_composed_imagefilter_offset(reporter, nullptr);
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ComposedImageFilterOffset_Gpu, reporter, ctxInfo) {
- run_gpu_test(reporter, ctxInfo.fGrContext, 100, test_composed_imagefilter_offset);
+ test_composed_imagefilter_offset(reporter, ctxInfo.fGrContext);
}
#endif
-static void test_composed_imagefilter_bounds(SkImageFilter::Proxy* proxy,
- skiatest::Reporter* reporter,
- GrContext* context) {
+static void test_composed_imagefilter_bounds(skiatest::Reporter* reporter, GrContext* context) {
// The bounds passed to the inner filter must be filtered by the outer
// filter, so that the inner filter produces the pixels that the outer
// filter requires as input. This matters if the outer filter moves pixels.
sk_sp<SkImageFilter> composedFilter(SkComposeImageFilter::Make(std::move(offsetFilter),
std::move(pictureFilter)));
- sk_sp<SkSpecialImage> sourceImage(create_empty_special_image(context, proxy, 100));
+ sk_sp<SkSpecialImage> sourceImage(create_empty_special_image(context, 100));
SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeWH(100, 100), nullptr);
SkIPoint offset;
sk_sp<SkSpecialImage> result(composedFilter->filterImage(sourceImage.get(), ctx, &offset));
}
DEF_TEST(ComposedImageFilterBounds, reporter) {
- run_raster_test(reporter, 100, test_composed_imagefilter_bounds);
+ test_composed_imagefilter_bounds(reporter, nullptr);
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ComposedImageFilterBounds_Gpu, reporter, ctxInfo) {
- run_gpu_test(reporter, ctxInfo.fGrContext, 100, test_composed_imagefilter_bounds);
+ test_composed_imagefilter_bounds(reporter, ctxInfo.fGrContext);
}
#endif
-static void test_partial_crop_rect(SkImageFilter::Proxy* proxy,
- skiatest::Reporter* reporter,
- GrContext* context) {
- sk_sp<SkSpecialImage> srcImg(create_empty_special_image(context, proxy, 100));
+static void test_partial_crop_rect(skiatest::Reporter* reporter, GrContext* context) {
+ sk_sp<SkSpecialImage> srcImg(create_empty_special_image(context, 100));
SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(100, 0, 20, 30),
SkImageFilter::CropRect::kHasWidth_CropEdge | SkImageFilter::CropRect::kHasHeight_CropEdge);
}
DEF_TEST(ImageFilterPartialCropRect, reporter) {
- run_raster_test(reporter, 100, test_partial_crop_rect);
+ test_partial_crop_rect(reporter, nullptr);
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageFilterPartialCropRect_Gpu, reporter, ctxInfo) {
- run_gpu_test(reporter, ctxInfo.fGrContext, 100, test_partial_crop_rect);
+ test_partial_crop_rect(reporter, ctxInfo.fGrContext);
}
#endif
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageFilterHugeBlur_Gpu, reporter, ctxInfo) {
- const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
- sk_sp<SkGpuDevice> device(SkGpuDevice::Create(ctxInfo.fGrContext,
- SkBudgeted::kNo,
- SkImageInfo::MakeN32Premul(100, 100),
- 0,
- &props,
- SkGpuDevice::kUninit_InitContents));
- SkCanvas canvas(device.get());
+ sk_sp<SkSurface> surf(SkSurface::MakeRenderTarget(ctxInfo.fGrContext,
+ SkBudgeted::kNo,
+ SkImageInfo::MakeN32Premul(100, 100)));
- test_huge_blur(&canvas, reporter);
+
+ SkCanvas* canvas = surf->getCanvas();
+
+ test_huge_blur(canvas, reporter);
}
DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(XfermodeImageFilterCroppedInput_Gpu, reporter, ctxInfo) {
- const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
- sk_sp<SkGpuDevice> device(SkGpuDevice::Create(ctxInfo.fGrContext,
- SkBudgeted::kNo,
- SkImageInfo::MakeN32Premul(1, 1),
- 0,
- &props,
- SkGpuDevice::kUninit_InitContents));
- SkCanvas canvas(device.get());
+ sk_sp<SkSurface> surf(SkSurface::MakeRenderTarget(ctxInfo.fGrContext,
+ SkBudgeted::kNo,
+ SkImageInfo::MakeN32Premul(1, 1)));
- test_xfermode_cropped_input(&canvas, reporter);
+
+ SkCanvas* canvas = surf->getCanvas();
+
+ test_xfermode_cropped_input(canvas, reporter);
}
DEF_GPUTEST_FOR_ALL_GL_CONTEXTS(ImageFilterBlurLargeImage_Gpu, reporter, ctxInfo) {
#include "SkSpecialSurface.h"
#include "SkSurface.h"
#include "Test.h"
-#include "TestingSpecialImageAccess.h"
#if SK_SUPPORT_GPU
#include "GrContext.h"
static void test_image(const sk_sp<SkSpecialImage>& img, skiatest::Reporter* reporter,
GrContext* context, bool peekTextureSucceeds,
int offset, int size) {
- const SkIRect subset = TestingSpecialImageAccess::Subset(img.get());
+ const SkIRect subset = img->subset();
REPORTER_ASSERT(reporter, offset == subset.left());
REPORTER_ASSERT(reporter, offset == subset.top());
REPORTER_ASSERT(reporter, kSmallerSize == subset.width());
SkBitmap bm = create_bm();
sk_sp<SkSpecialImage> fullSImage(SkSpecialImage::MakeFromRaster(
- nullptr,
SkIRect::MakeWH(kFullSize, kFullSize),
bm));
const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize);
{
- sk_sp<SkSpecialImage> subSImg1(SkSpecialImage::MakeFromRaster(nullptr, subset, bm));
+ sk_sp<SkSpecialImage> subSImg1(SkSpecialImage::MakeFromRaster(subset, bm));
test_image(subSImg1, reporter, nullptr, false, kPad, kFullSize);
}
sk_sp<SkImage> fullImage(SkImage::MakeFromBitmap(bm));
sk_sp<SkSpecialImage> fullSImage(SkSpecialImage::MakeFromImage(
- nullptr,
SkIRect::MakeWH(kFullSize, kFullSize),
fullImage));
const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize);
{
- sk_sp<SkSpecialImage> subSImg1(SkSpecialImage::MakeFromImage(nullptr, subset,
- fullImage));
+ sk_sp<SkSpecialImage> subSImg1(SkSpecialImage::MakeFromImage(subset, fullImage));
test_image(subSImg1, reporter, nullptr, false, kPad, kFullSize);
}
pixmap.erase(SK_ColorRED, subset);
{
- sk_sp<SkSpecialImage> img(SkSpecialImage::MakeFromPixmap(nullptr, subset, pixmap,
+ sk_sp<SkSpecialImage> img(SkSpecialImage::MakeFromPixmap(subset, pixmap,
nullptr, nullptr));
test_image(img, reporter, nullptr, false, kPad, kFullSize);
}
{
// raster
sk_sp<SkSpecialImage> rasterImage(SkSpecialImage::MakeFromRaster(
- nullptr,
SkIRect::MakeWH(kFullSize,
kFullSize),
bm));
{
- sk_sp<SkSpecialImage> fromRaster(rasterImage->makeTextureImage(nullptr, context));
+ sk_sp<SkSpecialImage> fromRaster(rasterImage->makeTextureImage(context));
test_texture_backed(reporter, rasterImage, fromRaster);
}
{
sk_sp<SkSpecialImage> subRasterImage(rasterImage->makeSubset(subset));
- sk_sp<SkSpecialImage> fromSubRaster(subRasterImage->makeTextureImage(nullptr, context));
+ sk_sp<SkSpecialImage> fromSubRaster(subRasterImage->makeTextureImage(context));
test_texture_backed(reporter, subRasterImage, fromSubRaster);
}
}
}
sk_sp<SkSpecialImage> gpuImage(SkSpecialImage::MakeFromGpu(
- nullptr,
SkIRect::MakeWH(kFullSize,
kFullSize),
kNeedNewImageUniqueID_SpecialImage,
texture));
{
- sk_sp<SkSpecialImage> fromGPU(gpuImage->makeTextureImage(nullptr, context));
+ sk_sp<SkSpecialImage> fromGPU(gpuImage->makeTextureImage(context));
test_texture_backed(reporter, gpuImage, fromGPU);
}
{
sk_sp<SkSpecialImage> subGPUImage(gpuImage->makeSubset(subset));
- sk_sp<SkSpecialImage> fromSubGPU(subGPUImage->makeTextureImage(nullptr, context));
+ sk_sp<SkSpecialImage> fromSubGPU(subGPUImage->makeTextureImage(context));
test_texture_backed(reporter, subGPUImage, fromSubGPU);
}
}
}
sk_sp<SkSpecialImage> fullSImg(SkSpecialImage::MakeFromGpu(
- nullptr,
SkIRect::MakeWH(kFullSize, kFullSize),
kNeedNewImageUniqueID_SpecialImage,
texture));
{
sk_sp<SkSpecialImage> subSImg1(SkSpecialImage::MakeFromGpu(
- nullptr, subset,
+ subset,
kNeedNewImageUniqueID_SpecialImage,
texture));
test_image(subSImg1, reporter, context, true, kPad, kFullSize);
static const SkIRect& Subset(const SkSpecialSurface* surf) {
return surf->subset();
}
-
- static const SkIRect& Subset(const SkSpecialImage* img) {
- return img->subset();
- }
};
// Both 'kSmallerSize' and 'kFullSize' need to be a non-power-of-2 to exercise
sk_sp<SkSpecialImage> img(surf->makeImageSnapshot());
REPORTER_ASSERT(reporter, img);
- const SkIRect imgSubset = TestingSpecialSurfaceAccess::Subset(img.get());
+ const SkIRect imgSubset = img->subset();
REPORTER_ASSERT(reporter, surfSubset == imgSubset);
// the canvas was invalidated by the newImageSnapshot call
DEF_TEST(SpecialSurface_Raster, reporter) {
SkImageInfo info = SkImageInfo::MakeN32(kSmallerSize, kSmallerSize, kOpaque_SkAlphaType);
- sk_sp<SkSpecialSurface> surf(SkSpecialSurface::MakeRaster(nullptr, info));
+ sk_sp<SkSpecialSurface> surf(SkSpecialSurface::MakeRaster(info));
test_surface(surf, reporter, 0);
}
const SkIRect subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize);
- sk_sp<SkSpecialSurface> surf(SkSpecialSurface::MakeFromBitmap(nullptr, subset, bm));
+ sk_sp<SkSpecialSurface> surf(SkSpecialSurface::MakeFromBitmap(subset, bm));
test_surface(surf, reporter, kPad);
desc.fWidth = kSmallerSize;
desc.fHeight = kSmallerSize;
- sk_sp<SkSpecialSurface> surf(SkSpecialSurface::MakeRenderTarget(nullptr, ctxInfo.fGrContext,
- desc));
+ sk_sp<SkSpecialSurface> surf(SkSpecialSurface::MakeRenderTarget(ctxInfo.fGrContext, desc));
test_surface(surf, reporter, 0);
}
const SkIRect subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize);
- sk_sp<SkSpecialSurface> surf(SkSpecialSurface::MakeFromTexture(nullptr, subset, temp));
+ sk_sp<SkSpecialSurface> surf(SkSpecialSurface::MakeFromTexture(subset, temp));
test_surface(surf, reporter, kPad);
+++ /dev/null
-/*
- * Copyright 2016 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file
- */
-
-#ifndef TestingSpecialImageAccess_DEFINED
-#define TestingSpecialImageAccess_DEFINED
-
-class TestingSpecialImageAccess {
-public:
- static const SkIRect& Subset(const SkSpecialImage* img) {
- return img->subset();
- }
-};
-
-#endif