7 #if (defined OS_MAC || defined OS_IOS) && !defined IGRAPHICS_SKIA_NO_METAL 11 #if defined IGRAPHICS_GL 15 #pragma warning( push ) 16 #pragma warning( disable : 4244 ) 17 #include "SkSurface.h" 21 #include "GrDirectContext.h" 22 #pragma warning( pop ) 25 BEGIN_IGRAPHICS_NAMESPACE
28 SkRect SkiaRect(
const IRECT& r);
31 SkBlendMode SkiaBlendMode(
const IBlend* pBlend);
34 SkColor SkiaColor(
const IColor& color,
const IBlend* pBlend);
37 SkTileMode SkiaTileMode(
const IPattern& pattern);
65 void PathArc(
float cx,
float cy,
float r,
float a1,
float a2, EWinding winding)
override;
67 void PathMoveTo(
float x,
float y)
override { mMainPath.moveTo(mMatrix.mapXY(x, y)); }
68 void PathLineTo(
float x,
float y)
override { mMainPath.lineTo(mMatrix.mapXY(x, y)); }
72 mMainPath.cubicTo(mMatrix.mapXY(x1, y1), mMatrix.mapXY(x2, y2), mMatrix.mapXY(x3, y3));
77 mMainPath.quadTo(mMatrix.mapXY(cx, cy), mMatrix.mapXY(x2, y2));
83 #ifdef IGRAPHICS_DRAWFILL_DIRECT 94 void DrawArc(
const IColor& color,
float cx,
float cy,
float r,
float a1,
float a2,
const IBlend* pBlend,
float thickness)
override;
95 void DrawCircle(
const IColor& color,
float cx,
float cy,
float r,
const IBlend* pBlend,
float thickness)
override;
105 void FillArc(
const IColor& color,
float cx,
float cy,
float r,
float a1,
float a2,
const IBlend* pBlend)
override;
131 bool LoadAPIFont(
const char* fontID,
const PlatformFontPtr& font)
override;
133 APIBitmap*
LoadAPIBitmap(
const char* fileNameOrResID,
int scale, EResourceLocation location,
const char* ext)
override;
136 void DrawImGui(SkSurface* surface);
138 void PrepareAndMeasureText(
const IText& text,
const char* str,
IRECT& r,
double& x,
double & y, SkFont& font)
const;
140 void PathTransformSetMatrix(
const IMatrix& m)
override;
141 void SetClipRegion(
const IRECT& r)
override;
143 void RenderPath(SkPaint& paint);
145 sk_sp<SkSurface> mSurface;
146 SkCanvas* mCanvas =
nullptr;
149 SkMatrix mClipMatrix;
150 SkMatrix mFinalMatrix;
152 #if defined OS_WIN && defined IGRAPHICS_CPU 153 WDL_TypedBuf<uint8_t> mSurfaceMemory;
156 #ifndef IGRAPHICS_CPU 157 sk_sp<GrDirectContext> mGrContext;
158 sk_sp<SkSurface> mScreenSurface;
161 #ifdef IGRAPHICS_METAL 163 void* mMTLCommandQueue;
168 static StaticStorage<Font> sFontCache;
171 END_IGRAPHICS_NAMESPACE
const char * GetDrawingAPIStr() override
void UpdateLayer() override
Implemented by a graphics backend to prepare for drawing to the layer at the top of the stack...
void PathLineTo(float x, float y) override
Add a line to the current path from the current point to the specified location.
void PathQuadraticBezierTo(float cx, float cy, float x2, float y2) override
Add a quadratic bezier to the current path from the current point to the specified location...
Used to manage a rectangular area, independent of draw class/platform.
virtual void DrawRect(const IColor &color, const IRECT &bounds, const IBlend *pBlend=0, float thickness=1.f)
Draw a rectangle to the graphics context.
Used to manage composite/blend operations, independent of draw class/platform.
User-facing bitmap abstraction that you use to manage bitmap data, independant of draw class/platform...
Used to manage fill behaviour for path based drawing back ends.
bool BitmapExtSupported(const char *ext) override
Checks a file extension and reports whether this drawing API supports loading that extension...
APIBitmap * CreateAPIBitmap(int width, int height, int scale, double drawScale, bool cacheable=false) override
Creates a new API bitmap, either in memory or as a GPU texture.
virtual void FillCircle(const IColor &color, float cx, float cy, float r, const IBlend *pBlend=0)
Fill a circle with a color.
void GetLayerBitmapData(const ILayerPtr &layer, RawBitmapData &data) override
Get the contents of a layers pixels as bitmap data.
void PathArc(float cx, float cy, float r, float a1, float a2, EWinding winding) override
Add an arc to the current path.
virtual void DrawRoundRect(const IColor &color, const IRECT &bounds, float cornerRadius=5.f, const IBlend *pBlend=0, float thickness=1.f)
Draw a rounded rectangle to the graphics context.
Used to manage color data, independent of draw class/platform.
void DrawBitmap(const IBitmap &bitmap, const IRECT &dest, int srcX, int srcY, const IBlend *pBlend) override
Draw a bitmap (raster) image to the graphics context.
Used to manage stroke behaviour for path based drawing back ends.
void EndFrame() override
Called by some drawing API classes to finally blit the draw bitmap onto the screen or perform other c...
void DrawResize() override
void PathClose() override
Close the path that is being specified.
The lowest level base class of an IGraphics context.
An editor delegate base class for a SOMETHING that uses IGraphics for it's UI.
void PathMoveTo(float x, float y) override
Move the current point in the current path.
IText is used to manage font and text/text entry style for a piece of text on the UI...
virtual void DrawCircle(const IColor &color, float cx, float cy, float r, const IBlend *pBlend=0, float thickness=1.f)
Draw a circle to the graphics context.
int AlphaChannel() const override
float DoMeasureText(const IText &text, const char *str, IRECT &bounds) const override
void PathClear() override
Clear the stack of path drawing commands.
virtual void FillArc(const IColor &color, float cx, float cy, float r, float a1, float a2, const IBlend *pBlend=0)
Fill an arc segment with a color.
void OnViewDestroyed() override
Called after a platform view is destroyed, so that drawing classes can e.g.
The lowest level base class of an IGraphics context.
Used to specify properties of a drop-shadow to a layer.
void ApplyShadowMask(ILayerPtr &layer, RawBitmapData &mask, const IShadow &shadow) override
Implemented by a graphics backend to apply a calculated shadow mask to a layer, according to the shad...
void OnViewInitialized(void *pContext) override
Called after platform view initialization, so that drawing classes can e.g.
virtual void FillRoundRect(const IColor &color, const IRECT &bounds, float cornerRadius=5.f, const IBlend *pBlend=0)
Fill a rounded rectangle with a color.
virtual void FillRect(const IColor &color, const IRECT &bounds, const IBlend *pBlend=0)
Fill a rectangular region of the graphics context with a color.
virtual void FillEllipse(const IColor &color, const IRECT &bounds, const IBlend *pBlend=0)
Fill an ellipse within a rectangular region of the graphics context.
virtual void DrawEllipse(const IColor &color, const IRECT &bounds, const IBlend *pBlend=0, float thickness=1.f)
Draw an ellipse within a rectangular region of the graphics context.
IGraphics draw class using Skia.
void PathCubicBezierTo(float x1, float y1, float x2, float y2, float x3, float y3) override
Add a cubic bezier to the current path from the current point to the specified location.
bool FlippedBitmap() const override
IColor GetPoint(int x, int y) override
Get the color at an X, Y location in the graphics context.
void * GetDrawContext() override
Gets a void pointer to underlying drawing context, for the IGraphics backend See draw class implement...
void DoDrawText(const IText &text, const char *str, const IRECT &bounds, const IBlend *pBlend) override
A base class interface for a bitmap abstraction around the different drawing back end bitmap represen...
void PathStroke(const IPattern &pattern, float thickness, const IStrokeOptions &options, const IBlend *pBlend) override
Stroke the current current path.
bool LoadAPIFont(const char *fontID, const PlatformFontPtr &font) override
Drawing API method to load a font from a PlatformFontPtr, called internally.
void BeginFrame() override
Called at the beginning of drawing.
void DrawFastDropShadow(const IRECT &innerBounds, const IRECT &outerBounds, float xyDrop, float roundness, float blur, IBlend *pBlend) override
NanoVG only.
virtual void DrawArc(const IColor &color, float cx, float cy, float r, float a1, float a2, const IBlend *pBlend=0, float thickness=1.f)
Draw an arc to the graphics context.
void PathFill(const IPattern &pattern, const IFillOptions &options, const IBlend *pBlend) override
Fill the current current path.
std::unique_ptr< ILayer > ILayerPtr
ILayerPtr is a managed pointer for transferring the ownership of layers.
Used to store pattern information for gradients.
APIBitmap * LoadAPIBitmap(const char *fileNameOrResID, int scale, EResourceLocation location, const char *ext) override
Drawing API method to load a bitmap, called internally.
Used to store transformation matrices.