diff --git a/include/tgfx/core/ColorFilter.h b/include/tgfx/core/ColorFilter.h index ecc9c237..0e882f74 100644 --- a/include/tgfx/core/ColorFilter.h +++ b/include/tgfx/core/ColorFilter.h @@ -54,10 +54,10 @@ class ColorFilter : public Filter { protected: std::unique_ptr onFilterImage(std::shared_ptr source, - const DrawArgs& args, - const tgfx::Matrix* localMatrix, - TileMode tileModeX, - TileMode tileModeY) const override; + const DrawArgs& args, TileMode tileModeX, + TileMode tileModeY, + const SamplingOptions& sampling, + const tgfx::Matrix* localMatrix) const override; private: virtual std::unique_ptr asFragmentProcessor() const = 0; diff --git a/include/tgfx/core/Filter.h b/include/tgfx/core/Filter.h index 93be0c29..7e1d86ff 100644 --- a/include/tgfx/core/Filter.h +++ b/include/tgfx/core/Filter.h @@ -44,10 +44,10 @@ class Filter { * The returned processor is in the coordinate space of the source image. */ virtual std::unique_ptr onFilterImage(std::shared_ptr source, - const DrawArgs& args, - const Matrix* localMatrix, - TileMode tileModeX, - TileMode tileModeY) const = 0; + const DrawArgs& args, TileMode tileModeX, + TileMode tileModeY, + const SamplingOptions& sampling, + const Matrix* localMatrix) const = 0; friend class FilterImage; }; diff --git a/include/tgfx/core/Image.h b/include/tgfx/core/Image.h index 679f0480..8ba8cf79 100644 --- a/include/tgfx/core/Image.h +++ b/include/tgfx/core/Image.h @@ -281,10 +281,9 @@ class Image { virtual std::shared_ptr onMakeRGBAAA(int displayWidth, int displayHeight, int alphaStartX, int alphaStartY) const; - virtual std::unique_ptr asFragmentProcessor(const DrawArgs& args, - const Matrix* localMatrix, - TileMode tileModeX, - TileMode tileModeY) const = 0; + virtual std::unique_ptr asFragmentProcessor( + const DrawArgs& args, TileMode tileModeX, TileMode tileModeY, const SamplingOptions& sampling, + const Matrix* localMatrix) const = 0; friend class FragmentProcessor; friend class TransformImage; diff --git a/include/tgfx/core/MaskFilter.h b/include/tgfx/core/MaskFilter.h index 52b653e0..9e221ffb 100644 --- a/include/tgfx/core/MaskFilter.h +++ b/include/tgfx/core/MaskFilter.h @@ -38,9 +38,10 @@ class MaskFilter : public Filter { protected: std::unique_ptr onFilterImage(std::shared_ptr source, - const DrawArgs& args, const Matrix* localMatrix, - TileMode tileModeX, - TileMode tileModeY) const override; + const DrawArgs& args, TileMode tileModeX, + TileMode tileModeY, + const SamplingOptions& sampling, + const Matrix* localMatrix) const override; private: virtual std::unique_ptr asFragmentProcessor( diff --git a/src/core/Canvas.cpp b/src/core/Canvas.cpp index 72892f74..462874b0 100644 --- a/src/core/Canvas.cpp +++ b/src/core/Canvas.cpp @@ -411,9 +411,7 @@ void Canvas::drawPath(const Path& path, const Paint& paint) { if (drawAsClear(fillPath, paint)) { return; } - auto inputColor = paint.getColor().premultiply(); - DrawArgs args(getContext(), surface->options()->renderFlags(), inputColor, localBounds, - state->matrix); + DrawArgs args(surface, paint, localBounds, state->matrix); auto drawOp = MakeSimplePathOp(fillPath, args); if (drawOp != nullptr) { addDrawOp(std::move(drawOp), args, paint); @@ -437,7 +435,7 @@ void Canvas::drawPath(const Path& path, const Paint& paint) { } void Canvas::drawImage(std::shared_ptr image, float left, float top, const Paint* paint) { - drawImage(image, Matrix::MakeTrans(left, top), paint); + drawImage(std::move(image), Matrix::MakeTrans(left, top), paint); } void Canvas::drawImage(std::shared_ptr image, const Matrix& matrix, const Paint* paint) { @@ -482,10 +480,8 @@ void Canvas::drawImage(std::shared_ptr image, SamplingOptions sampling, c if (realPaint.getShader() != nullptr && !image->isAlphaOnly()) { realPaint.setShader(nullptr); } - auto inputColor = realPaint.getColor().premultiply(); - DrawArgs args(getContext(), surface->options()->renderFlags(), inputColor, localBounds, - state->matrix, sampling); - auto processor = FragmentProcessor::Make(std::move(image), args); + DrawArgs args(surface, realPaint, localBounds, state->matrix); + auto processor = FragmentProcessor::Make(std::move(image), args, sampling); if (processor == nullptr) { return; } @@ -511,9 +507,7 @@ void Canvas::drawMask(const Rect& deviceBounds, std::shared_ptr te static_cast(textureProxy->height()) / deviceBounds.height()); auto oldMatrix = state->matrix; resetMatrix(); - auto inputColor = paint.getColor().premultiply(); - DrawArgs args(getContext(), surface->options()->renderFlags(), inputColor, deviceBounds, - Matrix::I()); + DrawArgs args(surface, paint, deviceBounds, Matrix::I()); auto op = FillRectOp::Make(args.color, args.drawRect, args.viewMatrix, &localMatrix); auto maskProcessor = FragmentProcessor::MulInputByChildAlpha( TextureEffect::Make(std::move(textureProxy), SamplingOptions(), &maskLocalMatrix)); @@ -644,11 +638,9 @@ void Canvas::drawAtlas(std::shared_ptr atlas, const Matrix matrix[], cons return; } auto realPaint = CleanPaintForDrawImage(paint); - auto inputColor = realPaint.getColor().premultiply(); - DrawArgs args(getContext(), surface->options()->renderFlags(), inputColor, drawRect, - state->matrix, sampling); + DrawArgs args(surface, realPaint, drawRect, state->matrix); for (auto& rectOp : ops) { - auto processor = FragmentProcessor::Make(atlas, args); + auto processor = FragmentProcessor::Make(atlas, args, sampling); if (colors) { processor = FragmentProcessor::MulInputByChildAlpha(std::move(processor)); } diff --git a/src/filters/BlurImageFilter.cpp b/src/filters/BlurImageFilter.cpp index 1a67f8f4..14a58bf3 100644 --- a/src/filters/BlurImageFilter.cpp +++ b/src/filters/BlurImageFilter.cpp @@ -105,11 +105,9 @@ Rect BlurImageFilter::onFilterBounds(const Rect& srcRect) const { return srcRect.makeOutset(blurOffset.x * mul, blurOffset.y * mul); } -std::unique_ptr BlurImageFilter::onFilterImage(std::shared_ptr source, - const DrawArgs& args, - const Matrix* localMatrix, - TileMode tileModeX, - TileMode tileModeY) const { +std::unique_ptr BlurImageFilter::onFilterImage( + std::shared_ptr source, const DrawArgs& args, TileMode tileModeX, TileMode tileModeY, + const SamplingOptions& sampling, const Matrix* localMatrix) const { auto inputBounds = Rect::MakeWH(source->width(), source->height()); auto clipBounds = args.drawRect; if (localMatrix) { @@ -119,12 +117,10 @@ std::unique_ptr BlurImageFilter::onFilterImage(std::shared_pt if (!applyCropRect(inputBounds, &dstBounds, &clipBounds)) { return nullptr; } - DrawArgs imageArgs = args; - imageArgs.sampling = {}; - auto processor = FragmentProcessor::Make(source, imageArgs, nullptr, tileMode, tileMode); + auto processor = FragmentProcessor::Make(source, args, tileMode, tileMode, {}); auto imageBounds = dstBounds; std::vector> renderTargets = {}; - auto mipmapped = source->hasMipmaps() && args.sampling.mipmapMode != MipmapMode::None; + auto mipmapped = source->hasMipmaps() && sampling.mipmapMode != MipmapMode::None; auto lastRenderTarget = RenderTargetProxy::Make( args.context, static_cast(imageBounds.width()), static_cast(imageBounds.height()), PixelFormat::RGBA_8888, 1, mipmapped); @@ -158,6 +154,6 @@ std::unique_ptr BlurImageFilter::onFilterImage(std::shared_pt matrix.preConcat(*localMatrix); } return TiledTextureEffect::Make(lastRenderTarget->getTextureProxy(), tileModeX, tileModeY, - args.sampling, &matrix); + sampling, &matrix); } } // namespace tgfx diff --git a/src/filters/BlurImageFilter.h b/src/filters/BlurImageFilter.h index 45bc125e..af324ab5 100644 --- a/src/filters/BlurImageFilter.h +++ b/src/filters/BlurImageFilter.h @@ -35,9 +35,10 @@ class BlurImageFilter : public ImageFilter { Rect onFilterBounds(const Rect& srcRect) const override; std::unique_ptr onFilterImage(std::shared_ptr source, - const DrawArgs& args, const Matrix* localMatrix, - TileMode tileModeX, - TileMode tileModeY) const override; + const DrawArgs& args, TileMode tileModeX, + TileMode tileModeY, + const SamplingOptions& sampling, + const Matrix* localMatrix) const override; void draw(std::shared_ptr renderTarget, std::unique_ptr imageProcessor, const Rect& imageBounds, diff --git a/src/filters/ColorFilter.cpp b/src/filters/ColorFilter.cpp index 4fba031f..052a1d40 100644 --- a/src/filters/ColorFilter.cpp +++ b/src/filters/ColorFilter.cpp @@ -20,13 +20,11 @@ #include "gpu/ops/DrawOp.h" namespace tgfx { -std::unique_ptr ColorFilter::onFilterImage(std::shared_ptr source, - const DrawArgs& args, - const tgfx::Matrix* localMatrix, - TileMode tileModeX, - TileMode tileModeY) const { +std::unique_ptr ColorFilter::onFilterImage( + std::shared_ptr source, const DrawArgs& args, TileMode tileModeX, TileMode tileModeY, + const SamplingOptions& sampling, const tgfx::Matrix* localMatrix) const { auto imageProcessor = - FragmentProcessor::Make(std::move(source), args, localMatrix, tileModeX, tileModeY); + FragmentProcessor::Make(std::move(source), args, tileModeX, tileModeY, sampling, localMatrix); if (imageProcessor == nullptr) { return nullptr; } diff --git a/src/filters/DropShadowImageFilter.cpp b/src/filters/DropShadowImageFilter.cpp index 5323c009..af398259 100644 --- a/src/filters/DropShadowImageFilter.cpp +++ b/src/filters/DropShadowImageFilter.cpp @@ -55,8 +55,8 @@ Rect DropShadowImageFilter::onFilterBounds(const Rect& srcRect) const { } std::unique_ptr DropShadowImageFilter::onFilterImage( - std::shared_ptr source, const tgfx::DrawArgs& args, const Matrix* localMatrix, - TileMode tileModeX, TileMode tileModeY) const { + std::shared_ptr source, const DrawArgs& args, TileMode tileModeX, TileMode tileModeY, + const SamplingOptions& sampling, const Matrix* localMatrix) const { auto inputBounds = Rect::MakeWH(source->width(), source->height()); auto clipBounds = args.drawRect; if (localMatrix) { @@ -68,18 +68,16 @@ std::unique_ptr DropShadowImageFilter::onFilterImage( } if (dstBounds.contains(clipBounds) || (tileModeX == TileMode::Decal && tileModeY == TileMode::Decal)) { - return getFragmentProcessor(std::move(source), args, localMatrix); + return getFragmentProcessor(std::move(source), args, sampling, localMatrix); } - auto mipmapped = source->hasMipmaps() && args.sampling.mipmapMode != MipmapMode::None; + auto mipmapped = source->hasMipmaps() && sampling.mipmapMode != MipmapMode::None; auto renderTarget = RenderTargetProxy::Make(args.context, static_cast(dstBounds.width()), static_cast(dstBounds.height()), PixelFormat::RGBA_8888, 1, mipmapped); if (renderTarget == nullptr) { return nullptr; } - DrawArgs shadowArgs = args; - shadowArgs.sampling = {}; - auto processor = getFragmentProcessor(std::move(source), shadowArgs); + auto processor = getFragmentProcessor(std::move(source), args, {}); if (processor == nullptr) { return nullptr; } @@ -90,23 +88,24 @@ std::unique_ptr DropShadowImageFilter::onFilterImage( if (localMatrix != nullptr) { matrix.preConcat(*localMatrix); } - return TiledTextureEffect::Make(renderTarget->getTextureProxy(), tileModeX, tileModeY, - args.sampling, &matrix); + return TiledTextureEffect::Make(renderTarget->getTextureProxy(), tileModeX, tileModeY, sampling, + &matrix); } std::unique_ptr DropShadowImageFilter::getFragmentProcessor( - std::shared_ptr source, const DrawArgs& args, const Matrix* localMatrix) const { + std::shared_ptr source, const DrawArgs& args, const SamplingOptions& sampling, + const Matrix* localMatrix) const { std::unique_ptr shadowProcessor; auto shadowMatrix = Matrix::MakeTrans(-dx, -dy); if (localMatrix != nullptr) { shadowMatrix.preConcat(*localMatrix); } if (blurFilter != nullptr) { - shadowProcessor = - blurFilter->onFilterImage(source, args, &shadowMatrix, TileMode::Decal, TileMode::Decal); + shadowProcessor = blurFilter->onFilterImage(source, args, TileMode::Decal, TileMode::Decal, + sampling, &shadowMatrix); } else { - shadowProcessor = - FragmentProcessor::Make(source, args, &shadowMatrix, TileMode::Decal, TileMode::Decal); + shadowProcessor = FragmentProcessor::Make(source, args, TileMode::Decal, TileMode::Decal, + sampling, &shadowMatrix); } if (shadowProcessor == nullptr) { return nullptr; @@ -117,8 +116,8 @@ std::unique_ptr DropShadowImageFilter::getFragmentProcessor( if (shadowOnly) { return colorShadowProcessor; } - auto imageProcessor = FragmentProcessor::Make(std::move(source), args, localMatrix, - TileMode::Decal, TileMode::Decal); + auto imageProcessor = FragmentProcessor::Make(std::move(source), args, TileMode::Decal, + TileMode::Decal, sampling, localMatrix); return XfermodeFragmentProcessor::MakeFromTwoProcessors( std::move(imageProcessor), std::move(colorShadowProcessor), BlendMode::SrcOver); } diff --git a/src/filters/DropShadowImageFilter.h b/src/filters/DropShadowImageFilter.h index 6ea4bdf3..1cb271ef 100644 --- a/src/filters/DropShadowImageFilter.h +++ b/src/filters/DropShadowImageFilter.h @@ -36,12 +36,13 @@ class DropShadowImageFilter : public ImageFilter { Rect onFilterBounds(const Rect& srcRect) const override; std::unique_ptr onFilterImage(std::shared_ptr source, - const DrawArgs& args, const Matrix* localMatrix, - TileMode tileModeX, - TileMode tileModeY) const override; + const DrawArgs& args, TileMode tileModeX, + TileMode tileModeY, + const SamplingOptions& sampling, + const Matrix* localMatrix) const override; std::unique_ptr getFragmentProcessor( - std::shared_ptr source, const DrawArgs& args, + std::shared_ptr source, const DrawArgs& args, const SamplingOptions& sampling, const Matrix* localMatrix = nullptr) const; }; } // namespace tgfx diff --git a/src/filters/MaskFilter.cpp b/src/filters/MaskFilter.cpp index c7e0c445..fb8a81d6 100644 --- a/src/filters/MaskFilter.cpp +++ b/src/filters/MaskFilter.cpp @@ -22,11 +22,11 @@ namespace tgfx { std::unique_ptr MaskFilter::onFilterImage(std::shared_ptr source, const DrawArgs& args, - const Matrix* localMatrix, - TileMode tileModeX, - TileMode tileModeY) const { + TileMode tileModeX, TileMode tileModeY, + const SamplingOptions& sampling, + const Matrix* localMatrix) const { auto imageProcessor = - FragmentProcessor::Make(std::move(source), args, localMatrix, tileModeX, tileModeY); + FragmentProcessor::Make(std::move(source), args, tileModeX, tileModeY, sampling, localMatrix); if (imageProcessor == nullptr) { return nullptr; } diff --git a/src/gpu/DrawArgs.h b/src/gpu/DrawArgs.h index 3cb9b35d..a25e7f25 100644 --- a/src/gpu/DrawArgs.h +++ b/src/gpu/DrawArgs.h @@ -19,15 +19,21 @@ #pragma once #include "tgfx/core/SamplingOptions.h" -#include "tgfx/gpu/Context.h" +#include "tgfx/gpu/Surface.h" namespace tgfx { class DrawArgs { public: DrawArgs(Context* context, uint32_t renderFlags, const Color& color, const Rect& drawRect, - const Matrix& viewMatrix = Matrix::I(), const SamplingOptions& sampling = {}) + const Matrix& viewMatrix = Matrix::I()) : context(context), renderFlags(renderFlags), color(color), drawRect(drawRect), - viewMatrix(viewMatrix), sampling(sampling) { + viewMatrix(viewMatrix) { + } + + DrawArgs(Surface* surface, const Paint& paint, const Rect& drawRect, + const Matrix& viewMatrix = Matrix::I()) + : context(surface->getContext()), renderFlags(surface->options()->renderFlags()), + color(paint.getColor().premultiply()), drawRect(drawRect), viewMatrix(viewMatrix) { } Context* context = nullptr; @@ -35,6 +41,5 @@ class DrawArgs { Color color = Color::White(); Rect drawRect = Rect::MakeEmpty(); Matrix viewMatrix = Matrix::I(); - SamplingOptions sampling = {}; }; } // namespace tgfx diff --git a/src/gpu/processors/FragmentProcessor.cpp b/src/gpu/processors/FragmentProcessor.cpp index a106c940..7aa0cff5 100644 --- a/src/gpu/processors/FragmentProcessor.cpp +++ b/src/gpu/processors/FragmentProcessor.cpp @@ -26,12 +26,23 @@ namespace tgfx { std::unique_ptr FragmentProcessor::Make(std::shared_ptr image, const DrawArgs& args, - const Matrix* localMatrix, - TileMode tileModeX, TileMode tileModeY) { + const SamplingOptions& sampling, + const Matrix* localMatrix) { + if (image == nullptr) { + return nullptr; + } + return image->asFragmentProcessor(args, TileMode::Clamp, TileMode::Clamp, sampling, localMatrix); +} + +std::unique_ptr FragmentProcessor::Make(std::shared_ptr image, + const tgfx::DrawArgs& args, + TileMode tileModeX, TileMode tileModeY, + const SamplingOptions& sampling, + const Matrix* localMatrix) { if (image == nullptr) { return nullptr; } - return image->asFragmentProcessor(args, localMatrix, tileModeX, tileModeY); + return image->asFragmentProcessor(args, tileModeX, tileModeY, sampling, localMatrix); } std::unique_ptr FragmentProcessor::Make(std::shared_ptr shader, diff --git a/src/gpu/processors/FragmentProcessor.h b/src/gpu/processors/FragmentProcessor.h index 283218ab..1e0b165c 100644 --- a/src/gpu/processors/FragmentProcessor.h +++ b/src/gpu/processors/FragmentProcessor.h @@ -35,13 +35,21 @@ class Shader; class FragmentProcessor : public Processor { public: + /** + * Creates a fragment processor that will draw the given image with the given options. The both + * tileModeX and tileModeY are set to TileMode::Clamp. + */ + static std::unique_ptr Make(std::shared_ptr image, const DrawArgs& args, + const SamplingOptions& sampling, + const Matrix* localMatrix = nullptr); + /** * Creates a fragment processor that will draw the given image with the given options. */ static std::unique_ptr Make(std::shared_ptr image, const DrawArgs& args, - const Matrix* localMatrix = nullptr, - TileMode tileModeX = TileMode::Clamp, - TileMode tileModeY = TileMode::Clamp); + TileMode tileModeX, TileMode tileModeY, + const SamplingOptions& sampling, + const Matrix* localMatrix = nullptr); /** * Creates a fragment processor that will draw the given Shader with the given options. diff --git a/src/images/FilterImage.cpp b/src/images/FilterImage.cpp index e721b260..dc45b09b 100644 --- a/src/images/FilterImage.cpp +++ b/src/images/FilterImage.cpp @@ -71,11 +71,10 @@ std::shared_ptr FilterImage::onMakeSubset(const Rect& subset) const { return FilterImage::MakeFrom(source, filter, newBounds); } -std::unique_ptr FilterImage::asFragmentProcessor(const DrawArgs& args, - const Matrix* localMatrix, - TileMode tileModeX, - TileMode tileModeY) const { +std::unique_ptr FilterImage::asFragmentProcessor( + const DrawArgs& args, TileMode tileModeX, TileMode tileModeY, const SamplingOptions& sampling, + const Matrix* localMatrix) const { auto matrix = SubsetImage::ConcatLocalMatrix(bounds, localMatrix); - return filter->onFilterImage(source, args, AddressOf(matrix), tileModeX, tileModeY); + return filter->onFilterImage(source, args, tileModeX, tileModeY, sampling, AddressOf(matrix)); } } // namespace tgfx diff --git a/src/images/FilterImage.h b/src/images/FilterImage.h index 8c8e968a..fd64a248 100644 --- a/src/images/FilterImage.h +++ b/src/images/FilterImage.h @@ -49,10 +49,10 @@ class FilterImage : public TransformImage { std::shared_ptr onMakeSubset(const Rect& subset) const override; - std::unique_ptr asFragmentProcessor(const DrawArgs& args, - const Matrix* localMatrix, - TileMode tileModeX, - TileMode tileModeY) const override; + std::unique_ptr asFragmentProcessor(const DrawArgs& args, TileMode tileModeX, + TileMode tileModeY, + const SamplingOptions& sampling, + const Matrix* localMatrix) const override; private: std::shared_ptr filter = nullptr; diff --git a/src/images/OrientImage.cpp b/src/images/OrientImage.cpp index e040d953..4e41c808 100644 --- a/src/images/OrientImage.cpp +++ b/src/images/OrientImage.cpp @@ -93,12 +93,11 @@ std::shared_ptr OrientImage::onMakeOriented(Orientation newOrientation) c return OrientImage::MakeFrom(source, newOrientation); } -std::unique_ptr OrientImage::asFragmentProcessor(const DrawArgs& args, - const Matrix* localMatrix, - TileMode tileModeX, - TileMode tileModeY) const { +std::unique_ptr OrientImage::asFragmentProcessor( + const DrawArgs& args, TileMode tileModeX, TileMode tileModeY, const SamplingOptions& sampling, + const Matrix* localMatrix) const { auto matrix = concatLocalMatrix(localMatrix); - return FragmentProcessor::Make(source, args, AddressOf(matrix), tileModeX, tileModeY); + return FragmentProcessor::Make(source, args, tileModeX, tileModeY, sampling, AddressOf(matrix)); } std::optional OrientImage::concatLocalMatrix(const Matrix* localMatrix) const { diff --git a/src/images/OrientImage.h b/src/images/OrientImage.h index a51a1101..dd28f1f3 100644 --- a/src/images/OrientImage.h +++ b/src/images/OrientImage.h @@ -45,9 +45,10 @@ class OrientImage : public TransformImage { std::shared_ptr onMakeOriented(Orientation newOrientation) const override; - std::unique_ptr asFragmentProcessor(const DrawArgs& args, - const Matrix* localMatrix, TileMode, - TileMode) const override; + std::unique_ptr asFragmentProcessor(const DrawArgs& args, TileMode tileModeX, + TileMode tileModeY, + const SamplingOptions& sampling, + const Matrix* localMatrix) const override; virtual std::optional concatLocalMatrix(const Matrix* localMatrix) const; diff --git a/src/images/RGBAAAImage.cpp b/src/images/RGBAAAImage.cpp index f4c7f96c..cfa59483 100644 --- a/src/images/RGBAAAImage.cpp +++ b/src/images/RGBAAAImage.cpp @@ -48,12 +48,12 @@ std::shared_ptr RGBAAAImage::onCloneWith(std::shared_ptr newSource return image; } -std::unique_ptr RGBAAAImage::asFragmentProcessor(const DrawArgs& args, - const Matrix* localMatrix, - TileMode, TileMode) const { +std::unique_ptr RGBAAAImage::asFragmentProcessor( + const DrawArgs& args, TileMode, TileMode, const SamplingOptions& sampling, + const Matrix* localMatrix) const { auto proxy = std::static_pointer_cast(source)->lockTextureProxy(args.context, args.renderFlags); auto matrix = concatLocalMatrix(localMatrix); - return TextureEffect::MakeRGBAAA(std::move(proxy), alphaStart, args.sampling, AddressOf(matrix)); + return TextureEffect::MakeRGBAAA(std::move(proxy), alphaStart, sampling, AddressOf(matrix)); } } // namespace tgfx diff --git a/src/images/RGBAAAImage.h b/src/images/RGBAAAImage.h index f6bfecd5..f1375f5b 100644 --- a/src/images/RGBAAAImage.h +++ b/src/images/RGBAAAImage.h @@ -30,10 +30,10 @@ class RGBAAAImage : public SubsetImage { protected: std::shared_ptr onCloneWith(std::shared_ptr newSource) const override; - std::unique_ptr asFragmentProcessor(const DrawArgs& args, - const Matrix* localMatrix, - TileMode tileModeX, - TileMode tileModeY) const override; + std::unique_ptr asFragmentProcessor(const DrawArgs& args, TileMode tileModeX, + TileMode tileModeY, + const SamplingOptions& sampling, + const Matrix* localMatrix) const override; private: Point alphaStart = Point::Zero(); diff --git a/src/images/RasterImage.cpp b/src/images/RasterImage.cpp index d3a358ae..055727f1 100644 --- a/src/images/RasterImage.cpp +++ b/src/images/RasterImage.cpp @@ -107,9 +107,9 @@ std::shared_ptr RasterImage::onLockTextureProxy(Context* context, } auto sourceFlags = renderFlags | RenderFlags::DisableCache; auto drawRect = Rect::MakeWH(width(), height()); - DrawArgs args(context, sourceFlags, Color::White(), drawRect, Matrix::I(), sampling); + DrawArgs args(context, sourceFlags, Color::White(), drawRect, Matrix::I()); auto localMatrix = Matrix::MakeScale(1.0f / rasterizationScale); - auto processor = FragmentProcessor::Make(source, args, &localMatrix); + auto processor = FragmentProcessor::Make(source, args, sampling, &localMatrix); if (processor == nullptr) { return nullptr; } diff --git a/src/images/ResourceImage.cpp b/src/images/ResourceImage.cpp index acda698c..93d3fcca 100644 --- a/src/images/ResourceImage.cpp +++ b/src/images/ResourceImage.cpp @@ -62,16 +62,14 @@ std::shared_ptr ResourceImage::onMakeRGBAAA(int displayWidth, int display alphaStartY); } -std::unique_ptr ResourceImage::asFragmentProcessor(const DrawArgs& args, - const Matrix* localMatrix, - TileMode tileModeX, - TileMode tileModeY) const { +std::unique_ptr ResourceImage::asFragmentProcessor( + const DrawArgs& args, TileMode tileModeX, TileMode tileModeY, const SamplingOptions& sampling, + const Matrix* localMatrix) const { auto proxy = lockTextureProxy(args.context, args.renderFlags); if (proxy == nullptr) { return nullptr; } - auto processor = - TiledTextureEffect::Make(proxy, tileModeX, tileModeY, args.sampling, localMatrix); + auto processor = TiledTextureEffect::Make(proxy, tileModeX, tileModeY, sampling, localMatrix); if (isAlphaOnly() && !proxy->isAlphaOnly()) { return FragmentProcessor::MulInputByChildAlpha(std::move(processor)); } diff --git a/src/images/ResourceImage.h b/src/images/ResourceImage.h index 41b6592c..7eccfa94 100644 --- a/src/images/ResourceImage.h +++ b/src/images/ResourceImage.h @@ -45,10 +45,10 @@ class ResourceImage : public Image { std::shared_ptr onMakeRGBAAA(int displayWidth, int displayHeight, int alphaStartX, int alphaStartY) const override; - std::unique_ptr asFragmentProcessor(const DrawArgs& args, - const Matrix* localMatrix, - TileMode tileModeX, - TileMode tileModeY) const override; + std::unique_ptr asFragmentProcessor(const DrawArgs& args, TileMode tileModeX, + TileMode tileModeY, + const SamplingOptions& sampling, + const Matrix* localMatrix) const override; virtual std::shared_ptr onLockTextureProxy(Context* context, const UniqueKey& key, bool mipmapped, diff --git a/src/shaders/ImageShader.cpp b/src/shaders/ImageShader.cpp index 6342d051..9dbff832 100644 --- a/src/shaders/ImageShader.cpp +++ b/src/shaders/ImageShader.cpp @@ -35,8 +35,6 @@ std::shared_ptr Shader::MakeImageShader(std::shared_ptr image, Ti std::unique_ptr ImageShader::asFragmentProcessor( const DrawArgs& args, const Matrix* localMatrix) const { - auto imageArgs = args; - imageArgs.sampling = sampling; - return FragmentProcessor::Make(image, imageArgs, localMatrix, tileModeX, tileModeY); + return FragmentProcessor::Make(image, args, tileModeX, tileModeY, sampling, localMatrix); } } // namespace tgfx