Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkCGUtils.h
Go to the documentation of this file.
1
2/*
3 * Copyright 2011 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8#ifndef SkCGUtils_DEFINED
9#define SkCGUtils_DEFINED
10
14#include "include/core/SkSize.h"
15
16#if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
17
18#ifdef SK_BUILD_FOR_MAC
19#include <ApplicationServices/ApplicationServices.h>
20#endif
21
22#ifdef SK_BUILD_FOR_IOS
23#include <CoreGraphics/CoreGraphics.h>
24#endif
25
26class SkBitmap;
27class SkColorSpace;
28class SkData;
29class SkPixmap;
31
32SK_API CGContextRef SkCreateCGContext(const SkPixmap&);
33
34/**
35 * Given a CGImage, allocate an SkBitmap and copy the image's pixels into it. If scaleToFit is not
36 * null, use it to determine the size of the bitmap, and scale the image to fill the bitmap.
37 * Otherwise use the image's width/height.
38 *
39 * On failure, return false, and leave bitmap unchanged.
40 */
41SK_API bool SkCreateBitmapFromCGImage(SkBitmap* dst, CGImageRef src);
42
43SK_API sk_sp<SkImage> SkMakeImageFromCGImage(CGImageRef);
44
45/**
46 * Given a CGColorSpace, return the closest matching SkColorSpace. If no conversion is possible
47 * or if the input CGColorSpace is nullptr then return nullptr.
48 */
49SK_API sk_sp<SkColorSpace> SkMakeColorSpaceFromCGColorSpace(CGColorSpaceRef);
50
51/**
52 * Copy the pixels from src into the memory specified by info/rowBytes/dstPixels. On failure,
53 * return false (e.g. ImageInfo incompatible with src).
54 */
55SK_API bool SkCopyPixelsFromCGImage(const SkImageInfo& info, size_t rowBytes, void* dstPixels,
56 CGImageRef src);
57static inline bool SkCopyPixelsFromCGImage(const SkPixmap& dst, CGImageRef src) {
58 return SkCopyPixelsFromCGImage(dst.info(), dst.rowBytes(), dst.writable_addr(), src);
59}
60
61/**
62 * Create an imageref from the specified bitmap. The color space parameter is ignored.
63 */
64SK_API CGImageRef SkCreateCGImageRefWithColorspace(const SkBitmap& bm,
65 CGColorSpaceRef space);
66
67/**
68 * Create an imageref from the specified bitmap.
69 */
70SK_API CGImageRef SkCreateCGImageRef(const SkBitmap& bm);
71
72/**
73 * Given an SkColorSpace, create a CGColorSpace. This will return sRGB if the specified
74 * SkColorSpace is nullptr or on failure. This will not retain the specified SkColorSpace.
75 */
76SK_API CGColorSpaceRef SkCreateCGColorSpace(const SkColorSpace*);
77
78/**
79 * Given an SkData, create a CGDataProviderRef that refers to the and retains the specified data.
80 */
81SK_API CGDataProviderRef SkCreateCGDataProvider(sk_sp<SkData>);
82
83/**
84 * Draw the bitmap into the specified CG context. (x,y) specifies the position of the top-left
85 * corner of the bitmap.
86 */
87void SkCGDrawBitmap(CGContextRef, const SkBitmap&, float x, float y);
88
89#endif // defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
90#endif // SkCGUtils_DEFINED
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
#define SK_API
Definition SkAPI.h:35
double y
double x
dst
Definition cp.py:12