45 bitmap.eraseColor(0x00000000);
66 float left,
float top,
float right,
float bottom,
69 if (!
rect.isEmpty()) {
78 m.setScaleTranslate(sx, sy, tx, ty);
98 SkRect deviceBounds = bBox;
110 deviceBounds.
join(bitmapBounds);
115 auto patternDevice = sk_make_sp<SkPDFDevice>(patternDeviceSize, doc);
124 patternBBox.
offset(-deviceBounds.
left(), -deviceBounds.
top());
162 bitmap, 0, 0, paintColor.fA);
178 if (deviceBounds.
left() < 0) {
190 patternBBox.
fLeft = 0;
210 if (deviceBounds.
left() < 0) {
211 patternBBox.
fLeft = 0;
221 if (deviceBounds.
top() < 0) {
233 patternBBox.
fTop = 0;
253 if (deviceBounds.
top() < 0) {
254 patternBBox.
fTop = 0;
261 auto imageShader = patternDevice->content();
262 std::unique_ptr<SkPDFDict> resourceDict = patternDevice->makeResourceDict();
265 std::move(resourceDict), finalMatrix);
266 return SkPDFStreamOut(std::move(dict), std::move(imageShader), doc);
287 static const int kMaxBitmapArea = 1024 * 1024;
290 if (bitmapArea > (
float)kMaxBitmapArea) {
291 rasterScale *=
SkScalarSqrt((
float)kMaxBitmapArea / bitmapArea);
309 canvas->
translate(-shaderRect.
x(), -shaderRect.
y());
313 shaderTransform.preScale(1 /
scale.width(), 1 /
scale.height());
327 if (img->isAlphaOnly()) {
331 return SkColor4f{0, 0, 0, paintColor.fA};
352 if (
SkImage* skimg = shader->
isAImage(&shaderTransform, imageTileModes)) {
358 {imageTileModes[0], imageTileModes[1]},
SkAssertResult(font.textToGlyphs("Hello", 5, SkTextEncoding::kUTF8, glyphs, std::size(glyphs))==count)
constexpr SkColor SK_ColorTRANSPARENT
SkBitmapKey SkBitmapKeyFromImage(const SkImage *image)
static void draw_matrix(SkCanvas *canvas, const SkImage *image, const SkMatrix &matrix, SkColor4f paintColor)
static SkPDFIndirectReference make_image_shader(SkPDFDocument *doc, SkMatrix finalMatrix, SkTileMode tileModesX, SkTileMode tileModesY, SkRect bBox, const SkImage *image, SkColor4f paintColor)
static void draw_bitmap_matrix(SkCanvas *canvas, const SkBitmap &bm, const SkMatrix &matrix, SkColor4f paintColor)
SkPDFIndirectReference SkPDFMakeShader(SkPDFDocument *doc, SkShader *shader, const SkMatrix &canvasTransform, const SkIRect &surfaceBBox, SkColor4f paintColor)
static bool is_tiled(SkTileMode m)
static void fill_color_from_bitmap(SkCanvas *canvas, float left, float top, float right, float bottom, const SkBitmap &bitmap, int x, int y, float alpha)
static SkPDFIndirectReference make_fallback_shader(SkPDFDocument *doc, SkShader *shader, const SkMatrix &canvasTransform, const SkIRect &surfaceBBox, SkColor4f paintColor)
static SkBitmap to_bitmap(const SkImage *image)
static void draw(SkCanvas *canvas, const SkImage *image, SkColor4f paintColor)
static SkColor4f adjust_color(SkShader *shader, SkColor4f paintColor)
static SkMatrix scale_translate(SkScalar sx, SkScalar sy, SkScalar tx, SkScalar ty)
SkPDFIndirectReference SkPDFStreamOut(std::unique_ptr< SkPDFDict > dict, std::unique_ptr< SkStreamAsset > content, SkPDFDocument *doc, SkPDFSteamCompressionEnabled compress)
static std::unique_ptr< SkPDFDict > SkPDFMakeDict(const char *type=nullptr)
static bool left(const SkPoint &p0, const SkPoint &p1)
static bool right(const SkPoint &p0, const SkPoint &p1)
sk_sp< T > sk_ref_sp(T *obj)
#define SkScalarCeilToInt(x)
SkShaderBase * as_SB(SkShader *shader)
static constexpr const T & SkTPin(const T &x, const T &lo, const T &hi)
sk_sp< SkImage > asImage() const
void drawRect(const SkRect &rect, const SkPaint &paint)
void translate(SkScalar dx, SkScalar dy)
void drawPaint(const SkPaint &paint)
void clear(SkColor color)
void scale(SkScalar sx, SkScalar sy)
void concat(const SkMatrix &matrix)
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
SkISize dimensions() const
SkMatrix & postTranslate(SkScalar dx, SkScalar dy)
SkMatrix & postScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py)
static SkMatrix Translate(SkScalar dx, SkScalar dy)
static SkMatrix Concat(const SkMatrix &a, const SkMatrix &b)
SkMatrix & preTranslate(SkScalar dx, SkScalar dy)
skia_private::THashMap< SkPDFImageShaderKey, SkPDFIndirectReference, SkPDFImageShaderKey::Hash > fImageShaderMap
SkImage * isAImage(SkMatrix *localMatrix, SkTileMode xy[2]) const
SkPDFIndirectReference Make(SkPDFDocument *doc, SkShader *shader, const SkMatrix &matrix, const SkIRect &surfaceBBox)
void PopulateTilingPatternDict(SkPDFDict *pattern, SkRect &bbox, std::unique_ptr< SkPDFDict > resources, const SkMatrix &matrix)
bool ToBitmap(const SkImage *img, SkBitmap *dst)
bool InverseTransformBBox(const SkMatrix &matrix, SkRect *bbox)
unsigned useCenter Optional< SkMatrix > matrix
sk_sp< const SkImage > image
sk_sp< SkBlender > blender SkRect rect
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
SkSamplingOptions(SkFilterMode::kLinear))
constexpr int32_t height() const
constexpr int32_t width() const
void offset(int32_t dx, int32_t dy)
static constexpr SkIRect MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h)
static SkImageInfo MakeN32Premul(int width, int height)
static SkRect Make(const SkISize &size)
SkScalar fBottom
larger y-axis bounds
constexpr float left() const
constexpr float top() const
SkScalar fLeft
smaller x-axis bounds
constexpr float x() const
constexpr float y() const
SkScalar fRight
larger x-axis bounds
void offset(float dx, float dy)
static constexpr SkRect MakeSize(const SkSize &size)
constexpr float height() const
constexpr float right() const
constexpr float width() const
void join(const SkRect &r)
constexpr float bottom() const
SkScalar fTop
smaller y-axis bounds
static constexpr SkSize Make(SkScalar w, SkScalar h)