36 bitmap.eraseColor(0x00000000);
57 float left,
float top,
float right,
float bottom,
60 if (!rect.isEmpty()) {
69 m.setScaleTranslate(sx, sy, tx, ty);
89 SkRect deviceBounds = bBox;
101 deviceBounds.
join(bitmapBounds);
106 auto patternDevice = sk_make_sp<SkPDFDevice>(patternDeviceSize, doc);
115 patternBBox.
offset(-deviceBounds.
left(), -deviceBounds.
top());
153 bitmap, 0, 0, paintColor.fA);
169 if (deviceBounds.
left() < 0) {
181 patternBBox.
fLeft = 0;
201 if (deviceBounds.
left() < 0) {
202 patternBBox.
fLeft = 0;
212 if (deviceBounds.
top() < 0) {
224 patternBBox.
fTop = 0;
244 if (deviceBounds.
top() < 0) {
245 patternBBox.
fTop = 0;
252 auto imageShader = patternDevice->content();
253 std::unique_ptr<SkPDFDict> resourceDict = patternDevice->makeResourceDict();
256 std::move(resourceDict), finalMatrix);
257 return SkPDFStreamOut(std::move(dict), std::move(imageShader), doc);
278 static const int kMaxBitmapArea = 1024 * 1024;
281 if (bitmapArea > (
float)kMaxBitmapArea) {
282 rasterScale *=
SkScalarSqrt((
float)kMaxBitmapArea / bitmapArea);
300 canvas->
translate(-shaderRect.
x(), -shaderRect.
y());
304 shaderTransform.preScale(1 /
scale.width(), 1 /
scale.height());
318 if (img->isAlphaOnly()) {
322 return SkColor4f{0, 0, 0, paintColor.fA};
343 if (
SkImage* skimg = shader->
isAImage(&shaderTransform, imageTileModes)) {
349 {imageTileModes[0], imageTileModes[1]},
#define SkAssertResult(cond)
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)
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
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 SkRGBA4f FromColor(SkColor color)
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)