Skip to content

Commit

Permalink
Rename DrawArgs to FPArgs.
Browse files Browse the repository at this point in the history
  • Loading branch information
domchen committed Mar 31, 2024
1 parent 9fee156 commit fd65a0a
Show file tree
Hide file tree
Showing 37 changed files with 74 additions and 99 deletions.
4 changes: 2 additions & 2 deletions include/tgfx/core/Image.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include "tgfx/platform/NativeImage.h"

namespace tgfx {
class DrawArgs;
class FPArgs;
class Context;
class ImageFilter;
class FragmentProcessor;
Expand Down Expand Up @@ -283,7 +283,7 @@ class Image {
int alphaStartY) const;

virtual std::unique_ptr<FragmentProcessor> asFragmentProcessor(
const DrawArgs& args, TileMode tileModeX, TileMode tileModeY, const SamplingOptions& sampling,
const FPArgs& args, TileMode tileModeX, TileMode tileModeY, const SamplingOptions& sampling,
const Matrix* localMatrix) const = 0;

friend class FragmentProcessor;
Expand Down
2 changes: 1 addition & 1 deletion include/tgfx/core/ImageFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class ImageFilter {
* The returned processor is in the coordinate space of the source image.
*/
virtual std::unique_ptr<FragmentProcessor> onFilterImage(std::shared_ptr<Image> source,
const DrawArgs& args, TileMode tileModeX,
const FPArgs& args, TileMode tileModeX,
TileMode tileModeY,
const SamplingOptions& sampling,
const Matrix* localMatrix) const = 0;
Expand Down
2 changes: 1 addition & 1 deletion include/tgfx/core/MaskFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class MaskFilter {

private:
virtual std::unique_ptr<FragmentProcessor> asFragmentProcessor(
const DrawArgs& args, const Matrix* localMatrix) const = 0;
const FPArgs& args, const Matrix* localMatrix) const = 0;

friend class SurfaceCanvas;
};
Expand Down
2 changes: 1 addition & 1 deletion include/tgfx/core/Shader.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class Shader {
std::weak_ptr<Shader> weakThis;

virtual std::unique_ptr<FragmentProcessor> asFragmentProcessor(
const DrawArgs& args, const Matrix* localMatrix) const = 0;
const FPArgs& args, const Matrix* localMatrix) const = 0;

friend class FragmentProcessor;
friend class Canvas;
Expand Down
2 changes: 1 addition & 1 deletion src/filters/BlurImageFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Rect BlurImageFilter::onFilterBounds(const Rect& srcRect) const {
}

std::unique_ptr<FragmentProcessor> BlurImageFilter::onFilterImage(
std::shared_ptr<Image> source, const DrawArgs& args, TileMode tileModeX, TileMode tileModeY,
std::shared_ptr<Image> source, const FPArgs& args, TileMode tileModeX, TileMode tileModeY,
const SamplingOptions& sampling, const Matrix* localMatrix) const {
auto inputBounds = Rect::MakeWH(source->width(), source->height());
auto clipBounds = args.drawRect;
Expand Down
2 changes: 1 addition & 1 deletion src/filters/BlurImageFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class BlurImageFilter : public ImageFilter {
Rect onFilterBounds(const Rect& srcRect) const override;

std::unique_ptr<FragmentProcessor> onFilterImage(std::shared_ptr<Image> source,
const DrawArgs& args, TileMode tileModeX,
const FPArgs& args, TileMode tileModeX,
TileMode tileModeY,
const SamplingOptions& sampling,
const Matrix* localMatrix) const override;
Expand Down
4 changes: 2 additions & 2 deletions src/filters/DropShadowImageFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Rect DropShadowImageFilter::onFilterBounds(const Rect& srcRect) const {
}

std::unique_ptr<FragmentProcessor> DropShadowImageFilter::onFilterImage(
std::shared_ptr<Image> source, const DrawArgs& args, TileMode tileModeX, TileMode tileModeY,
std::shared_ptr<Image> source, const FPArgs& args, TileMode tileModeX, TileMode tileModeY,
const SamplingOptions& sampling, const Matrix* localMatrix) const {
auto inputBounds = Rect::MakeWH(source->width(), source->height());
auto clipBounds = args.drawRect;
Expand Down Expand Up @@ -93,7 +93,7 @@ std::unique_ptr<FragmentProcessor> DropShadowImageFilter::onFilterImage(
}

std::unique_ptr<FragmentProcessor> DropShadowImageFilter::getFragmentProcessor(
std::shared_ptr<Image> source, const DrawArgs& args, const SamplingOptions& sampling,
std::shared_ptr<Image> source, const FPArgs& args, const SamplingOptions& sampling,
const Matrix* localMatrix) const {
std::unique_ptr<FragmentProcessor> shadowProcessor;
auto shadowMatrix = Matrix::MakeTrans(-dx, -dy);
Expand Down
4 changes: 2 additions & 2 deletions src/filters/DropShadowImageFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ class DropShadowImageFilter : public ImageFilter {
Rect onFilterBounds(const Rect& srcRect) const override;

std::unique_ptr<FragmentProcessor> onFilterImage(std::shared_ptr<Image> source,
const DrawArgs& args, TileMode tileModeX,
const FPArgs& args, TileMode tileModeX,
TileMode tileModeY,
const SamplingOptions& sampling,
const Matrix* localMatrix) const override;

std::unique_ptr<FragmentProcessor> getFragmentProcessor(
std::shared_ptr<Image> source, const DrawArgs& args, const SamplingOptions& sampling,
std::shared_ptr<Image> source, const FPArgs& args, const SamplingOptions& sampling,
const Matrix* localMatrix = nullptr) const;
};
} // namespace tgfx
2 changes: 1 addition & 1 deletion src/filters/ShaderMaskFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ std::shared_ptr<MaskFilter> MaskFilter::MakeShader(std::shared_ptr<Shader> shade
}

std::unique_ptr<FragmentProcessor> ShaderMaskFilter::asFragmentProcessor(
const DrawArgs& args, const Matrix* localMatrix) const {
const FPArgs& args, const Matrix* localMatrix) const {
auto processor = FragmentProcessor::Make(shader, args, localMatrix);
return FragmentProcessor::MulInputByChildAlpha(std::move(processor), inverted);
}
Expand Down
2 changes: 1 addition & 1 deletion src/filters/ShaderMaskFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ShaderMaskFilter : public MaskFilter {
}

protected:
std::unique_ptr<FragmentProcessor> asFragmentProcessor(const DrawArgs& args,
std::unique_ptr<FragmentProcessor> asFragmentProcessor(const FPArgs& args,
const Matrix* localMatrix) const override;

private:
Expand Down
43 changes: 0 additions & 43 deletions src/gpu/DrawArgs.h

This file was deleted.

16 changes: 8 additions & 8 deletions src/gpu/SurfaceCanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Context* SurfaceCanvas::getContext() const {
return surface->getContext();
}

DrawArgs SurfaceCanvas::makeDrawArgs(const Rect& localBounds, const Matrix& viewMatrix) {
FPArgs SurfaceCanvas::makeFPArgs(const Rect& localBounds, const Matrix& viewMatrix) {
Matrix invert = {};
if (!viewMatrix.invert(&invert)) {
return {};
Expand Down Expand Up @@ -94,7 +94,7 @@ void SurfaceCanvas::onDrawRect(const Rect& rect, const FillStyle& style) {
if (drawAsClear(rect, viewMatrix, style)) {
return;
}
auto args = makeDrawArgs(rect, viewMatrix);
auto args = makeFPArgs(rect, viewMatrix);
if (args.empty()) {
return;
}
Expand Down Expand Up @@ -138,7 +138,7 @@ bool SurfaceCanvas::drawAsClear(const Rect& rect, const Matrix& viewMatrix,
}

void SurfaceCanvas::onDrawRRect(const RRect& rRect, const FillStyle& style) {
auto args = makeDrawArgs(rRect.rect, getMatrix());
auto args = makeFPArgs(rRect.rect, getMatrix());
if (args.empty()) {
return;
}
Expand All @@ -163,7 +163,7 @@ void SurfaceCanvas::onDrawPath(const Path& path, const FillStyle& style, const S
if (stroke != nullptr) {
pathBounds.outset(stroke->width, stroke->width);
}
auto args = makeDrawArgs(pathBounds, getMatrix());
auto args = makeFPArgs(pathBounds, getMatrix());
if (args.empty()) {
return;
}
Expand Down Expand Up @@ -234,7 +234,7 @@ void SurfaceCanvas::onDrawImageRect(const Rect& rect, std::shared_ptr<Image> ima
void SurfaceCanvas::drawImageRect(const Rect& rect, std::shared_ptr<Image> image,
const SamplingOptions& sampling, const Matrix& viewMatrix,
const FillStyle& style) {
auto args = makeDrawArgs(rect, viewMatrix);
auto args = makeFPArgs(rect, viewMatrix);
if (args.empty()) {
return;
}
Expand Down Expand Up @@ -269,7 +269,7 @@ void SurfaceCanvas::onDrawGlyphRun(GlyphRun glyphRun, const FillStyle& style,
auto bounds = glyphRun.getBounds(maxScale, stroke);
auto localBounds = bounds;
localBounds.scale(1.0f / maxScale, 1.0f / maxScale);
auto args = makeDrawArgs(localBounds, viewMatrix);
auto args = makeFPArgs(localBounds, viewMatrix);
if (args.empty()) {
return;
}
Expand Down Expand Up @@ -425,7 +425,7 @@ std::unique_ptr<FragmentProcessor> SurfaceCanvas::getClipMask(const Rect& device
return maskEffect;
}

void SurfaceCanvas::addDrawOp(std::unique_ptr<DrawOp> op, const DrawArgs& args,
void SurfaceCanvas::addDrawOp(std::unique_ptr<DrawOp> op, const FPArgs& args,
const FillStyle& style) {
if (op == nullptr || args.empty()) {
return;
Expand Down Expand Up @@ -511,7 +511,7 @@ static bool BlendModeIsOpaque(BlendMode mode, SrcColorOpacity opacityType) {
}
}

bool SurfaceCanvas::wouldOverwriteEntireSurface(DrawOp* op, const DrawArgs& args,
bool SurfaceCanvas::wouldOverwriteEntireSurface(DrawOp* op, const FPArgs& args,
const FillStyle& style) const {
if (op->classID() != FillRectOp::ClassID()) {
return false;
Expand Down
6 changes: 3 additions & 3 deletions src/gpu/SurfaceCanvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,17 @@ class SurfaceCanvas : public Canvas {
std::pair<std::optional<Rect>, bool> getClipRect(const Rect* drawBounds = nullptr);
std::unique_ptr<FragmentProcessor> getClipMask(const Rect& deviceBounds, const Matrix& viewMatrix,
Rect* scissorRect);
DrawArgs makeDrawArgs(const Rect& localBounds, const Matrix& viewMatrix);
FPArgs makeFPArgs(const Rect& localBounds, const Matrix& viewMatrix);
std::unique_ptr<FragmentProcessor> makeTextureMask(const Path& path, const Matrix& viewMatrix,
const Stroke* stroke = nullptr);
bool drawAsClear(const Rect& rect, const Matrix& viewMatrix, const FillStyle& style);
void drawImageRect(const Rect& rect, std::shared_ptr<Image> image,
const SamplingOptions& sampling, const Matrix& viewMatrix,
const FillStyle& style);
void drawColorGlyphs(const GlyphRun& glyphRun, const FillStyle& style);
void addDrawOp(std::unique_ptr<DrawOp> op, const DrawArgs& args, const FillStyle& style);
void addDrawOp(std::unique_ptr<DrawOp> op, const FPArgs& args, const FillStyle& style);
void addOp(std::unique_ptr<Op> op, bool discardContent);
bool wouldOverwriteEntireSurface(DrawOp* op, const DrawArgs& args, const FillStyle& style) const;
bool wouldOverwriteEntireSurface(DrawOp* op, const FPArgs& args, const FillStyle& style) const;
void replaceRenderTarget(std::shared_ptr<RenderTargetProxy> newRenderTargetProxy);

friend class Surface;
Expand Down
6 changes: 3 additions & 3 deletions src/gpu/processors/FragmentProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

namespace tgfx {
std::unique_ptr<FragmentProcessor> FragmentProcessor::Make(std::shared_ptr<Image> image,
const DrawArgs& args,
const FPArgs& args,
const SamplingOptions& sampling,
const Matrix* localMatrix) {
if (image == nullptr) {
Expand All @@ -35,7 +35,7 @@ std::unique_ptr<FragmentProcessor> FragmentProcessor::Make(std::shared_ptr<Image
}

std::unique_ptr<FragmentProcessor> FragmentProcessor::Make(std::shared_ptr<Image> image,
const tgfx::DrawArgs& args,
const tgfx::FPArgs& args,
TileMode tileModeX, TileMode tileModeY,
const SamplingOptions& sampling,
const Matrix* localMatrix) {
Expand All @@ -46,7 +46,7 @@ std::unique_ptr<FragmentProcessor> FragmentProcessor::Make(std::shared_ptr<Image
}

std::unique_ptr<FragmentProcessor> FragmentProcessor::Make(std::shared_ptr<Shader> shader,
const DrawArgs& args,
const FPArgs& args,
const Matrix* localMatrix) {
if (shader == nullptr) {
return nullptr;
Expand Down
25 changes: 22 additions & 3 deletions src/gpu/processors/FragmentProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,39 @@ class Pipeline;
class Image;
class Shader;

class FPArgs {
public:
FPArgs() = default;

FPArgs(Context* context, uint32_t renderFlags, const Rect& drawRect,
const Matrix& viewMatrix = Matrix::I())
: context(context), renderFlags(renderFlags), drawRect(drawRect), viewMatrix(viewMatrix) {
}

bool empty() const {
return context == nullptr || drawRect.isEmpty();
}

Context* context = nullptr;
uint32_t renderFlags = 0;
Rect drawRect = Rect::MakeEmpty();
Matrix viewMatrix = Matrix::I();
};

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<FragmentProcessor> Make(std::shared_ptr<Image> image, const DrawArgs& args,
static std::unique_ptr<FragmentProcessor> Make(std::shared_ptr<Image> image, const FPArgs& 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<FragmentProcessor> Make(std::shared_ptr<Image> image, const DrawArgs& args,
static std::unique_ptr<FragmentProcessor> Make(std::shared_ptr<Image> image, const FPArgs& args,
TileMode tileModeX, TileMode tileModeY,
const SamplingOptions& sampling,
const Matrix* localMatrix = nullptr);
Expand All @@ -55,7 +74,7 @@ class FragmentProcessor : public Processor {
* Creates a fragment processor that will draw the given Shader with the given options.
*/
static std::unique_ptr<FragmentProcessor> Make(std::shared_ptr<Shader> shader,
const DrawArgs& args,
const FPArgs& args,
const Matrix* localMatrix = nullptr);

/**
Expand Down
1 change: 0 additions & 1 deletion src/gpu/processors/Processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

#pragma once

#include "gpu/DrawArgs.h"
#include "tgfx/gpu/Context.h"
#include "tgfx/utils/BytesKey.h"
#include "utils/UniqueID.h"
Expand Down
2 changes: 1 addition & 1 deletion src/images/FilterImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ std::shared_ptr<Image> FilterImage::onMakeSubset(const Rect& subset) const {
}

std::unique_ptr<FragmentProcessor> FilterImage::asFragmentProcessor(
const DrawArgs& args, TileMode tileModeX, TileMode tileModeY, const SamplingOptions& sampling,
const FPArgs& args, TileMode tileModeX, TileMode tileModeY, const SamplingOptions& sampling,
const Matrix* localMatrix) const {
auto matrix = SubsetImage::ConcatLocalMatrix(bounds, localMatrix);
return filter->onFilterImage(source, args, tileModeX, tileModeY, sampling, AddressOf(matrix));
Expand Down
2 changes: 1 addition & 1 deletion src/images/FilterImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class FilterImage : public TransformImage {

std::shared_ptr<Image> onMakeSubset(const Rect& subset) const override;

std::unique_ptr<FragmentProcessor> asFragmentProcessor(const DrawArgs& args, TileMode tileModeX,
std::unique_ptr<FragmentProcessor> asFragmentProcessor(const FPArgs& args, TileMode tileModeX,
TileMode tileModeY,
const SamplingOptions& sampling,
const Matrix* localMatrix) const override;
Expand Down
2 changes: 1 addition & 1 deletion src/images/OrientImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ std::shared_ptr<Image> OrientImage::onMakeOriented(Orientation newOrientation) c
}

std::unique_ptr<FragmentProcessor> OrientImage::asFragmentProcessor(
const DrawArgs& args, TileMode tileModeX, TileMode tileModeY, const SamplingOptions& sampling,
const FPArgs& args, TileMode tileModeX, TileMode tileModeY, const SamplingOptions& sampling,
const Matrix* localMatrix) const {
auto matrix = concatLocalMatrix(localMatrix);
return FragmentProcessor::Make(source, args, tileModeX, tileModeY, sampling, AddressOf(matrix));
Expand Down
2 changes: 1 addition & 1 deletion src/images/OrientImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class OrientImage : public TransformImage {

std::shared_ptr<Image> onMakeOriented(Orientation newOrientation) const override;

std::unique_ptr<FragmentProcessor> asFragmentProcessor(const DrawArgs& args, TileMode tileModeX,
std::unique_ptr<FragmentProcessor> asFragmentProcessor(const FPArgs& args, TileMode tileModeX,
TileMode tileModeY,
const SamplingOptions& sampling,
const Matrix* localMatrix) const override;
Expand Down
2 changes: 1 addition & 1 deletion src/images/RGBAAAImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ std::shared_ptr<Image> RGBAAAImage::onCloneWith(std::shared_ptr<Image> newSource
}

std::unique_ptr<FragmentProcessor> RGBAAAImage::asFragmentProcessor(
const DrawArgs& args, TileMode, TileMode, const SamplingOptions& sampling,
const FPArgs& args, TileMode, TileMode, const SamplingOptions& sampling,
const Matrix* localMatrix) const {
auto proxy = std::static_pointer_cast<ResourceImage>(source)->lockTextureProxy(args.context,
args.renderFlags);
Expand Down
2 changes: 1 addition & 1 deletion src/images/RGBAAAImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class RGBAAAImage : public SubsetImage {
protected:
std::shared_ptr<Image> onCloneWith(std::shared_ptr<Image> newSource) const override;

std::unique_ptr<FragmentProcessor> asFragmentProcessor(const DrawArgs& args, TileMode tileModeX,
std::unique_ptr<FragmentProcessor> asFragmentProcessor(const FPArgs& args, TileMode tileModeX,
TileMode tileModeY,
const SamplingOptions& sampling,
const Matrix* localMatrix) const override;
Expand Down
Loading

0 comments on commit fd65a0a

Please sign in to comment.