Reland "Migrate SkImage::makeWithFilter to GrRecordingContext"
This reverts commitd13b97f94c
. Reason for revert: Fixed chromium canary Original change's description: > Revert "Migrate SkImage::makeWithFilter to GrRecordingContext" > > This reverts commit7f0129d424
. > > Reason for revert: Broke Chrome roll > > Original change's description: > > Migrate SkImage::makeWithFilter to GrRecordingContext > > > > The staging flag landed in Chrome CL 2307531. > > > > Bug: skia:104662 > > Change-Id: I8a483bfb83e890bb0566cd252a464a6add89df4f > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/304003 > > Reviewed-by: Robert Phillips <robertphillips@google.com> > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > Commit-Queue: Adlai Holler <adlai@google.com> > > TBR=bsalomon@google.com,robertphillips@google.com,adlai@google.com > > Change-Id: I280dbffa26da71d53872266e62fa3bcaa3c00989 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia:104662 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/304802 > Reviewed-by: Adlai Holler <adlai@google.com> > Commit-Queue: Adlai Holler <adlai@google.com> TBR=bsalomon@google.com,robertphillips@google.com,adlai@google.com Bug: skia:104662 Change-Id: I815677659f776966b1c7e362ce3df444834dd482 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/304803 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com> Auto-Submit: Adlai Holler <adlai@google.com>
This commit is contained in:
parent
01373555fe
commit
247835b6c8
@ -73,9 +73,9 @@ protected:
|
||||
SkIPoint offset = SkIPoint::Make(0, 0);
|
||||
SkIRect discardSubset;
|
||||
|
||||
auto direct = GrAsDirectContext(canvas->recordingContext());
|
||||
auto dContext = GrAsDirectContext(canvas->recordingContext());
|
||||
// makeWithFilter will only use the GPU backend if the image is already a texture
|
||||
sk_sp<SkImage> image = fImage->makeTextureImage(direct);
|
||||
sk_sp<SkImage> image = fImage->makeTextureImage(dContext);
|
||||
if (!image) {
|
||||
image = fImage;
|
||||
}
|
||||
@ -90,8 +90,8 @@ protected:
|
||||
|
||||
// But measure makeWithFilter() per loop since that's the focus of this benchmark
|
||||
for (int j = 0; j < loops; j++) {
|
||||
image = image->makeWithFilter(mergeFilter.get(), subset, subset, &discardSubset,
|
||||
&offset);
|
||||
image = image->makeWithFilter(dContext, mergeFilter.get(), subset, subset,
|
||||
&discardSubset, &offset);
|
||||
SkASSERT(image && image->dimensions() == fImage->dimensions());
|
||||
}
|
||||
}
|
||||
|
@ -12,8 +12,8 @@ void draw(SkCanvas* canvas) {
|
||||
clipBounds.outset(60, 60);
|
||||
SkIRect outSubset;
|
||||
SkIPoint offset;
|
||||
sk_sp<SkImage> filtered(image->makeWithFilter(offsetFilter.get(), subset, clipBounds,
|
||||
&outSubset, &offset));
|
||||
sk_sp<SkImage> filtered(image->makeWithFilter(canvas->recordingContext(), offsetFilter.get(),
|
||||
subset, clipBounds, &outSubset, &offset));
|
||||
SkPaint paint;
|
||||
paint.setAntiAlias(true);
|
||||
paint.setStyle(SkPaint::kStroke_Style);
|
||||
|
@ -271,20 +271,20 @@ protected:
|
||||
// code paths (otherwise they may choose to do CPU filtering then upload)
|
||||
sk_sp<SkImage> mainImage, auxImage;
|
||||
|
||||
auto recording = canvas->recordingContext();
|
||||
if (recording) {
|
||||
// In a DDL context, we can't use the GPU code paths and we will drop the work – skip.
|
||||
auto direct = GrAsDirectContext(recording);
|
||||
if (!direct) {
|
||||
auto rContext = canvas->recordingContext();
|
||||
// In a DDL context, we can't use the GPU code paths and we will drop the work – skip.
|
||||
auto dContext = GrAsDirectContext(rContext);
|
||||
if (rContext) {
|
||||
if (!dContext) {
|
||||
*errorMsg = "Requires a direct context.";
|
||||
return DrawResult::kSkip;
|
||||
}
|
||||
if (direct->abandoned()) {
|
||||
if (dContext->abandoned()) {
|
||||
*errorMsg = "Direct context abandoned.";
|
||||
return DrawResult::kSkip;
|
||||
}
|
||||
mainImage = fMainImage->makeTextureImage(direct);
|
||||
auxImage = fAuxImage->makeTextureImage(direct);
|
||||
mainImage = fMainImage->makeTextureImage(dContext);
|
||||
auxImage = fAuxImage->makeTextureImage(dContext);
|
||||
} else {
|
||||
mainImage = fMainImage;
|
||||
auxImage = fAuxImage;
|
||||
@ -292,8 +292,8 @@ protected:
|
||||
if (!mainImage || !auxImage) {
|
||||
return DrawResult::kFail;
|
||||
}
|
||||
SkASSERT(mainImage && (mainImage->isTextureBacked() || !recording));
|
||||
SkASSERT(auxImage && (auxImage->isTextureBacked() || !recording));
|
||||
SkASSERT(mainImage && (mainImage->isTextureBacked() || !rContext));
|
||||
SkASSERT(auxImage && (auxImage->isTextureBacked() || !rContext));
|
||||
|
||||
SkScalar MARGIN = SkIntToScalar(40);
|
||||
SkScalar DX = mainImage->width() + MARGIN;
|
||||
@ -376,7 +376,9 @@ private:
|
||||
SkIRect outSubset;
|
||||
SkIPoint offset;
|
||||
|
||||
result = mainImage->makeWithFilter(filter.get(), subset, clip, &outSubset, &offset);
|
||||
auto rContext = canvas->recordingContext();
|
||||
result = mainImage->makeWithFilter(rContext, filter.get(), subset, clip,
|
||||
&outSubset, &offset);
|
||||
|
||||
SkASSERT(result);
|
||||
SkASSERT(mainImage->isTextureBacked() == result->isTextureBacked());
|
||||
|
@ -35,7 +35,6 @@ class GrContext;
|
||||
class GrDirectContext;
|
||||
class GrRecordingContext;
|
||||
class GrContextThreadSafeProxy;
|
||||
class GrRecordingContext;
|
||||
|
||||
struct SkYUVAIndex;
|
||||
|
||||
@ -1253,7 +1252,8 @@ public:
|
||||
is required storage for the actual bounds of the filtered SkImage. offset is
|
||||
required storage for translation of returned SkImage.
|
||||
|
||||
Returns nullptr if SkImage could not be created. If nullptr is returned, outSubset
|
||||
Returns nullptr if SkImage could not be created or if the recording context provided doesn't
|
||||
match the GPU context in which the image was created. If nullptr is returned, outSubset
|
||||
and offset are undefined.
|
||||
|
||||
Useful for animation of SkImageFilter that varies size from frame to frame.
|
||||
@ -1262,7 +1262,7 @@ public:
|
||||
of GPU texture returned. offset translates the returned SkImage to keep subsequent
|
||||
animation frames aligned with respect to each other.
|
||||
|
||||
@param context the GrContext in play - if it exists
|
||||
@param context the GrRecordingContext in play - if it exists
|
||||
@param filter how SkImage is sampled when transformed
|
||||
@param subset bounds of SkImage processed by filter
|
||||
@param clipBounds expected bounds of filtered SkImage
|
||||
@ -1270,16 +1270,16 @@ public:
|
||||
@param offset storage for returned SkImage translation
|
||||
@return filtered SkImage, or nullptr
|
||||
*/
|
||||
sk_sp<SkImage> makeWithFilter(GrContext* context,
|
||||
sk_sp<SkImage> makeWithFilter(GrRecordingContext* context,
|
||||
const SkImageFilter* filter, const SkIRect& subset,
|
||||
const SkIRect& clipBounds, SkIRect* outSubset,
|
||||
SkIPoint* offset) const;
|
||||
|
||||
/** To be deprecated.
|
||||
*/
|
||||
#ifdef SK_IMAGE_MAKE_WITH_FILTER_LEGACY_API
|
||||
sk_sp<SkImage> makeWithFilter(const SkImageFilter* filter, const SkIRect& subset,
|
||||
const SkIRect& clipBounds, SkIRect* outSubset,
|
||||
SkIPoint* offset) const;
|
||||
#endif
|
||||
|
||||
/** Defines a callback function, taking one parameter of type GrBackendTexture with
|
||||
no return value. Function is called when back-end texture is to be released.
|
||||
|
@ -348,26 +348,24 @@ sk_sp<SkImage> SkImage::MakeFromPicture(sk_sp<SkPicture> picture, const SkISize&
|
||||
std::move(colorSpace)));
|
||||
}
|
||||
|
||||
sk_sp<SkImage> SkImage::makeWithFilter(const SkImageFilter* filter, const SkIRect& subset,
|
||||
const SkIRect& clipBounds, SkIRect* outSubset,
|
||||
SkIPoint* offset) const {
|
||||
GrContext* context = as_IB(this)->context();
|
||||
sk_sp<SkImage> SkImage::makeWithFilter(GrRecordingContext* rContext, const SkImageFilter* filter,
|
||||
const SkIRect& subset, const SkIRect& clipBounds,
|
||||
SkIRect* outSubset, SkIPoint* offset) const {
|
||||
|
||||
return this->makeWithFilter(context, filter, subset, clipBounds, outSubset, offset);
|
||||
}
|
||||
|
||||
sk_sp<SkImage> SkImage::makeWithFilter(GrContext* grContext,
|
||||
const SkImageFilter* filter, const SkIRect& subset,
|
||||
const SkIRect& clipBounds, SkIRect* outSubset,
|
||||
SkIPoint* offset) const {
|
||||
if (!filter || !outSubset || !offset || !this->bounds().contains(subset)) {
|
||||
return nullptr;
|
||||
}
|
||||
sk_sp<SkSpecialImage> srcSpecialImage =
|
||||
sk_sp<SkSpecialImage> srcSpecialImage;
|
||||
#if SK_SUPPORT_GPU
|
||||
SkSpecialImage::MakeFromImage(grContext, subset, sk_ref_sp(const_cast<SkImage*>(this)));
|
||||
auto myContext = as_IB(this)->context();
|
||||
if (myContext && !myContext->priv().matches(rContext)) {
|
||||
return nullptr;
|
||||
}
|
||||
srcSpecialImage = SkSpecialImage::MakeFromImage(rContext, subset,
|
||||
sk_ref_sp(const_cast<SkImage*>(this)));
|
||||
#else
|
||||
SkSpecialImage::MakeFromImage(nullptr, subset, sk_ref_sp(const_cast<SkImage*>(this)));
|
||||
srcSpecialImage = SkSpecialImage::MakeFromImage(nullptr, subset,
|
||||
sk_ref_sp(const_cast<SkImage*>(this)));
|
||||
#endif
|
||||
if (!srcSpecialImage) {
|
||||
return nullptr;
|
||||
@ -412,6 +410,18 @@ sk_sp<SkImage> SkImage::makeWithFilter(GrContext* grContext,
|
||||
return result->asImage();
|
||||
}
|
||||
|
||||
#ifdef SK_IMAGE_MAKE_WITH_FILTER_LEGACY_API
|
||||
sk_sp<SkImage> SkImage::makeWithFilter(const SkImageFilter* filter, const SkIRect& subset,
|
||||
const SkIRect& clipBounds, SkIRect* outSubset,
|
||||
SkIPoint* offset) const {
|
||||
GrRecordingContext* rContext = nullptr;
|
||||
#if SK_SUPPORT_GPU
|
||||
rContext = as_IB(this)->context();
|
||||
#endif
|
||||
return this->makeWithFilter(rContext, filter, subset, clipBounds, outSubset, offset);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool SkImage::isLazyGenerated() const {
|
||||
return as_IB(this)->onIsLazyGenerated();
|
||||
}
|
||||
|
@ -329,9 +329,10 @@ static sk_sp<SkImageFilter> make_blue(sk_sp<SkImageFilter> input, const SkIRect*
|
||||
return SkImageFilters::ColorFilter(std::move(filter), std::move(input), cropRect);
|
||||
}
|
||||
|
||||
static sk_sp<SkSpecialSurface> create_empty_special_surface(GrContext* context, int widthHeight) {
|
||||
if (context) {
|
||||
return SkSpecialSurface::MakeRenderTarget(context, widthHeight, widthHeight,
|
||||
static sk_sp<SkSpecialSurface> create_empty_special_surface(GrRecordingContext* rContext,
|
||||
int widthHeight) {
|
||||
if (rContext) {
|
||||
return SkSpecialSurface::MakeRenderTarget(rContext, widthHeight, widthHeight,
|
||||
GrColorType::kRGBA_8888, nullptr);
|
||||
} else {
|
||||
const SkImageInfo info = SkImageInfo::MakeN32(widthHeight, widthHeight,
|
||||
@ -340,17 +341,18 @@ static sk_sp<SkSpecialSurface> create_empty_special_surface(GrContext* context,
|
||||
}
|
||||
}
|
||||
|
||||
static sk_sp<SkSurface> create_surface(GrContext* context, int width, int height) {
|
||||
static sk_sp<SkSurface> create_surface(GrRecordingContext* rContext, int width, int height) {
|
||||
const SkImageInfo info = SkImageInfo::MakeN32(width, height, kOpaque_SkAlphaType);
|
||||
if (context) {
|
||||
return SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info);
|
||||
if (rContext) {
|
||||
return SkSurface::MakeRenderTarget(rContext, SkBudgeted::kNo, info);
|
||||
} else {
|
||||
return SkSurface::MakeRaster(info);
|
||||
}
|
||||
}
|
||||
|
||||
static sk_sp<SkSpecialImage> create_empty_special_image(GrContext* context, int widthHeight) {
|
||||
sk_sp<SkSpecialSurface> surf(create_empty_special_surface(context, widthHeight));
|
||||
static sk_sp<SkSpecialImage> create_empty_special_image(GrRecordingContext* rContext,
|
||||
int widthHeight) {
|
||||
sk_sp<SkSpecialSurface> surf(create_empty_special_surface(rContext, widthHeight));
|
||||
|
||||
SkASSERT(surf);
|
||||
|
||||
@ -467,11 +469,11 @@ DEF_TEST(ImageFilter, reporter) {
|
||||
}
|
||||
}
|
||||
|
||||
static void test_cropRects(skiatest::Reporter* reporter, GrContext* context) {
|
||||
static void test_cropRects(skiatest::Reporter* reporter, GrRecordingContext* rContext) {
|
||||
// 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, 100));
|
||||
sk_sp<SkSpecialImage> srcImg(create_empty_special_image(rContext, 100));
|
||||
SkASSERT(srcImg);
|
||||
|
||||
SkIRect inputCropRect = SkIRect::MakeXYWH(8, 13, 80, 80);
|
||||
@ -504,7 +506,8 @@ static bool special_image_to_bitmap(const SkSpecialImage* src, SkBitmap* dst) {
|
||||
return img->readPixels(dst->pixmap(), src->subset().fLeft, src->subset().fTop);
|
||||
}
|
||||
|
||||
static void test_negative_blur_sigma(skiatest::Reporter* reporter, GrContext* context) {
|
||||
static void test_negative_blur_sigma(skiatest::Reporter* reporter,
|
||||
GrRecordingContext* rContext) {
|
||||
// Check that SkBlurImageFilter will accept a negative sigma, either in
|
||||
// the given arguments or after CTM application.
|
||||
static const int kWidth = 32, kHeight = 32;
|
||||
@ -515,7 +518,7 @@ static void test_negative_blur_sigma(skiatest::Reporter* reporter, GrContext* co
|
||||
|
||||
sk_sp<SkImage> gradient = SkImage::MakeFromBitmap(make_gradient_circle(kWidth, kHeight));
|
||||
sk_sp<SkSpecialImage> imgSrc(
|
||||
SkSpecialImage::MakeFromImage(context, SkIRect::MakeWH(kWidth, kHeight), gradient));
|
||||
SkSpecialImage::MakeFromImage(rContext, SkIRect::MakeWH(kWidth, kHeight), gradient));
|
||||
|
||||
SkIPoint offset;
|
||||
SkImageFilter_Base::Context ctx(SkMatrix::I(), SkIRect::MakeWH(32, 32), nullptr,
|
||||
@ -664,13 +667,13 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(MorphologyFilterRadiusWithMirrorCTM_Gpu, repo
|
||||
test_morphology_radius_with_mirror_ctm(reporter, ctxInfo.directContext());
|
||||
}
|
||||
|
||||
static void test_zero_blur_sigma(skiatest::Reporter* reporter, GrContext* context) {
|
||||
static void test_zero_blur_sigma(skiatest::Reporter* reporter, GrRecordingContext* rContext) {
|
||||
// Check that SkBlurImageFilter with a zero sigma and a non-zero srcOffset works correctly.
|
||||
SkIRect cropRect = SkIRect::MakeXYWH(5, 0, 5, 10);
|
||||
sk_sp<SkImageFilter> input(SkImageFilters::Offset(0, 0, nullptr, &cropRect));
|
||||
sk_sp<SkImageFilter> filter(SkImageFilters::Blur(0, 0, std::move(input), &cropRect));
|
||||
|
||||
sk_sp<SkSpecialSurface> surf(create_empty_special_surface(context, 10));
|
||||
sk_sp<SkSpecialSurface> surf(create_empty_special_surface(rContext, 10));
|
||||
surf->getCanvas()->clear(SK_ColorGREEN);
|
||||
sk_sp<SkSpecialImage> image(surf->makeImageSnapshot());
|
||||
|
||||
@ -709,9 +712,10 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageFilterZeroBlurSigma_Gpu, reporter, ctxIn
|
||||
|
||||
// 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(skiatest::Reporter* reporter, GrContext* context) {
|
||||
static void test_fail_affects_transparent_black(skiatest::Reporter* reporter,
|
||||
GrRecordingContext* rContext) {
|
||||
sk_sp<FailImageFilter> failFilter(new FailImageFilter());
|
||||
sk_sp<SkSpecialImage> source(create_empty_special_image(context, 5));
|
||||
sk_sp<SkSpecialImage> source(create_empty_special_image(rContext, 5));
|
||||
SkImageFilter_Base::Context ctx(SkMatrix::I(), SkIRect::MakeXYWH(0, 0, 1, 1), nullptr,
|
||||
kN32_SkColorType, nullptr, source.get());
|
||||
sk_sp<SkColorFilter> green(SkColorFilters::Blend(SK_ColorGREEN, SkBlendMode::kSrc));
|
||||
@ -986,7 +990,8 @@ DEF_TEST(ImageFilterUnionBounds, reporter) {
|
||||
}
|
||||
}
|
||||
|
||||
static void test_imagefilter_merge_result_size(skiatest::Reporter* reporter, GrContext* context) {
|
||||
static void test_imagefilter_merge_result_size(skiatest::Reporter* reporter,
|
||||
GrRecordingContext* rContext) {
|
||||
SkBitmap greenBM;
|
||||
greenBM.allocN32Pixels(20, 20);
|
||||
greenBM.eraseColor(SK_ColorGREEN);
|
||||
@ -994,7 +999,7 @@ static void test_imagefilter_merge_result_size(skiatest::Reporter* reporter, GrC
|
||||
sk_sp<SkImageFilter> source(SkImageFilters::Image(std::move(greenImage)));
|
||||
sk_sp<SkImageFilter> merge(SkImageFilters::Merge(source, source));
|
||||
|
||||
sk_sp<SkSpecialImage> srcImg(create_empty_special_image(context, 1));
|
||||
sk_sp<SkSpecialImage> srcImg(create_empty_special_image(rContext, 1));
|
||||
|
||||
SkImageFilter_Base::Context ctx(SkMatrix::I(), SkIRect::MakeXYWH(0, 0, 100, 100), nullptr,
|
||||
kN32_SkColorType, nullptr, srcImg.get());
|
||||
@ -1132,7 +1137,7 @@ DEF_TEST(ImageFilterMatrixConvolutionBorder, reporter) {
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
static void test_big_kernel(skiatest::Reporter* reporter, GrContext* context) {
|
||||
static void test_big_kernel(skiatest::Reporter* reporter, GrRecordingContext* rContext) {
|
||||
// Check that a kernel that is too big for the GPU still works
|
||||
SkScalar identityKernel[49] = {
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
@ -1151,7 +1156,7 @@ static void test_big_kernel(skiatest::Reporter* reporter, GrContext* context) {
|
||||
kernelSize, identityKernel, gain, bias, kernelOffset,
|
||||
SkTileMode::kClamp, true, nullptr));
|
||||
|
||||
sk_sp<SkSpecialImage> srcImg(create_empty_special_image(context, 100));
|
||||
sk_sp<SkSpecialImage> srcImg(create_empty_special_image(rContext, 100));
|
||||
SkASSERT(srcImg);
|
||||
|
||||
SkIPoint offset;
|
||||
@ -1159,7 +1164,7 @@ static void test_big_kernel(skiatest::Reporter* reporter, GrContext* context) {
|
||||
kN32_SkColorType, nullptr, srcImg.get());
|
||||
sk_sp<SkSpecialImage> resultImg(as_IFB(filter)->filterImage(ctx).imageAndOffset(&offset));
|
||||
REPORTER_ASSERT(reporter, resultImg);
|
||||
REPORTER_ASSERT(reporter, SkToBool(context) == resultImg->isTextureBacked());
|
||||
REPORTER_ASSERT(reporter, SkToBool(rContext) == resultImg->isTextureBacked());
|
||||
REPORTER_ASSERT(reporter, resultImg->width() == 100 && resultImg->height() == 100);
|
||||
REPORTER_ASSERT(reporter, offset.fX == 0 && offset.fY == 0);
|
||||
}
|
||||
@ -1207,7 +1212,8 @@ DEF_TEST(ImageFilterMatrix, reporter) {
|
||||
canvas.drawPicture(recorder.finishRecordingAsPicture());
|
||||
}
|
||||
|
||||
static void test_clipped_picture_imagefilter(skiatest::Reporter* reporter, GrContext* context) {
|
||||
static void test_clipped_picture_imagefilter(skiatest::Reporter* reporter,
|
||||
GrRecordingContext* rContext) {
|
||||
sk_sp<SkPicture> picture;
|
||||
|
||||
{
|
||||
@ -1222,7 +1228,7 @@ static void test_clipped_picture_imagefilter(skiatest::Reporter* reporter, GrCon
|
||||
picture = recorder.finishRecordingAsPicture();
|
||||
}
|
||||
|
||||
sk_sp<SkSpecialImage> srcImg(create_empty_special_image(context, 2));
|
||||
sk_sp<SkSpecialImage> srcImg(create_empty_special_image(rContext, 2));
|
||||
|
||||
sk_sp<SkImageFilter> imageFilter(SkImageFilters::Picture(picture));
|
||||
|
||||
@ -1443,8 +1449,9 @@ DEF_TEST(XfermodeImageFilterCroppedInput, reporter) {
|
||||
test_xfermode_cropped_input(SkSurface::MakeRasterN32Premul(100, 100).get(), reporter);
|
||||
}
|
||||
|
||||
static void test_composed_imagefilter_offset(skiatest::Reporter* reporter, GrContext* context) {
|
||||
sk_sp<SkSpecialImage> srcImg(create_empty_special_image(context, 100));
|
||||
static void test_composed_imagefilter_offset(skiatest::Reporter* reporter,
|
||||
GrRecordingContext* rContext) {
|
||||
sk_sp<SkSpecialImage> srcImg(create_empty_special_image(rContext, 100));
|
||||
|
||||
SkIRect cropRect = SkIRect::MakeXYWH(1, 0, 20, 20);
|
||||
sk_sp<SkImageFilter> offsetFilter(SkImageFilters::Offset(0, 0, nullptr, &cropRect));
|
||||
@ -1470,7 +1477,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ComposedImageFilterOffset_Gpu, reporter, ctxI
|
||||
test_composed_imagefilter_offset(reporter, ctxInfo.directContext());
|
||||
}
|
||||
|
||||
static void test_composed_imagefilter_bounds(skiatest::Reporter* reporter, GrContext* context) {
|
||||
static void test_composed_imagefilter_bounds(skiatest::Reporter* reporter,
|
||||
GrRecordingContext* rContext) {
|
||||
// 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.
|
||||
@ -1488,7 +1496,7 @@ static void test_composed_imagefilter_bounds(skiatest::Reporter* reporter, GrCon
|
||||
sk_sp<SkImageFilter> composedFilter(SkImageFilters::Compose(std::move(offsetFilter),
|
||||
std::move(pictureFilter)));
|
||||
|
||||
sk_sp<SkSpecialImage> sourceImage(create_empty_special_image(context, 100));
|
||||
sk_sp<SkSpecialImage> sourceImage(create_empty_special_image(rContext, 100));
|
||||
SkImageFilter_Base::Context ctx(SkMatrix::I(), SkIRect::MakeWH(100, 100), nullptr,
|
||||
kN32_SkColorType, nullptr, sourceImage.get());
|
||||
SkIPoint offset;
|
||||
@ -1652,8 +1660,8 @@ DEF_TEST(ImageFilterBlurLargeImage, reporter) {
|
||||
test_large_blur_input(reporter, surface->getCanvas());
|
||||
}
|
||||
|
||||
static void test_make_with_filter(skiatest::Reporter* reporter, GrContext* context) {
|
||||
sk_sp<SkSurface> surface(create_surface(context, 192, 128));
|
||||
static void test_make_with_filter(skiatest::Reporter* reporter, GrRecordingContext* rContext) {
|
||||
sk_sp<SkSurface> surface(create_surface(rContext, 192, 128));
|
||||
surface->getCanvas()->clear(SK_ColorRED);
|
||||
SkPaint bluePaint;
|
||||
bluePaint.setColor(SK_ColorBLUE);
|
||||
@ -1667,31 +1675,39 @@ static void test_make_with_filter(skiatest::Reporter* reporter, GrContext* conte
|
||||
SkIPoint offset;
|
||||
sk_sp<SkImage> result;
|
||||
|
||||
result = sourceImage->makeWithFilter(nullptr, subset, clipBounds, &outSubset, &offset);
|
||||
result = sourceImage->makeWithFilter(rContext, nullptr, subset, clipBounds,
|
||||
&outSubset, &offset);
|
||||
REPORTER_ASSERT(reporter, !result);
|
||||
|
||||
result = sourceImage->makeWithFilter(filter.get(), subset, clipBounds, nullptr, &offset);
|
||||
result = sourceImage->makeWithFilter(rContext, filter.get(), subset, clipBounds,
|
||||
nullptr, &offset);
|
||||
REPORTER_ASSERT(reporter, !result);
|
||||
|
||||
result = sourceImage->makeWithFilter(filter.get(), subset, clipBounds, &outSubset, nullptr);
|
||||
result = sourceImage->makeWithFilter(rContext, filter.get(), subset, clipBounds,
|
||||
&outSubset, nullptr);
|
||||
REPORTER_ASSERT(reporter, !result);
|
||||
|
||||
SkIRect bigSubset = SkIRect::MakeXYWH(-10000, -10000, 20000, 20000);
|
||||
result = sourceImage->makeWithFilter(filter.get(), bigSubset, clipBounds, &outSubset, &offset);
|
||||
result = sourceImage->makeWithFilter(rContext, filter.get(), bigSubset, clipBounds,
|
||||
&outSubset, &offset);
|
||||
REPORTER_ASSERT(reporter, !result);
|
||||
|
||||
SkIRect empty = SkIRect::MakeEmpty();
|
||||
result = sourceImage->makeWithFilter(filter.get(), empty, clipBounds, &outSubset, &offset);
|
||||
result = sourceImage->makeWithFilter(rContext, filter.get(), empty, clipBounds,
|
||||
&outSubset, &offset);
|
||||
REPORTER_ASSERT(reporter, !result);
|
||||
|
||||
result = sourceImage->makeWithFilter(filter.get(), subset, empty, &outSubset, &offset);
|
||||
result = sourceImage->makeWithFilter(rContext, filter.get(), subset, empty,
|
||||
&outSubset, &offset);
|
||||
REPORTER_ASSERT(reporter, !result);
|
||||
|
||||
SkIRect leftField = SkIRect::MakeXYWH(-1000, 0, 100, 100);
|
||||
result = sourceImage->makeWithFilter(filter.get(), subset, leftField, &outSubset, &offset);
|
||||
result = sourceImage->makeWithFilter(rContext, filter.get(), subset, leftField,
|
||||
&outSubset, &offset);
|
||||
REPORTER_ASSERT(reporter, !result);
|
||||
|
||||
result = sourceImage->makeWithFilter(filter.get(), subset, clipBounds, &outSubset, &offset);
|
||||
result = sourceImage->makeWithFilter(rContext, filter.get(), subset, clipBounds,
|
||||
&outSubset, &offset);
|
||||
|
||||
REPORTER_ASSERT(reporter, result);
|
||||
REPORTER_ASSERT(reporter, result->bounds().contains(outSubset));
|
||||
@ -1706,7 +1722,8 @@ static void test_make_with_filter(skiatest::Reporter* reporter, GrContext* conte
|
||||
subset.setXYWH(0, 0, 160, 90);
|
||||
|
||||
filter = SkImageFilters::Xfermode(SkBlendMode::kSrc, nullptr);
|
||||
result = sourceImage->makeWithFilter(filter.get(), subset, clipBounds, &outSubset, &offset);
|
||||
result = sourceImage->makeWithFilter(rContext, filter.get(), subset, clipBounds,
|
||||
&outSubset, &offset);
|
||||
REPORTER_ASSERT(reporter, result);
|
||||
}
|
||||
}
|
||||
|
@ -23,13 +23,13 @@
|
||||
// 2D canvas and compositor image filtering. In this case Chrome doesn't regularly purge
|
||||
// the cache. This would result in Ganesh quickly running up to its max cache limit.
|
||||
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(RepeatedClippedBlurTest, reporter, ctxInfo) {
|
||||
auto context = ctxInfo.directContext();
|
||||
GrResourceCache* cache = context->priv().getResourceCache();
|
||||
auto dContext = ctxInfo.directContext();
|
||||
GrResourceCache* cache = dContext->priv().getResourceCache();
|
||||
|
||||
const SkImageInfo ii = SkImageInfo::Make(1024, 600, kRGBA_8888_SkColorType,
|
||||
kPremul_SkAlphaType);
|
||||
|
||||
sk_sp<SkSurface> dst(SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, ii));
|
||||
sk_sp<SkSurface> dst(SkSurface::MakeRenderTarget(dContext, SkBudgeted::kNo, ii));
|
||||
if (!dst) {
|
||||
ERRORF(reporter, "Could not create surfaces for repeated clipped blur test.");
|
||||
return;
|
||||
@ -53,7 +53,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(RepeatedClippedBlurTest, reporter, ctxInfo) {
|
||||
bm.eraseArea(SkIRect::MakeXYWH(1, 2, 1277, 1274), SK_ColorGREEN);
|
||||
|
||||
sk_sp<SkImage> rasterImg = SkImage::MakeFromBitmap(bm);
|
||||
bigImg = rasterImg->makeTextureImage(context);
|
||||
bigImg = rasterImg->makeTextureImage(dContext);
|
||||
}
|
||||
|
||||
sk_sp<SkImage> smImg;
|
||||
@ -63,7 +63,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(RepeatedClippedBlurTest, reporter, ctxInfo) {
|
||||
SkImageInfo screenII = SkImageInfo::Make(1024, 600, kRGBA_8888_SkColorType,
|
||||
kPremul_SkAlphaType);
|
||||
|
||||
sk_sp<SkSurface> s = SkSurface::MakeRenderTarget(context, SkBudgeted::kYes,
|
||||
sk_sp<SkSurface> s = SkSurface::MakeRenderTarget(dContext, SkBudgeted::kYes,
|
||||
screenII, 1, kTopLeft_GrSurfaceOrigin,
|
||||
nullptr);
|
||||
SkCanvas* c = s->getCanvas();
|
||||
@ -74,7 +74,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(RepeatedClippedBlurTest, reporter, ctxInfo) {
|
||||
}
|
||||
|
||||
// flush here just to clear the playing field
|
||||
context->flushAndSubmit();
|
||||
dContext->flushAndSubmit();
|
||||
|
||||
size_t beforeBytes = cache->getResourceBytes();
|
||||
|
||||
@ -93,7 +93,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(RepeatedClippedBlurTest, reporter, ctxInfo) {
|
||||
|
||||
SkIRect outSubset;
|
||||
SkIPoint offset;
|
||||
sk_sp<SkImage> filteredImg = smImg->makeWithFilter(context, blur.get(), subset, clip,
|
||||
sk_sp<SkImage> filteredImg = smImg->makeWithFilter(dContext, blur.get(), subset, clip,
|
||||
&outSubset, &offset);
|
||||
|
||||
SkRect dstRect = SkRect::MakeXYWH(offset.fX, offset.fY,
|
||||
@ -101,7 +101,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(RepeatedClippedBlurTest, reporter, ctxInfo) {
|
||||
dstCanvas->drawImageRect(filteredImg, outSubset, dstRect, nullptr);
|
||||
|
||||
// Flush here to mimic Chrome's SkiaHelper::ApplyImageFilter
|
||||
context->flushAndSubmit();
|
||||
dContext->flushAndSubmit();
|
||||
|
||||
clip.fRight -= 16;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user