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 "include/core/SkSurface.h"
18#include "include/core/SkPath.h"
19#include "include/core/SkCanvas.h"
20#include "include/core/SkImage.h"
21#include "include/gpu/GrDirectContext.h"
24namespace skia::textlayout {
29BEGIN_IGRAPHICS_NAMESPACE
32SkRect SkiaRect(
const IRECT& r);
35SkBlendMode SkiaBlendMode(
const IBlend* pBlend);
38SkColor SkiaColor(
const IColor& color,
const IBlend* pBlend);
41SkTileMode SkiaTileMode(
const IPattern& pattern);
69 void PathArc(
float cx,
float cy,
float r,
float a1,
float a2, EWinding winding)
override;
71 void PathMoveTo(
float x,
float y)
override { mMainPath.moveTo(mMatrix.mapXY(x, y)); }
72 void PathLineTo(
float x,
float y)
override { mMainPath.lineTo(mMatrix.mapXY(x, y)); }
76 mMainPath.cubicTo(mMatrix.mapXY(x1, y1), mMatrix.mapXY(x2, y2), mMatrix.mapXY(x3, y3));
81 mMainPath.quadTo(mMatrix.mapXY(cx, cy), mMatrix.mapXY(x2, y2));
87#ifdef IGRAPHICS_DRAWFILL_DIRECT
98 void DrawArc(
const IColor& color,
float cx,
float cy,
float r,
float a1,
float a2,
const IBlend* pBlend,
float thickness)
override;
99 void DrawCircle(
const IColor& color,
float cx,
float cy,
float r,
const IBlend* pBlend,
float thickness)
override;
109 void FillArc(
const IColor& color,
float cx,
float cy,
float r,
float a1,
float a2,
const IBlend* pBlend)
override;
137 bool LoadAPIFont(
const char* fontID,
const PlatformFontPtr& font)
override;
139 APIBitmap*
LoadAPIBitmap(
const char* fileNameOrResID,
int scale, EResourceLocation location,
const char* ext)
override;
142 void PrepareAndMeasureText(
const IText& text,
const char* str,
IRECT& r,
double& x,
double & y, SkFont& font)
const;
144 void PathTransformSetMatrix(
const IMatrix& m)
override;
145 void SetClipRegion(
const IRECT& r)
override;
147 void RenderPath(SkPaint& paint);
149 sk_sp<SkSurface> mSurface;
150 SkCanvas* mCanvas =
nullptr;
153 SkMatrix mClipMatrix;
154 SkMatrix mFinalMatrix;
156#if defined OS_WIN && defined IGRAPHICS_CPU
157 WDL_TypedBuf<uint8_t> mSurfaceMemory;
161 sk_sp<GrDirectContext> mGrContext;
162 sk_sp<SkSurface> mScreenSurface;
165#if !defined IGRAPHICS_NO_SKIA_SKPARAGRAPH
166 sk_sp<skia::textlayout::FontCollection> mFontCollection;
169#ifdef IGRAPHICS_METAL
171 void* mMTLCommandQueue;
176 static StaticStorage<Font> sFontCache;
179END_IGRAPHICS_NAMESPACE
A base class interface for a bitmap abstraction around the different drawing back end bitmap represen...
User-facing bitmap abstraction that you use to manage bitmap data, independant of draw class/platform...
An editor delegate base class that uses IGraphics for the UI.
The lowest level base class of an IGraphics context.
virtual void DrawRect(const IColor &color, const IRECT &bounds, const IBlend *pBlend=0, float thickness=1.f)
Draw a rectangle to the graphics context.
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.
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.
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 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.
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.
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 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.
virtual void FillCircle(const IColor &color, float cx, float cy, float r, const IBlend *pBlend=0)
Fill a circle with a color.
IGraphics draw class using Skia.
APIBitmap * LoadAPIBitmap(const char *fileNameOrResID, int scale, EResourceLocation location, const char *ext) override
Drawing API method to load a bitmap, called internally.
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.
void BeginFrame() override
Called at the beginning of drawing.
void GetLayerBitmapData(const ILayerPtr &layer, RawBitmapData &data) override
Get the contents of a layer as Raw RGBA bitmap data NOTE: you should only call this within IControl::...
void DrawResize() override
void DoDrawText(const IText &text, const char *str, const IRECT &bounds, const IBlend *pBlend) override
void PathStroke(const IPattern &pattern, float thickness, const IStrokeOptions &options, const IBlend *pBlend) override
Stroke the current current path.
void EndFrame() override
Called by some drawing API classes to finally blit the draw bitmap onto the screen or perform other c...
float DoMeasureText(const IText &text, const char *str, IRECT &bounds) const override
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.
void PathArc(float cx, float cy, float r, float a1, float a2, EWinding winding) override
Add an arc to the current path.
int AlphaChannel() const override
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...
const char * GetDrawingAPIStr() override
APIBitmap * CreateAPIBitmap(int width, int height, float scale, double drawScale, bool cacheable=false) override
Creates a new API bitmap, either in memory or as a GPU texture.
void * GetDrawContext() override
Gets a void pointer to underlying drawing context, for the IGraphics backend See draw class implement...
bool LoadAPIFont(const char *fontID, const PlatformFontPtr &font) override
Drawing API method to load a font from a PlatformFontPtr, called internally.
void OnViewInitialized(void *pContext) override
Called after platform view initialization, so that drawing classes can e.g.
void PathClear() override
Clear the stack of path drawing commands.
void PathMoveTo(float x, float y) override
Move the current point in the current path.
void UpdateLayer() override
Implemented by a graphics backend to prepare for drawing to the layer at the top of the stack.
void DrawMultiLineText(const IText &text, const char *str, const IRECT &bounds, const IBlend *pBlend) override
Draw some multi-line text to the graphics context in a specific rectangle (NanoVG only)
void PathFill(const IPattern &pattern, const IFillOptions &options, const IBlend *pBlend) override
Fill the current current path.
bool BitmapExtSupported(const char *ext) override
Checks a file extension and reports whether this drawing API supports loading that extension.
void PathClose() override
Close the path that is being specified.
IColor GetPoint(int x, int y) override
Get the color at an X, Y location in the graphics context.
void PathLineTo(float x, float y) override
Add a line to the current path from the current point to the specified location.
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.
bool FlippedBitmap() const override
void DrawFastDropShadow(const IRECT &innerBounds, const IRECT &outerBounds, float xyDrop, float roundness, float blur, IBlend *pBlend) override
NanoVG only.
void OnViewDestroyed() override
Called after a platform view is destroyed, so that drawing classes can e.g.
std::unique_ptr< ILayer > ILayerPtr
ILayerPtr is a managed pointer for transferring the ownership of layers.
Used to manage stroke behaviour for path based drawing back ends.
Used to manage composite/blend operations, independent of draw class/platform.
Used to manage color data, independent of draw class/platform.
Used to manage fill behaviour.
Used to store transformation matrices.
Used to store pattern information for gradients.
Used to manage a rectangular area, independent of draw class/platform.
Used to specify properties of a drop-shadow to a layer.
IText is used to manage font and text/text entry style for a piece of text on the UI,...