90#ifdef SK_BUILD_FOR_MAC
98 CGContextRef cg = (CGContextRef)fCanvas->accessTopRasterHandle();
105 CGContextSetFillColorWithColor(cg,
color);
106 CGContextFillRect(cg, CGRectMake(r.
x(), r.
y(), r.
width(), r.
height()));
110static CGAffineTransform matrix_to_transform(CGContextRef cg,
const SkMatrix& ctm) {
130 CGContextRef cg = SkCreateCGContext(
SkPixmap(
info,
nullptr, 0));
134 rec->fReleaseProc = [](
void* pixels,
void* ctx){ CGContextRelease((CGContextRef)ctx); };
135 rec->fReleaseCtx = cg;
136 rec->fPixels = CGBitmapContextGetData(cg);
137 rec->fRowBytes = CGBitmapContextGetBytesPerRow(cg);
139 CGContextSaveGState(cg);
144 CGContextRef cg = (CGContextRef)hndl;
146 CGContextRestoreGState(cg);
147 CGContextSaveGState(cg);
148 CGContextClipToRect(cg, CGRectMake(
clip.x(),
clip.y(),
clip.width(),
clip.height()));
149 CGContextConcatCTM(cg, matrix_to_transform(cg, ctm));
153using MyPort = CGGraphicsPort;
156#elif defined(SK_BUILD_FOR_WIN)
160static RECT toRECT(
const SkIRect& r) {
169 HDC hdc = (HDC)fCanvas->accessTopRasterHandle();
172 RECT rounded = toRECT(r.
round());
173 FillRect(hdc, &rounded, CreateSolidBrush(cr));
178 fCanvas->drawRect(r,
paint);
187 BITMAPINFOHEADER hdr;
188 memset(&hdr, 0,
sizeof(hdr));
189 hdr.biSize =
sizeof(BITMAPINFOHEADER);
194 hdr.biCompression = BI_RGB;
196 hdr.biXPelsPerMeter = 1;
197 hdr.biYPelsPerMeter = 1;
199 HBITMAP hbitmap = CreateDIBSection(
nullptr, (
const BITMAPINFO*)&hdr, 0, &pixels, 0, 0);
207 HDC hdc = CreateCompatibleDC(
nullptr);
209 DeleteObject(hbitmap);
212 SetGraphicsMode(hdc, GM_ADVANCED);
213 HGDIOBJ origBitmap = SelectObject(hdc, hbitmap);
221 HBITMAP hbitmap =
static_cast<HBITMAP
>(SelectObject(ctx->hdc, ctx->hbitmap));
222 DeleteObject(hbitmap);
246 HDC hdc =
static_cast<HDC
>(handle);
255 SetWorldTransform(hdc, &xf);
257 RECT clip_bounds_RECT = toRECT(clip_bounds);
258 HRGN hrgn = CreateRectRgnIndirect(&clip_bounds_RECT);
259 [[maybe_unused]]
int result = SelectClipRgn(hdc, hrgn);
261 result = DeleteObject(hrgn);
266using MyPort = GDIGraphicsPort;
282 port->translate(30, 30);
287 port->saveLayer({50, 50, 100, 100}, 0x80);
291 port->clip({150, 50, 200, 200});
292 port->drawRect({0, 0, 256, 256}, 0xFFCCCCCC);
300 std::unique_ptr<SkCanvas> nativeCanvas =
302 MyPort nativePort(nativeCanvas.get());
306 nativeCanvas->peekPixels(&pm);
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
sk_bzero(glyphs, sizeof(glyphs))
static sk_sp< Effect > Create()
@ kDstATop
r = d*sa + s*(1-da)
#define SkColorGetR(color)
#define SkColorGetG(color)
constexpr SkColor SK_ColorBLUE
constexpr SkColor SK_ColorRED
constexpr SkColor SK_ColorGREEN
#define SkColorGetA(color)
#define SkColorGetB(color)
constexpr SkColor SK_ColorWHITE
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
static void SkSafeUnref(T *obj)
void drawOval(const SkRect &r, SkColor c)
void translate(float x, float y)
void saveLayer(const SkRect &bounds, SkAlpha alpha)
SkCanvas * peekCanvas() const
virtual void drawRect(const SkRect &r, SkColor c)
void clip(const SkRect &r)
GraphicsPort(SkCanvas *canvas)
SkRasterHandleAllocator::Handle accessTopRasterHandle() const
void drawRect(const SkRect &rect, const SkPaint &paint)
void drawOval(const SkRect &oval, const SkPaint &paint)
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
bool peekPixels(SkPixmap *pixmap)
void translate(SkScalar dx, SkScalar dy)
int saveLayerAlpha(const SkRect *bounds, U8CPU alpha)
void scale(SkScalar sx, SkScalar sy)
void concat(const SkMatrix &matrix)
static constexpr int kMScaleX
horizontal scale factor
static constexpr int kMTransY
vertical translation
static constexpr int kMTransX
horizontal translation
static constexpr int kMSkewY
vertical skew factor
static constexpr int kMScaleY
vertical scale factor
static constexpr int kMSkewX
horizontal skew factor
void * writable_addr() const
static std::unique_ptr< SkCanvas > MakeCanvas(std::unique_ptr< SkRasterHandleAllocator >, const SkImageInfo &, const Rec *rec=nullptr, const SkSurfaceProps *props=nullptr)
virtual void updateHandle(Handle, const SkMatrix &, const SkIRect &)=0
virtual bool allocHandle(const SkImageInfo &, Rec *)=0
void updateHandle(Handle hndl, const SkMatrix &ctm, const SkIRect &clip) override
bool allocHandle(const SkImageInfo &info, Rec *rec) override
SkiaGraphicsPort(SkCanvas *canvas)
void drawRect(const SkRect &r, SkColor c) override
SK_API sk_sp< SkImage > RasterFromPixmapCopy(const SkPixmap &pixmap)
unsigned useCenter Optional< SkMatrix > matrix
Optional< SkRect > bounds
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service port
DEF_SIMPLE_GM(rasterallocator, canvas, 600, 300)
constexpr int32_t top() const
constexpr int32_t bottom() const
constexpr int32_t right() const
constexpr int32_t left() const
static SkImageInfo MakeN32Premul(int width, int height)
void(* fReleaseProc)(void *pixels, void *ctx)
static SkRect Make(const SkISize &size)
constexpr float x() const
constexpr float y() const
void round(SkIRect *dst) const
constexpr float height() const
constexpr float width() const