diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h index 16fd6c4c68..d3e5684757 100644 --- a/include/core/SkCanvas.h +++ b/include/core/SkCanvas.h @@ -41,10 +41,6 @@ #define SK_SUPPORT_LEGACY_DRAWBITMAP #endif -#ifndef SK_SUPPORT_LEGACY_DRAWIMAGE_NOSAMPLING -#define SK_SUPPORT_LEGACY_DRAWIMAGE_NOSAMPLING -#endif - class GrBackendRenderTarget; class GrRecordingContext; class GrSurfaceDrawContext; diff --git a/modules/canvaskit/CHANGELOG.md b/modules/canvaskit/CHANGELOG.md index 3ade6f5c33..9d45ec845c 100644 --- a/modules/canvaskit/CHANGELOG.md +++ b/modules/canvaskit/CHANGELOG.md @@ -18,6 +18,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - 4x4 matrices are "downsampled" properly if necessary to 3x3 matrices by removing the third column and the third row. +## [0.23.0] - 2021-1-29 + +### Deprecated + - `Canvas.drawImageRect`, `Canvas.drawImage`, `Canvas.drawAtlas`, + These rely on the Paint's FilterQuality, which is going away. Pass sampling options explicitly. + ## [0.22.0] - 2020-12-17 ### Added diff --git a/modules/canvaskit/canvaskit_bindings.cpp b/modules/canvaskit/canvaskit_bindings.cpp index cb56aa6f58..8b4878d7f4 100644 --- a/modules/canvaskit/canvaskit_bindings.cpp +++ b/modules/canvaskit/canvaskit_bindings.cpp @@ -874,6 +874,7 @@ EMSCRIPTEN_BINDINGS(Skia) { self.drawArc(*oval, startAngle, sweepAngle, useCenter, paint); })) // _drawAtlas takes an array of SkColor. There is no SkColor4f override. + // TODO: take sampling as an explicit parameter from the caller .function("_drawAtlas", optional_override([](SkCanvas& self, const sk_sp& atlas, uintptr_t /* SkRSXform* */ xptr, uintptr_t /* SkRect* */ rptr, uintptr_t /* SkColor* */ cptr, int count, @@ -884,7 +885,6 @@ EMSCRIPTEN_BINDINGS(Skia) { if (cptr) { colors = reinterpret_cast(cptr); } - // TODO: take sampling as an explicit parameter from the caller SkSamplingOptions sampling(SkFilterMode::kLinear); self.drawAtlas(atlas.get(), dstXforms, srcRects, colors, count, mode, sampling, nullptr, paint); @@ -906,7 +906,13 @@ EMSCRIPTEN_BINDINGS(Skia) { uintptr_t /* float* */ innerPtr, const SkPaint& paint) { self.drawDRRect(ptrToSkRRect(outerPtr), ptrToSkRRect(innerPtr), paint); })) - .function("drawImage", select_overload&, SkScalar, SkScalar, const SkPaint*)>(&SkCanvas::drawImage), allow_raw_pointers()) + // TODO: deprecate this version, and require sampling + .function("drawImage", optional_override([](SkCanvas& self, const sk_sp& image, + SkScalar x, SkScalar y, const SkPaint* paint) { + SkSamplingOptions sampling(paint ? paint->getFilterQuality() + : kNone_SkFilterQuality); + self.drawImage(image.get(), x, y, sampling, paint); + }), allow_raw_pointers()) .function("drawImageCubic", optional_override([](SkCanvas& self, const sk_sp& img, SkScalar left, SkScalar top, float B, float C, // See SkSamplingOptions.h for docs. @@ -922,7 +928,9 @@ EMSCRIPTEN_BINDINGS(Skia) { .function("drawImageAtCurrentFrame", optional_override([](SkCanvas& self, sk_sp aImg, SkScalar left, SkScalar top, const SkPaint* paint)->void { auto img = aImg->getCurrentFrame(); - self.drawImage(img, left, top, paint); + SkSamplingOptions sampling(paint ? paint->getFilterQuality() + : kNone_SkFilterQuality); + self.drawImage(img, left, top, sampling, paint); }), allow_raw_pointers()) .function("_drawImageNine", optional_override([](SkCanvas& self, const sk_sp& image, @@ -933,12 +941,15 @@ EMSCRIPTEN_BINDINGS(Skia) { self.drawImageNine(image.get(), *center, *dst, filter, paint); }), allow_raw_pointers()) + // TODO: deprecate this version, and require sampling .function("_drawImageRect", optional_override([](SkCanvas& self, const sk_sp& image, uintptr_t /* float* */ srcPtr, uintptr_t /* float* */ dstPtr, const SkPaint* paint, bool fastSample)->void { const SkRect* src = reinterpret_cast(srcPtr); const SkRect* dst = reinterpret_cast(dstPtr); - self.drawImageRect(image, *src, *dst, paint, + SkSamplingOptions sampling(paint ? paint->getFilterQuality() + : kNone_SkFilterQuality); + self.drawImageRect(image, *src, *dst, sampling, paint, fastSample ? SkCanvas::kFast_SrcRectConstraint: SkCanvas::kStrict_SrcRectConstraint); }), allow_raw_pointers()) diff --git a/tests/VkDrawableTest.cpp b/tests/VkDrawableTest.cpp index 662b322ef6..154c089f95 100644 --- a/tests/VkDrawableTest.cpp +++ b/tests/VkDrawableTest.cpp @@ -158,8 +158,9 @@ public: surf->getCanvas()->clear(SK_ColorRED); SkRect dstRect = SkRect::MakeXYWH(3*td->fWidth/4, 0, td->fWidth/4, td->fHeight); - SkIRect srcRect = SkIRect::MakeWH(td->fWidth/4, td->fHeight); - canvas->drawImageRect(surf->makeImageSnapshot(), srcRect, dstRect, &paint); + SkRect srcRect = SkRect::MakeIWH(td->fWidth/4, td->fHeight); + canvas->drawImageRect(surf->makeImageSnapshot(), srcRect, dstRect, SkSamplingOptions(), + &paint, SkCanvas::kStrict_SrcRectConstraint); td->fDrawContext->flush(); }