Skia
2D Graphics Library
SkCanvas.h
Go to the documentation of this file.
1 /*
2  * Copyright 2006 The Android Open Source Project
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #ifndef SkCanvas_DEFINED
9 #define SkCanvas_DEFINED
10 
12 #include "include/core/SkClipOp.h"
13 #include "include/core/SkColor.h"
16 #include "include/core/SkM44.h"
17 #include "include/core/SkMatrix.h"
18 #include "include/core/SkPaint.h"
19 #include "include/core/SkPoint.h"
21 #include "include/core/SkRect.h"
22 #include "include/core/SkRefCnt.h"
24 #include "include/core/SkScalar.h"
25 #include "include/core/SkSize.h"
26 #include "include/core/SkString.h"
28 #include "include/core/SkTypes.h"
29 #include "include/private/SkDeque.h"
30 #include "include/private/SkMacros.h"
31 
32 #include <cstring>
33 #include <memory>
34 #include <vector>
35 
36 // Working on allow this to be undefined
37 #define SK_SUPPORT_LEGACY_GETTOTALMATRIX
38 
39 #define SK_SUPPORT_LEGACY_DRAWBITMAP
40 
41 #define SK_SUPPORT_LEGACY_DRAWIMAGE_NOSAMPLING
42 
44 class GrRecordingContext;
45 class GrSurfaceDrawContext;
46 class SkBaseDevice;
47 class SkBitmap;
48 class SkData;
49 class SkDrawable;
50 struct SkDrawShadowRec;
51 class SkFont;
52 class SkGlyphRunBuilder;
53 class SkImage;
54 class SkImageFilter;
55 class SkMarkerStack;
56 class SkPaintFilterCanvas;
57 class SkPath;
58 class SkPicture;
59 class SkPixmap;
60 class SkRegion;
61 class SkRRect;
62 struct SkRSXform;
63 class SkSurface;
64 class SkSurface_Base;
65 class SkTextBlob;
66 class SkVertices;
67 
91 public:
92 
118  static std::unique_ptr<SkCanvas> MakeRasterDirect(const SkImageInfo& info, void* pixels,
119  size_t rowBytes,
120  const SkSurfaceProps* props = nullptr);
121 
147  static std::unique_ptr<SkCanvas> MakeRasterDirectN32(int width, int height, SkPMColor* pixels,
148  size_t rowBytes) {
149  return MakeRasterDirect(SkImageInfo::MakeN32Premul(width, height), pixels, rowBytes);
150  }
151 
160 
178  SkCanvas(int width, int height, const SkSurfaceProps* props = nullptr);
179 
182  explicit SkCanvas(sk_sp<SkBaseDevice> device);
183 
198  explicit SkCanvas(const SkBitmap& bitmap);
199 
200 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
201 
203  enum class ColorBehavior {
204  kLegacy,
205  };
206 
213  SkCanvas(const SkBitmap& bitmap, ColorBehavior behavior);
214 #endif
215 
230  SkCanvas(const SkBitmap& bitmap, const SkSurfaceProps& props);
231 
237  virtual ~SkCanvas();
238 
247 
256  bool getProps(SkSurfaceProps* props) const;
257 
265  void flush();
266 
275  virtual SkISize getBaseLayerSize() const;
276 
289  sk_sp<SkSurface> makeSurface(const SkImageInfo& info, const SkSurfaceProps* props = nullptr);
290 
298 
303 
320  void* accessTopLayerPixels(SkImageInfo* info, size_t* rowBytes, SkIPoint* origin = nullptr);
321 
334 
350  bool peekPixels(SkPixmap* pixmap);
351 
386  bool readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes,
387  int srcX, int srcY);
388 
424  bool readPixels(const SkPixmap& pixmap, int srcX, int srcY);
425 
461  bool readPixels(const SkBitmap& bitmap, int srcX, int srcY);
462 
499  bool writePixels(const SkImageInfo& info, const void* pixels, size_t rowBytes, int x, int y);
500 
539  bool writePixels(const SkBitmap& bitmap, int x, int y);
540 
557  int save();
558 
581  int saveLayer(const SkRect* bounds, const SkPaint* paint);
582 
602  int saveLayer(const SkRect& bounds, const SkPaint* paint) {
603  return this->saveLayer(&bounds, paint);
604  }
605 
628  int saveLayerAlpha(const SkRect* bounds, U8CPU alpha);
629 
636  kPreserveLCDText_SaveLayerFlag = 1 << 1,
637  kInitWithPrevious_SaveLayerFlag = 1 << 2,
638  kMaskAgainstCoverage_EXPERIMENTAL_DONT_USE_SaveLayerFlag =
639  1 << 3,
640  // instead of matching previous layer's colortype, use F16
641  kF16ColorType = 1 << 4,
642  };
643 
644  typedef uint32_t SaveLayerFlags;
645 
649  struct SaveLayerRec {
650 
656 
664  SaveLayerRec(const SkRect* bounds, const SkPaint* paint, SaveLayerFlags saveLayerFlags = 0)
665  : fBounds(bounds)
666  , fPaint(paint)
667  , fSaveLayerFlags(saveLayerFlags)
668  {}
669 
682  SaveLayerRec(const SkRect* bounds, const SkPaint* paint, const SkImageFilter* backdrop,
683  SaveLayerFlags saveLayerFlags)
684  : fBounds(bounds)
685  , fPaint(paint)
686  , fBackdrop(backdrop)
687  , fSaveLayerFlags(saveLayerFlags)
688  {}
689 
691  const SkRect* fBounds = nullptr;
692 
694  const SkPaint* fPaint = nullptr;
695 
702  const SkImageFilter* fBackdrop = nullptr;
703 
705  SaveLayerFlags fSaveLayerFlags = 0;
706  };
707 
726  int saveLayer(const SaveLayerRec& layerRec);
727 
737  void restore();
738 
747  int getSaveCount() const;
748 
759  void restoreToCount(int saveCount);
760 
775 
789  void scale(SkScalar sx, SkScalar sy);
790 
803  void rotate(SkScalar degrees);
804 
821  void rotate(SkScalar degrees, SkScalar px, SkScalar py);
822 
837  void skew(SkScalar sx, SkScalar sy);
838 
848  void concat(const SkMatrix& matrix);
849  void concat(const SkM44&);
850 
861  void markCTM(const char* name);
862 
863  bool findMarkedCTM(const char* name, SkM44*) const;
864 
872  void setMatrix(const SkM44& matrix);
873 
874  // DEPRECATED -- use SkM44 version
875  void setMatrix(const SkMatrix& matrix);
876 
882  void resetMatrix();
883 
894  void clipRect(const SkRect& rect, SkClipOp op, bool doAntiAlias);
895 
903  void clipRect(const SkRect& rect, SkClipOp op) {
904  this->clipRect(rect, op, false);
905  }
906 
915  void clipRect(const SkRect& rect, bool doAntiAlias = false) {
916  this->clipRect(rect, SkClipOp::kIntersect, doAntiAlias);
917  }
918 
919  void clipIRect(const SkIRect& irect, SkClipOp op = SkClipOp::kIntersect) {
920  this->clipRect(SkRect::Make(irect), op, false);
921  }
922 
936 
948  void clipRRect(const SkRRect& rrect, SkClipOp op, bool doAntiAlias);
949 
957  void clipRRect(const SkRRect& rrect, SkClipOp op) {
958  this->clipRRect(rrect, op, false);
959  }
960 
968  void clipRRect(const SkRRect& rrect, bool doAntiAlias = false) {
969  this->clipRRect(rrect, SkClipOp::kIntersect, doAntiAlias);
970  }
971 
984  void clipPath(const SkPath& path, SkClipOp op, bool doAntiAlias);
985 
997  void clipPath(const SkPath& path, SkClipOp op) {
998  this->clipPath(path, op, false);
999  }
1000 
1011  void clipPath(const SkPath& path, bool doAntiAlias = false) {
1012  this->clipPath(path, SkClipOp::kIntersect, doAntiAlias);
1013  }
1014 
1016 
1026  void clipRegion(const SkRegion& deviceRgn, SkClipOp op = SkClipOp::kIntersect);
1027 
1038  bool quickReject(const SkRect& rect) const;
1039 
1050  bool quickReject(const SkPath& path) const;
1051 
1063 
1073  bool getLocalClipBounds(SkRect* bounds) const {
1074  *bounds = this->getLocalClipBounds();
1075  return !bounds->isEmpty();
1076  }
1077 
1088 
1097  bool getDeviceClipBounds(SkIRect* bounds) const {
1098  *bounds = this->getDeviceClipBounds();
1099  return !bounds->isEmpty();
1100  }
1101 
1111  this->drawColor(SkColor4f::FromColor(color), mode);
1112  }
1113 
1121 
1127  void clear(SkColor color) {
1128  this->clear(SkColor4f::FromColor(color));
1129  }
1130 
1136  void clear(const SkColor4f& color) {
1137  this->drawColor(color, SkBlendMode::kSrc);
1138  }
1139 
1152  void discard() { this->onDiscard(); }
1153 
1162  void drawPaint(const SkPaint& paint);
1163 
1168  enum PointMode {
1172  };
1173 
1205  void drawPoints(PointMode mode, size_t count, const SkPoint pts[], const SkPaint& paint);
1206 
1221  void drawPoint(SkScalar x, SkScalar y, const SkPaint& paint);
1222 
1234  void drawPoint(SkPoint p, const SkPaint& paint) {
1235  this->drawPoint(p.x(), p.y(), paint);
1236  }
1237 
1251  void drawLine(SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1, const SkPaint& paint);
1252 
1262  void drawLine(SkPoint p0, SkPoint p1, const SkPaint& paint) {
1263  this->drawLine(p0.x(), p0.y(), p1.x(), p1.y(), paint);
1264  }
1265 
1276  void drawRect(const SkRect& rect, const SkPaint& paint);
1277 
1286  void drawIRect(const SkIRect& rect, const SkPaint& paint) {
1287  SkRect r;
1288  r.set(rect); // promotes the ints to scalars
1289  this->drawRect(r, paint);
1290  }
1291 
1302  void drawRegion(const SkRegion& region, const SkPaint& paint);
1303 
1313  void drawOval(const SkRect& oval, const SkPaint& paint);
1314 
1327  void drawRRect(const SkRRect& rrect, const SkPaint& paint);
1328 
1348  void drawDRRect(const SkRRect& outer, const SkRRect& inner, const SkPaint& paint);
1349 
1362  void drawCircle(SkScalar cx, SkScalar cy, SkScalar radius, const SkPaint& paint);
1363 
1373  void drawCircle(SkPoint center, SkScalar radius, const SkPaint& paint) {
1374  this->drawCircle(center.x(), center.y(), radius, paint);
1375  }
1376 
1397  void drawArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle,
1398  bool useCenter, const SkPaint& paint);
1399 
1417  void drawRoundRect(const SkRect& rect, SkScalar rx, SkScalar ry, const SkPaint& paint);
1418 
1433  void drawPath(const SkPath& path, const SkPaint& paint);
1434 
1435  void drawImage(const SkImage* image, SkScalar left, SkScalar top) {
1436  this->drawImage(image, left, top, SkSamplingOptions(), nullptr);
1437  }
1438  void drawImage(const sk_sp<SkImage>& image, SkScalar left, SkScalar top) {
1439  this->drawImage(image.get(), left, top, SkSamplingOptions(), nullptr);
1440  }
1441 
1442 #ifdef SK_SUPPORT_LEGACY_DRAWIMAGE_NOSAMPLING
1443 
1455  void drawImage(const SkImage* image, SkScalar left, SkScalar top,
1456  const SkPaint* paint);
1457 
1470  void drawImage(const sk_sp<SkImage>& image, SkScalar left, SkScalar top,
1471  const SkPaint* paint) {
1472  this->drawImage(image.get(), left, top, paint);
1473  }
1474 #endif
1475 
1489  };
1490 
1491 #ifdef SK_SUPPORT_LEGACY_DRAWIMAGE_NOSAMPLING
1492 
1518  void drawImageRect(const SkImage* image, const SkRect& src, const SkRect& dst,
1519  const SkPaint* paint,
1520  SrcRectConstraint constraint = kStrict_SrcRectConstraint);
1521 
1550  void drawImageRect(const SkImage* image, const SkIRect& isrc, const SkRect& dst,
1551  const SkPaint* paint,
1552  SrcRectConstraint constraint = kStrict_SrcRectConstraint);
1553 
1576  void drawImageRect(const SkImage* image, const SkRect& dst, const SkPaint* paint);
1577 
1600  void drawImageRect(const sk_sp<SkImage>& image, const SkRect& src, const SkRect& dst,
1601  const SkPaint* paint,
1602  SrcRectConstraint constraint = kStrict_SrcRectConstraint) {
1603  this->drawImageRect(image.get(), src, dst, paint, constraint);
1604  }
1605 
1633  void drawImageRect(const sk_sp<SkImage>& image, const SkIRect& isrc, const SkRect& dst,
1634  const SkPaint* paint,
1635  SrcRectConstraint constraint = kStrict_SrcRectConstraint) {
1636  this->drawImageRect(image.get(), isrc, dst, paint, constraint);
1637  }
1638 
1659  void drawImageRect(const sk_sp<SkImage>& image, const SkRect& dst, const SkPaint* paint) {
1660  this->drawImageRect(image.get(), dst, paint);
1661  }
1662 #endif
1663 
1665  const SkPaint* = nullptr);
1666  void drawImage(const sk_sp<SkImage>& image, SkScalar x, SkScalar y,
1667  const SkSamplingOptions& sampling, const SkPaint* paint = nullptr) {
1668  this->drawImage(image.get(), x, y, sampling, paint);
1669  }
1670  void drawImageRect(const SkImage*, const SkRect& src, const SkRect& dst,
1671  const SkSamplingOptions&, const SkPaint*, SrcRectConstraint);
1672  void drawImageRect(const SkImage*, const SkRect& dst, const SkSamplingOptions&,
1673  const SkPaint* = nullptr);
1674  void drawImageRect(const sk_sp<SkImage>& image, const SkRect& src, const SkRect& dst,
1675  const SkSamplingOptions& sampling, const SkPaint* paint,
1676  SrcRectConstraint constraint) {
1677  this->drawImageRect(image.get(), src, dst, sampling, paint, constraint);
1678  }
1679  void drawImageRect(const sk_sp<SkImage>& image, const SkRect& dst,
1680  const SkSamplingOptions& sampling, const SkPaint* paint = nullptr) {
1681  this->drawImageRect(image.get(), dst, sampling, paint);
1682  }
1683 
1707  void drawImageNine(const SkImage* image, const SkIRect& center, const SkRect& dst,
1708  SkFilterMode filter, const SkPaint* paint = nullptr);
1709 
1710 #ifdef SK_SUPPORT_LEGACY_PAINT_QUALITY_APIS
1711  void drawImageNine(const SkImage* image, const SkIRect& center, const SkRect& dst,
1712  const SkPaint* paint = nullptr);
1713 
1714  void drawImageNine(const sk_sp<SkImage>& image, const SkIRect& center, const SkRect& dst,
1715  const SkPaint* paint = nullptr) {
1716  this->drawImageNine(image.get(), center, dst, paint);
1717  }
1718 #endif
1719 
1720 #ifdef SK_SUPPORT_LEGACY_DRAWBITMAP
1721 public:
1722 #else
1723 private:
1724 #endif
1725 
1743  void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
1744  const SkPaint* paint = nullptr);
1745 
1769  void drawBitmapRect(const SkBitmap& bitmap, const SkRect& src, const SkRect& dst,
1770  const SkPaint* paint,
1771  SrcRectConstraint constraint = kStrict_SrcRectConstraint);
1772 
1797  void drawBitmapRect(const SkBitmap& bitmap, const SkIRect& isrc, const SkRect& dst,
1798  const SkPaint* paint,
1799  SrcRectConstraint constraint = kStrict_SrcRectConstraint);
1800 
1824  void drawBitmapRect(const SkBitmap& bitmap, const SkRect& dst, const SkPaint* paint,
1825  SrcRectConstraint constraint = kStrict_SrcRectConstraint);
1826 public:
1827 
1837  struct Lattice {
1838 
1843  enum RectType : uint8_t {
1844  kDefault = 0,
1847  };
1848 
1849  const int* fXDivs;
1850  const int* fYDivs;
1852  int fXCount;
1853  int fYCount;
1854  const SkIRect* fBounds;
1855  const SkColor* fColors;
1856  };
1857 
1885  void drawImageLattice(const SkImage* image, const Lattice& lattice, const SkRect& dst,
1886  SkFilterMode filter, const SkPaint* paint = nullptr);
1887  void drawImageLattice(const SkImage* image, const Lattice& lattice, const SkRect& dst) {
1888  this->drawImageLattice(image, lattice, dst, SkFilterMode::kNearest, nullptr);
1889  }
1890 
1891 #ifdef SK_SUPPORT_LEGACY_PAINT_QUALITY_APIS
1892  void drawImageLattice(const SkImage*, const Lattice&, const SkRect& dst, const SkPaint*);
1893 #endif
1894 
1898  enum QuadAAFlags : unsigned {
1899  kLeft_QuadAAFlag = 0b0001,
1900  kTop_QuadAAFlag = 0b0010,
1901  kRight_QuadAAFlag = 0b0100,
1902  kBottom_QuadAAFlag = 0b1000,
1903 
1904  kNone_QuadAAFlags = 0b0000,
1905  kAll_QuadAAFlags = 0b1111,
1906  };
1907 
1910  ImageSetEntry(sk_sp<const SkImage> image, const SkRect& srcRect, const SkRect& dstRect,
1911  int matrixIndex, float alpha, unsigned aaFlags, bool hasClip);
1912 
1913  ImageSetEntry(sk_sp<const SkImage> image, const SkRect& srcRect, const SkRect& dstRect,
1914  float alpha, unsigned aaFlags);
1915 
1920 
1924  int fMatrixIndex = -1; // Index into the preViewMatrices arg, or < 0
1925  float fAlpha = 1.f;
1926  unsigned fAAFlags = kNone_QuadAAFlags; // QuadAAFlags
1927  bool fHasClip = false; // True to use next 4 points in dstClip arg as quad
1928  };
1929 
1949  void experimental_DrawEdgeAAQuad(const SkRect& rect, const SkPoint clip[4], QuadAAFlags aaFlags,
1950  const SkColor4f& color, SkBlendMode mode);
1951  void experimental_DrawEdgeAAQuad(const SkRect& rect, const SkPoint clip[4], QuadAAFlags aaFlags,
1952  SkColor color, SkBlendMode mode) {
1953  this->experimental_DrawEdgeAAQuad(rect, clip, aaFlags, SkColor4f::FromColor(color), mode);
1954  }
1955 
1984  void experimental_DrawEdgeAAImageSet(const ImageSetEntry imageSet[], int cnt,
1985  const SkPoint dstClips[], const SkMatrix preViewMatrices[],
1986  const SkSamplingOptions&, const SkPaint* paint = nullptr,
1987  SrcRectConstraint constraint = kStrict_SrcRectConstraint);
1988 
1989 #ifdef SK_SUPPORT_LEGACY_PAINT_QUALITY_APIS
1990  void experimental_DrawEdgeAAImageSet(const ImageSetEntry imageSet[], int cnt,
1991  const SkPoint dstClips[], const SkMatrix preViewMatrices[],
1992  const SkPaint* paint = nullptr,
1993  SrcRectConstraint constraint = kStrict_SrcRectConstraint);
1994 #endif
1995 
2023  void drawSimpleText(const void* text, size_t byteLength, SkTextEncoding encoding,
2024  SkScalar x, SkScalar y, const SkFont& font, const SkPaint& paint);
2025 
2050  void drawString(const char str[], SkScalar x, SkScalar y, const SkFont& font,
2051  const SkPaint& paint) {
2052  this->drawSimpleText(str, strlen(str), SkTextEncoding::kUTF8, x, y, font, paint);
2053  }
2054 
2079  void drawString(const SkString& str, SkScalar x, SkScalar y, const SkFont& font,
2080  const SkPaint& paint) {
2081  this->drawSimpleText(str.c_str(), str.size(), SkTextEncoding::kUTF8, x, y, font, paint);
2082  }
2083 
2107  void drawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, const SkPaint& paint);
2108 
2127  void drawTextBlob(const sk_sp<SkTextBlob>& blob, SkScalar x, SkScalar y, const SkPaint& paint) {
2128  this->drawTextBlob(blob.get(), x, y, paint);
2129  }
2130 
2139  void drawPicture(const SkPicture* picture) {
2140  this->drawPicture(picture, nullptr, nullptr);
2141  }
2142 
2151  void drawPicture(const sk_sp<SkPicture>& picture) {
2152  this->drawPicture(picture.get());
2153  }
2154 
2169  void drawPicture(const SkPicture* picture, const SkMatrix* matrix, const SkPaint* paint);
2170 
2183  void drawPicture(const sk_sp<SkPicture>& picture, const SkMatrix* matrix,
2184  const SkPaint* paint) {
2185  this->drawPicture(picture.get(), matrix, paint);
2186  }
2187 
2201  void drawVertices(const SkVertices* vertices, SkBlendMode mode, const SkPaint& paint);
2202 
2206  void drawVertices(const SkVertices* vertices, const SkPaint& paint) {
2207  this->drawVertices(vertices, SkBlendMode::kModulate, paint);
2208  }
2209 
2223  void drawVertices(const sk_sp<SkVertices>& vertices, SkBlendMode mode, const SkPaint& paint);
2224 
2228  void drawVertices(const sk_sp<SkVertices>& vertices, const SkPaint& paint) {
2229  this->drawVertices(vertices, SkBlendMode::kModulate, paint);
2230  }
2231 
2258  void drawPatch(const SkPoint cubics[12], const SkColor colors[4],
2259  const SkPoint texCoords[4], SkBlendMode mode, const SkPaint& paint);
2260 
2286  void drawPatch(const SkPoint cubics[12], const SkColor colors[4],
2287  const SkPoint texCoords[4], const SkPaint& paint) {
2288  this->drawPatch(cubics, colors, texCoords, SkBlendMode::kModulate, paint);
2289  }
2290 
2314  void drawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect tex[],
2315  const SkColor colors[], int count, SkBlendMode mode,
2316  const SkSamplingOptions& sampling, const SkRect* cullRect, const SkPaint* paint);
2317 
2318 #ifdef SK_SUPPORT_LEGACY_PAINT_QUALITY_APIS
2319  void drawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect tex[],
2320  const SkColor colors[], int count, SkBlendMode mode, const SkRect* cullRect,
2321  const SkPaint* paint);
2322 
2323  void drawAtlas(const sk_sp<SkImage>& atlas, const SkRSXform xform[], const SkRect tex[],
2324  const SkColor colors[], int count, SkBlendMode mode, const SkRect* cullRect,
2325  const SkPaint* paint) {
2326  this->drawAtlas(atlas.get(), xform, tex, colors, count, mode, cullRect, paint);
2327  }
2328 
2329  void drawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect tex[], int count,
2330  const SkRect* cullRect, const SkPaint* paint) {
2331  this->drawAtlas(atlas, xform, tex, nullptr, count, SkBlendMode::kDst, cullRect, paint);
2332  }
2333 
2334  void drawAtlas(const sk_sp<SkImage>& atlas, const SkRSXform xform[], const SkRect tex[],
2335  int count, const SkRect* cullRect, const SkPaint* paint) {
2336  this->drawAtlas(atlas.get(), xform, tex, nullptr, count, SkBlendMode::kDst,
2337  cullRect, paint);
2338  }
2339 #endif
2340 
2354  void drawDrawable(SkDrawable* drawable, const SkMatrix* matrix = nullptr);
2355 
2369  void drawDrawable(SkDrawable* drawable, SkScalar x, SkScalar y);
2370 
2383  void drawAnnotation(const SkRect& rect, const char key[], SkData* value);
2384 
2395  void drawAnnotation(const SkRect& rect, const char key[], const sk_sp<SkData>& value) {
2396  this->drawAnnotation(rect, key, value.get());
2397  }
2398 
2409  virtual bool isClipEmpty() const;
2410 
2418  virtual bool isClipRect() const;
2419 
2426 
2431  return this->getLocalToDevice().asM33();
2432  }
2433 
2434 #ifdef SK_SUPPORT_LEGACY_GETTOTALMATRIX
2435 
2445 #endif
2446 
2448 
2449 #if defined(SK_BUILD_FOR_ANDROID_FRAMEWORK) && SK_SUPPORT_GPU
2450  // These methods exist to support WebView in Android Framework.
2451  SkIRect topLayerBounds() const;
2452  GrBackendRenderTarget topLayerBackendRenderTarget() const;
2453 #endif
2454 
2460 
2461  void private_draw_shadow_rec(const SkPath&, const SkDrawShadowRec&);
2462 
2463 
2464 protected:
2465  // default impl defers to getDevice()->newSurface(info)
2466  virtual sk_sp<SkSurface> onNewSurface(const SkImageInfo& info, const SkSurfaceProps& props);
2467 
2468  // default impl defers to its device
2469  virtual bool onPeekPixels(SkPixmap* pixmap);
2470  virtual bool onAccessTopLayerPixels(SkPixmap* pixmap);
2471  virtual SkImageInfo onImageInfo() const;
2472  virtual bool onGetProps(SkSurfaceProps* props) const;
2473  virtual void onFlush();
2474 
2475  // Subclass save/restore notifiers.
2476  // Overriders should call the corresponding INHERITED method up the inheritance chain.
2477  // getSaveLayerStrategy()'s return value may suppress full layer allocation.
2481  };
2482 
2483  virtual void willSave() {}
2484  // Overriders should call the corresponding INHERITED method up the inheritance chain.
2486  return kFullLayer_SaveLayerStrategy;
2487  }
2488 
2489  // returns true if we should actually perform the saveBehind, or false if we should just save.
2490  virtual bool onDoSaveBehind(const SkRect*) { return true; }
2491  virtual void willRestore() {}
2492  virtual void didRestore() {}
2493 
2494  virtual void onMarkCTM(const char*) {}
2495  virtual void didConcat44(const SkM44&) {}
2496  virtual void didSetM44(const SkM44&) {}
2497  virtual void didTranslate(SkScalar, SkScalar) {}
2498  virtual void didScale(SkScalar, SkScalar) {}
2499 
2500  // NOTE: If you are adding a new onDraw virtual to SkCanvas, PLEASE add an override to
2501  // SkCanvasVirtualEnforcer (in SkCanvasVirtualEnforcer.h). This ensures that subclasses using
2502  // that mechanism will be required to implement the new function.
2503  virtual void onDrawPaint(const SkPaint& paint);
2504  virtual void onDrawBehind(const SkPaint& paint);
2505  virtual void onDrawRect(const SkRect& rect, const SkPaint& paint);
2506  virtual void onDrawRRect(const SkRRect& rrect, const SkPaint& paint);
2507  virtual void onDrawDRRect(const SkRRect& outer, const SkRRect& inner, const SkPaint& paint);
2508  virtual void onDrawOval(const SkRect& rect, const SkPaint& paint);
2509  virtual void onDrawArc(const SkRect& rect, SkScalar startAngle, SkScalar sweepAngle,
2510  bool useCenter, const SkPaint& paint);
2511  virtual void onDrawPath(const SkPath& path, const SkPaint& paint);
2512  virtual void onDrawRegion(const SkRegion& region, const SkPaint& paint);
2513 
2514  virtual void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
2515  const SkPaint& paint);
2516 
2517  virtual void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
2518  const SkPoint texCoords[4], SkBlendMode mode, const SkPaint& paint);
2519  virtual void onDrawPoints(PointMode mode, size_t count, const SkPoint pts[],
2520  const SkPaint& paint);
2521 
2522  virtual void onDrawImage2(const SkImage*, SkScalar dx, SkScalar dy, const SkSamplingOptions&,
2523  const SkPaint*);
2524  virtual void onDrawImageRect2(const SkImage*, const SkRect& src, const SkRect& dst,
2525  const SkSamplingOptions&, const SkPaint*, SrcRectConstraint);
2526  virtual void onDrawImageLattice2(const SkImage*, const Lattice&, const SkRect& dst,
2527  SkFilterMode, const SkPaint*);
2528  virtual void onDrawAtlas2(const SkImage*, const SkRSXform[], const SkRect src[],
2529  const SkColor[], int count, SkBlendMode, const SkSamplingOptions&,
2530  const SkRect* cull, const SkPaint*);
2531  virtual void onDrawEdgeAAImageSet2(const ImageSetEntry imageSet[], int count,
2532  const SkPoint dstClips[], const SkMatrix preViewMatrices[],
2533  const SkSamplingOptions&, const SkPaint*,
2535 
2536  virtual void onDrawVerticesObject(const SkVertices* vertices, SkBlendMode mode,
2537  const SkPaint& paint);
2538 
2539  virtual void onDrawAnnotation(const SkRect& rect, const char key[], SkData* value);
2540  virtual void onDrawShadowRec(const SkPath&, const SkDrawShadowRec&);
2541 
2542  virtual void onDrawDrawable(SkDrawable* drawable, const SkMatrix* matrix);
2543  virtual void onDrawPicture(const SkPicture* picture, const SkMatrix* matrix,
2544  const SkPaint* paint);
2545 
2546  virtual void onDrawEdgeAAQuad(const SkRect& rect, const SkPoint clip[4], QuadAAFlags aaFlags,
2547  const SkColor4f& color, SkBlendMode mode);
2548 
2551  kSoft_ClipEdgeStyle
2552  };
2553 
2554  virtual void onClipRect(const SkRect& rect, SkClipOp op, ClipEdgeStyle edgeStyle);
2555  virtual void onClipRRect(const SkRRect& rrect, SkClipOp op, ClipEdgeStyle edgeStyle);
2556  virtual void onClipPath(const SkPath& path, SkClipOp op, ClipEdgeStyle edgeStyle);
2558  virtual void onClipRegion(const SkRegion& deviceRgn, SkClipOp op);
2559 
2560  virtual void onDiscard();
2561 
2562  // Clip rectangle bounds. Called internally by saveLayer.
2563  // returns false if the entire rectangle is entirely clipped out
2564  // If non-NULL, The imageFilter parameter will be used to expand the clip
2565  // and offscreen bounds for any margin required by the filter DAG.
2566  bool clipRectBounds(const SkRect* bounds, SkIRect* intersection,
2567  const SkImageFilter* imageFilter = nullptr);
2568 
2569 private:
2570  static void DrawDeviceWithFilter(SkBaseDevice* src, const SkImageFilter* filter,
2571  SkBaseDevice* dst, const SkIPoint& dstOrigin,
2572  const SkMatrix& ctm);
2573 
2574  enum ShaderOverrideOpacity {
2575  kNone_ShaderOverrideOpacity,
2576  kOpaque_ShaderOverrideOpacity,
2577  kNotOpaque_ShaderOverrideOpacity,
2578  };
2579 
2580  // notify our surface (if we have one) that we are about to draw, so it
2581  // can perform copy-on-write or invalidate any cached images
2582  void predrawNotify(bool willOverwritesEntireSurface = false);
2583  void predrawNotify(const SkRect* rect, const SkPaint* paint, ShaderOverrideOpacity);
2584 
2585  // The bottom-most device in the stack, only changed by init(). Image properties and the final
2586  // canvas pixels are determined by this device.
2587  SkBaseDevice* baseDevice() const {
2588  SkASSERT(fBaseDevice);
2589  return fBaseDevice.get();
2590  }
2591 
2592  // The top-most device in the stack, will change within saveLayer()'s. All drawing and clipping
2593  // operations should route to this device.
2594  SkBaseDevice* topDevice() const;
2595  virtual GrSurfaceDrawContext* topDeviceSurfaceDrawContext();
2596 
2597  class MCRec;
2598 
2599  SkDeque fMCStack;
2600  // points to top of stack
2601  MCRec* fMCRec;
2602 
2603  sk_sp<SkMarkerStack> fMarkerStack;
2604 
2605  // the first N recs that can fit here mean we won't call malloc
2606  static constexpr int kMCRecSize = 96; // most recent measurement
2607  static constexpr int kMCRecCount = 32; // common depth for save/restores
2608 
2609  intptr_t fMCRecStorage[kMCRecSize * kMCRecCount / sizeof(intptr_t)];
2610 
2611  // Installed via init()
2612  sk_sp<SkBaseDevice> fBaseDevice;
2613  const SkSurfaceProps fProps;
2614 
2615  int fSaveCount; // value returned by getSaveCount()
2616 
2617  std::unique_ptr<SkRasterHandleAllocator> fAllocator;
2618 
2619  SkSurface_Base* fSurfaceBase;
2620  SkSurface_Base* getSurfaceBase() const { return fSurfaceBase; }
2621  void setSurfaceBase(SkSurface_Base* sb) {
2622  fSurfaceBase = sb;
2623  }
2624  friend class SkSurface_Base;
2625  friend class SkSurface_Gpu;
2626 
2627  SkIRect fClipRestrictionRect = SkIRect::MakeEmpty();
2628 
2629  void doSave();
2630  void checkForDeferredSave();
2631  void internalSetMatrix(const SkM44&);
2632 
2633  friend class SkAndroidFrameworkUtils;
2634  friend class SkCanvasPriv; // needs to expose android functions for testing outside android
2635  friend class AutoLayerForImageFilter;
2636  friend class SkSurface_Raster; // needs getDevice()
2637  friend class SkNoDrawCanvas; // needs resetForNextPicture()
2638  friend class SkPictureRecord; // predrawNotify (why does it need it? <reed>)
2639  friend class SkOverdrawCanvas;
2641 protected:
2642  // For use by SkNoDrawCanvas (via SkCanvasVirtualEnforcer, which can't be a friend)
2643  SkCanvas(const SkIRect& bounds);
2644 private:
2645  SkCanvas(const SkBitmap&, std::unique_ptr<SkRasterHandleAllocator>,
2647 
2648  SkCanvas(SkCanvas&&) = delete;
2649  SkCanvas(const SkCanvas&) = delete;
2650  SkCanvas& operator=(SkCanvas&&) = delete;
2651  SkCanvas& operator=(const SkCanvas&) = delete;
2652 
2661  int only_axis_aligned_saveBehind(const SkRect* subset);
2662 
2667  void drawClippedToSaveBehind(const SkPaint&);
2668 
2669  void resetForNextPicture(const SkIRect& bounds);
2670 
2671  // needs gettotalclip()
2672  friend class SkCanvasStateUtils;
2673 
2674  void init(sk_sp<SkBaseDevice>);
2675 
2676  // All base onDrawX() functions should call this and skip drawing if it returns true.
2677  // If 'matrix' is non-null, it maps the paint's fast bounds before checking for quick rejection
2678  bool internalQuickReject(const SkRect& bounds, const SkPaint& paint,
2679  const SkMatrix* matrix = nullptr);
2680 
2681  void internalDrawPaint(const SkPaint& paint);
2682  void internalSaveLayer(const SaveLayerRec&, SaveLayerStrategy);
2683  void internalSaveBehind(const SkRect*);
2684  void internalDrawDevice(SkBaseDevice*, const SkSamplingOptions&, const SkPaint*);
2685 
2686  void internalConcat44(const SkM44&);
2687 
2688  // shared by save() and saveLayer()
2689  void internalSave();
2690  void internalRestore();
2691 
2692  /*
2693  * Returns true if drawing the specified rect (or all if it is null) with the specified
2694  * paint (or default if null) would overwrite the entire root device of the canvas
2695  * (i.e. the canvas' surface if it had one).
2696  */
2697  bool wouldOverwriteEntireSurface(const SkRect*, const SkPaint*, ShaderOverrideOpacity) const;
2698 
2702  bool canDrawBitmapAsSprite(SkScalar x, SkScalar y, int w, int h, const SkSamplingOptions&,
2703  const SkPaint&);
2704 
2709  bool androidFramework_isClipAA() const;
2710 
2716  void androidFramework_replaceClip(const SkIRect& rect);
2717 
2718  virtual SkPaintFilterCanvas* internal_private_asPaintFilterCanvas() const { return nullptr; }
2719 
2724  bool fIsScaleTranslate;
2725  SkRect fQuickRejectBounds;
2726 
2727  // Compute the clip's bounds based on all clipped SkDevice's reported device bounds transformed
2728  // into the canvas' global space.
2729  SkRect computeDeviceClipBounds() const;
2730 
2731  class AutoUpdateQRBounds;
2732  void validateClip() const;
2733 
2734  std::unique_ptr<SkGlyphRunBuilder> fScratchGlyphRunBuilder;
2735 
2736  using INHERITED = SkRefCnt;
2737 };
2738 
2745 public:
2746 
2753  SkAutoCanvasRestore(SkCanvas* canvas, bool doSave) : fCanvas(canvas), fSaveCount(0) {
2754  if (fCanvas) {
2755  fSaveCount = canvas->getSaveCount();
2756  if (doSave) {
2757  canvas->save();
2758  }
2759  }
2760  }
2761 
2766  if (fCanvas) {
2767  fCanvas->restoreToCount(fSaveCount);
2768  }
2769  }
2770 
2774  void restore() {
2775  if (fCanvas) {
2776  fCanvas->restoreToCount(fSaveCount);
2777  fCanvas = nullptr;
2778  }
2779  }
2780 
2781 private:
2782  SkCanvas* fCanvas;
2783  int fSaveCount;
2784 
2786  SkAutoCanvasRestore(const SkAutoCanvasRestore&) = delete;
2787  SkAutoCanvasRestore& operator=(SkAutoCanvasRestore&&) = delete;
2788  SkAutoCanvasRestore& operator=(const SkAutoCanvasRestore&) = delete;
2789 };
2790 
2791 #endif
GrRecordingContext
Definition: GrRecordingContext.h:34
SkCanvas::ImageSetEntry::~ImageSetEntry
~ImageSetEntry()
SkCanvas::drawDrawable
void drawDrawable(SkDrawable *drawable, SkScalar x, SkScalar y)
Draws SkDrawable drawable using clip and SkMatrix, offset by (x, y).
SkCanvas::drawSimpleText
void drawSimpleText(const void *text, size_t byteLength, SkTextEncoding encoding, SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
Draws text, with origin at (x, y), using clip, SkMatrix, SkFont font, and SkPaint paint.
SkCanvas::drawBitmapRect
void drawBitmapRect(const SkBitmap &bitmap, const SkRect &dst, const SkPaint *paint, SrcRectConstraint constraint=kStrict_SrcRectConstraint)
Draws SkBitmap bitmap, scaled and translated to fill SkRect dst.
SkCanvas::clipPath
void clipPath(const SkPath &path, bool doAntiAlias=false)
Replaces clip with the intersection of clip and path.
Definition: SkCanvas.h:1011
SkCanvas::ImageSetEntry::ImageSetEntry
ImageSetEntry(sk_sp< const SkImage > image, const SkRect &srcRect, const SkRect &dstRect, float alpha, unsigned aaFlags)
SkTextBlob
Definition: SkTextBlob.h:28
SkCanvas::drawIRect
void drawIRect(const SkIRect &rect, const SkPaint &paint)
Draws SkIRect rect using clip, SkMatrix, and SkPaint paint.
Definition: SkCanvas.h:1286
SkCanvas::drawAnnotation
void drawAnnotation(const SkRect &rect, const char key[], const sk_sp< SkData > &value)
Associates SkRect on SkCanvas when an annotation; a key-value pair, where the key is a null-terminate...
Definition: SkCanvas.h:2395
SkAutoCanvasRestore::~SkAutoCanvasRestore
~SkAutoCanvasRestore()
Restores SkCanvas to saved state.
Definition: SkCanvas.h:2765
SkImage
Definition: SkImage.h:58
SkCanvas::accessTopLayerPixels
void * accessTopLayerPixels(SkImageInfo *info, size_t *rowBytes, SkIPoint *origin=nullptr)
Returns the pixel base address, SkImageInfo, rowBytes, and origin if the pixels can be read directly.
SkSize.h
SkCanvas::drawOval
void drawOval(const SkRect &oval, const SkPaint &paint)
Draws oval oval using clip, SkMatrix, and SkPaint.
SkCanvas::willSave
virtual void willSave()
Definition: SkCanvas.h:2483
SkCanvas::onDrawPoints
virtual void onDrawPoints(PointMode mode, size_t count, const SkPoint pts[], const SkPaint &paint)
SkCanvas::drawRect
void drawRect(const SkRect &rect, const SkPaint &paint)
Draws SkRect rect using clip, SkMatrix, and SkPaint paint.
SkCanvas::drawImage
void drawImage(const sk_sp< SkImage > &image, SkScalar x, SkScalar y, const SkSamplingOptions &sampling, const SkPaint *paint=nullptr)
Definition: SkCanvas.h:1666
SkCanvas::drawArc
void drawArc(const SkRect &oval, SkScalar startAngle, SkScalar sweepAngle, bool useCenter, const SkPaint &paint)
Draws arc using clip, SkMatrix, and SkPaint paint.
SkCanvas::ImageSetEntry::fImage
sk_sp< const SkImage > fImage
Definition: SkCanvas.h:1921
SkCanvas::onFlush
virtual void onFlush()
SkPath
Definition: SkPath.h:44
SkRefCnt
Definition: SkRefCnt.h:118
SkCanvas::clipRectBounds
bool clipRectBounds(const SkRect *bounds, SkIRect *intersection, const SkImageFilter *imageFilter=nullptr)
SkCanvas::save
int save()
Saves SkMatrix and clip.
SkM44.h
SkCanvas::drawRoundRect
void drawRoundRect(const SkRect &rect, SkScalar rx, SkScalar ry, const SkPaint &paint)
Draws SkRRect bounded by SkRect rect, with corner radii (rx, ry) using clip, SkMatrix,...
SkCanvas::drawImageNine
void drawImageNine(const SkImage *image, const SkIRect &center, const SkRect &dst, SkFilterMode filter, const SkPaint *paint=nullptr)
Draws SkImage image stretched proportionally to fit into SkRect dst.
SkRasterHandleAllocator::Handle
void * Handle
Definition: SkRasterHandleAllocator.h:41
SkCanvas::onDrawImage2
virtual void onDrawImage2(const SkImage *, SkScalar dx, SkScalar dy, const SkSamplingOptions &, const SkPaint *)
SkCanvas::getLocalClipBounds
SkRect getLocalClipBounds() const
Returns bounds of clip, transformed by inverse of SkMatrix.
SkCanvas::drawImageRect
void drawImageRect(const SkImage *, const SkRect &src, const SkRect &dst, const SkSamplingOptions &, const SkPaint *, SrcRectConstraint)
SkCanvas::drawDrawable
void drawDrawable(SkDrawable *drawable, const SkMatrix *matrix=nullptr)
Draws SkDrawable drawable using clip and SkMatrix, concatenated with optional matrix.
SkCanvas::experimental_DrawEdgeAAQuad
void experimental_DrawEdgeAAQuad(const SkRect &rect, const SkPoint clip[4], QuadAAFlags aaFlags, SkColor color, SkBlendMode mode)
Definition: SkCanvas.h:1951
SkCanvas::drawString
void drawString(const SkString &str, SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
Draws SkString, with origin at (x, y), using clip, SkMatrix, SkFont font, and SkPaint paint.
Definition: SkCanvas.h:2079
SkCanvas::discard
void discard()
Makes SkCanvas contents undefined.
Definition: SkCanvas.h:1152
SkCanvas::drawCircle
void drawCircle(SkScalar cx, SkScalar cy, SkScalar radius, const SkPaint &paint)
Draws circle at (cx, cy) with radius using clip, SkMatrix, and SkPaint paint.
SkCanvas::drawColor
void drawColor(const SkColor4f &color, SkBlendMode mode=SkBlendMode::kSrcOver)
Fills clip with color color.
SkCanvas::ImageSetEntry::fSrcRect
SkRect fSrcRect
Definition: SkCanvas.h:1922
SkSurface
Definition: SkSurface.h:46
SkCanvas::drawBitmapRect
void drawBitmapRect(const SkBitmap &bitmap, const SkRect &src, const SkRect &dst, const SkPaint *paint, SrcRectConstraint constraint=kStrict_SrcRectConstraint)
Draws SkRect src of SkBitmap bitmap, scaled and translated to fill SkRect dst.
SkCanvas::writePixels
bool writePixels(const SkImageInfo &info, const void *pixels, size_t rowBytes, int x, int y)
Copies SkRect from pixels to SkCanvas.
SkTypes.h
SkCanvas::SkCanvas
SkCanvas()
Creates an empty SkCanvas with no backing device or pixels, with a width and height of zero.
SkRSXform
A compressed form of a rotation+scale matrix.
Definition: SkRSXform.h:21
SkM44
4x4 matrix used by SkCanvas and other parts of Skia.
Definition: SkM44.h:133
SkCanvas::saveLayer
int saveLayer(const SaveLayerRec &layerRec)
Saves SkMatrix and clip, and allocates SkBitmap for subsequent drawing.
SkCanvas::scale
void scale(SkScalar sx, SkScalar sy)
Scales SkMatrix by sx on the x-axis and sy on the y-axis.
SkCanvas::saveLayer
int saveLayer(const SkRect &bounds, const SkPaint *paint)
Saves SkMatrix and clip, and allocates a SkBitmap for subsequent drawing.
Definition: SkCanvas.h:602
SkBlendMode::kDst
@ kDst
preserves destination
SkCanvas::onDrawRect
virtual void onDrawRect(const SkRect &rect, const SkPaint &paint)
SkColor4f
SkCanvas::willRestore
virtual void willRestore()
Definition: SkCanvas.h:2491
SkCanvas::concat
void concat(const SkM44 &)
SkCanvas::onNewSurface
virtual sk_sp< SkSurface > onNewSurface(const SkImageInfo &info, const SkSurfaceProps &props)
SkCanvas::onDrawPath
virtual void onDrawPath(const SkPath &path, const SkPaint &paint)
SkClipOp::kIntersect
@ kIntersect
SkCanvas::ImageSetEntry::ImageSetEntry
ImageSetEntry(const ImageSetEntry &)
SkCanvas::markCTM
void markCTM(const char *name)
Record a marker (provided by caller) for the current CTM.
SkCanvas::experimental_DrawEdgeAAImageSet
void experimental_DrawEdgeAAImageSet(const ImageSetEntry imageSet[], int cnt, const SkPoint dstClips[], const SkMatrix preViewMatrices[], const SkSamplingOptions &, const SkPaint *paint=nullptr, SrcRectConstraint constraint=kStrict_SrcRectConstraint)
This is an bulk variant of experimental_DrawEdgeAAQuad() that renders 'cnt' textured quads.
SkRect.h
SkCanvas::ImageSetEntry::ImageSetEntry
ImageSetEntry(sk_sp< const SkImage > image, const SkRect &srcRect, const SkRect &dstRect, int matrixIndex, float alpha, unsigned aaFlags, bool hasClip)
SkCanvas::drawAtlas
void drawAtlas(const SkImage *atlas, const SkRSXform xform[], const SkRect tex[], const SkColor colors[], int count, SkBlendMode mode, const SkSamplingOptions &sampling, const SkRect *cullRect, const SkPaint *paint)
Draws a set of sprites from atlas, using clip, SkMatrix, and optional SkPaint paint.
SkBlendMode
SkBlendMode
Definition: SkBlendMode.h:13
SkCanvas::drawPoints
void drawPoints(PointMode mode, size_t count, const SkPoint pts[], const SkPaint &paint)
Draws pts using clip, SkMatrix and SkPaint paint.
SkCanvas::SrcRectConstraint
SrcRectConstraint
Definition: SkCanvas.h:1486
SkCanvas::findMarkedCTM
bool findMarkedCTM(const char *name, SkM44 *) const
SkCanvas::onDrawRRect
virtual void onDrawRRect(const SkRRect &rrect, const SkPaint &paint)
SkCanvas::drawImageRect
void drawImageRect(const sk_sp< SkImage > &image, const SkRect &src, const SkRect &dst, const SkPaint *paint, SrcRectConstraint constraint=kStrict_SrcRectConstraint)
Draws SkRect src of SkImage image, scaled and translated to fill SkRect dst.
Definition: SkCanvas.h:1600
SkCanvas::saveLayerAlpha
int saveLayerAlpha(const SkRect *bounds, U8CPU alpha)
Saves SkMatrix and clip, and allocates SkBitmap for subsequent drawing.
SkCanvas::onDrawEdgeAAImageSet2
virtual void onDrawEdgeAAImageSet2(const ImageSetEntry imageSet[], int count, const SkPoint dstClips[], const SkMatrix preViewMatrices[], const SkSamplingOptions &, const SkPaint *, SrcRectConstraint)
SkCanvas::drawImageLattice
void drawImageLattice(const SkImage *image, const Lattice &lattice, const SkRect &dst)
Definition: SkCanvas.h:1887
SkCanvas::MakeRasterDirect
static std::unique_ptr< SkCanvas > MakeRasterDirect(const SkImageInfo &info, void *pixels, size_t rowBytes, const SkSurfaceProps *props=nullptr)
Allocates raster SkCanvas that will draw directly into pixels.
SkCanvas::concat
void concat(const SkMatrix &matrix)
Replaces SkMatrix with matrix premultiplied with existing SkMatrix.
SkAutoCanvasRestore::SkAutoCanvasRestore
SkAutoCanvasRestore(SkCanvas *canvas, bool doSave)
Preserves SkCanvas::save() count.
Definition: SkCanvas.h:2753
SkRasterHandleAllocator
If a client wants to control the allocation of raster layers in a canvas, it should subclass SkRaster...
Definition: SkRasterHandleAllocator.h:36
SkCanvas::onDrawBehind
virtual void onDrawBehind(const SkPaint &paint)
SkCanvas::Lattice::fXCount
int fXCount
number of x-coordinates
Definition: SkCanvas.h:1852
SkCanvas::onDrawShadowRec
virtual void onDrawShadowRec(const SkPath &, const SkDrawShadowRec &)
SkCanvas::onDrawOval
virtual void onDrawOval(const SkRect &rect, const SkPaint &paint)
SkCanvas::clipPath
void clipPath(const SkPath &path, SkClipOp op)
Replaces clip with the intersection or difference of clip and path.
Definition: SkCanvas.h:997
SkCanvas::drawImage
void drawImage(const sk_sp< SkImage > &image, SkScalar left, SkScalar top, const SkPaint *paint)
Draws SkImage image, with its top-left corner at (left, top), using clip, SkMatrix,...
Definition: SkCanvas.h:1470
SkCanvas::onPeekPixels
virtual bool onPeekPixels(SkPixmap *pixmap)
GrBackendRenderTarget
Definition: GrBackendSurface.h:61
SkCanvas::kFullLayer_SaveLayerStrategy
@ kFullLayer_SaveLayerStrategy
Definition: SkCanvas.h:2479
SkCanvas::drawPicture
void drawPicture(const SkPicture *picture)
Draws SkPicture picture, using clip and SkMatrix.
Definition: SkCanvas.h:2139
SkRect::set
void set(const SkIRect &src)
Sets SkRect to src, promoting src members from integer to scalar.
Definition: SkRect.h:847
SkData
SkData holds an immutable data buffer.
Definition: SkData.h:22
SkCanvas::drawImageRect
void drawImageRect(const sk_sp< SkImage > &image, const SkIRect &isrc, const SkRect &dst, const SkPaint *paint, SrcRectConstraint constraint=kStrict_SrcRectConstraint)
Draws SkIRect isrc of SkImage image, scaled and translated to fill SkRect dst.
Definition: SkCanvas.h:1633
SkCanvas::setMatrix
void setMatrix(const SkMatrix &matrix)
SkCanvas::drawVertices
void drawVertices(const SkVertices *vertices, const SkPaint &paint)
Variant of 3-parameter drawVertices, using the default of Modulate for the blend parameter.
Definition: SkCanvas.h:2206
SkCanvas::drawImageRect
void drawImageRect(const SkImage *image, const SkRect &src, const SkRect &dst, const SkPaint *paint, SrcRectConstraint constraint=kStrict_SrcRectConstraint)
Draws SkRect src of SkImage image, scaled and translated to fill SkRect dst.
SkCanvas::getProps
bool getProps(SkSurfaceProps *props) const
Copies SkSurfaceProps, if SkCanvas is associated with raster surface or GPU surface,...
SkCanvas::onDrawAnnotation
virtual void onDrawAnnotation(const SkRect &rect, const char key[], SkData *value)
SkCanvas::drawLine
void drawLine(SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1, const SkPaint &paint)
Draws line segment from (x0, y0) to (x1, y1) using clip, SkMatrix, and SkPaint paint.
SkRRect
Definition: SkRRect.h:31
SkCanvas::onDrawImageLattice2
virtual void onDrawImageLattice2(const SkImage *, const Lattice &, const SkRect &dst, SkFilterMode, const SkPaint *)
SkRefCnt.h
SkCanvas::onDrawRegion
virtual void onDrawRegion(const SkRegion &region, const SkPaint &paint)
SkCanvas::onClipShader
virtual void onClipShader(sk_sp< SkShader >, SkClipOp)
SkCanvas::onDrawPicture
virtual void onDrawPicture(const SkPicture *picture, const SkMatrix *matrix, const SkPaint *paint)
SkCanvas::clipShader
void clipShader(sk_sp< SkShader >, SkClipOp=SkClipOp::kIntersect)
SkCanvas::SkCanvas
SkCanvas(int width, int height, const SkSurfaceProps *props=nullptr)
Creates SkCanvas of the specified dimensions without a SkSurface.
SkFilterMode
SkFilterMode
Definition: SkSamplingOptions.h:14
SkCanvas::ImageSetEntry::operator=
ImageSetEntry & operator=(const ImageSetEntry &)
SkCanvas::didTranslate
virtual void didTranslate(SkScalar, SkScalar)
Definition: SkCanvas.h:2497
SkScalar.h
sk_sp< SkBaseDevice >
SkCanvas::flush
void flush()
Triggers the immediate execution of all pending draw operations.
SkCanvas::drawImageRect
void drawImageRect(const sk_sp< SkImage > &image, const SkRect &dst, const SkSamplingOptions &sampling, const SkPaint *paint=nullptr)
Definition: SkCanvas.h:1679
SkSamplingOptions
Definition: SkSamplingOptions.h:50
SkCanvas::drawImageRect
void drawImageRect(const sk_sp< SkImage > &image, const SkRect &dst, const SkPaint *paint)
Draws SkImage image, scaled and translated to fill SkRect dst, using clip, SkMatrix,...
Definition: SkCanvas.h:1659
SkCanvas::clipRRect
void clipRRect(const SkRRect &rrect, SkClipOp op, bool doAntiAlias)
Replaces clip with the intersection or difference of clip and rrect, with an aliased or anti-aliased ...
SkCanvas::~SkCanvas
virtual ~SkCanvas()
Draws saved layers, if any.
SkVertices
An immutable set of vertex data that can be used with SkCanvas::drawVertices.
Definition: SkVertices.h:22
SkCanvas::drawString
void drawString(const char str[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
Draws null terminated string, with origin at (x, y), using clip, SkMatrix, SkFont font,...
Definition: SkCanvas.h:2050
SkCanvas::readPixels
bool readPixels(const SkPixmap &pixmap, int srcX, int srcY)
Copies SkRect of pixels from SkCanvas into pixmap.
SkTextEncoding::kUTF8
@ kUTF8
uses bytes to represent UTF-8 or ASCII
SkCanvas::SkCanvas
SkCanvas(const SkBitmap &bitmap)
Constructs a canvas that draws into bitmap.
SkRegion
Definition: SkRegion.h:23
SkCanvas::onDrawImageRect2
virtual void onDrawImageRect2(const SkImage *, const SkRect &src, const SkRect &dst, const SkSamplingOptions &, const SkPaint *, SrcRectConstraint)
SkCanvas::Lattice::kFixedColor
@ kFixedColor
draws one of fColors into lattice rectangle
Definition: SkCanvas.h:1846
SkCanvas::getDeviceClipBounds
bool getDeviceClipBounds(SkIRect *bounds) const
Returns SkIRect bounds of clip, unaffected by SkMatrix.
Definition: SkCanvas.h:1097
SkString::size
size_t size() const
Definition: SkString.h:128
SkPoint
Definition: SkPoint.h:160
SkCanvas::drawPoint
void drawPoint(SkScalar x, SkScalar y, const SkPaint &paint)
Draws point at (x, y) using clip, SkMatrix and SkPaint paint.
SkCanvas::clear
void clear(SkColor color)
Fills clip with color color using SkBlendMode::kSrc.
Definition: SkCanvas.h:1127
SkCanvas::getSurface
SkSurface * getSurface() const
Sometimes a canvas is owned by a surface.
SkCanvas::clipPath
void clipPath(const SkPath &path, SkClipOp op, bool doAntiAlias)
Replaces clip with the intersection or difference of clip and path, with an aliased or anti-aliased c...
SkBlendMode::kModulate
@ kModulate
product of premultiplied colors; darkens destination
SkCanvas::drawImage
void drawImage(const SkImage *image, SkScalar left, SkScalar top, const SkPaint *paint)
Draws SkImage image, with its top-left corner at (left, top), using clip, SkMatrix,...
SkCanvas::private_draw_shadow_rec
void private_draw_shadow_rec(const SkPath &, const SkDrawShadowRec &)
SkCanvas::getLocalToDevice
SkM44 getLocalToDevice() const
Returns the current transform from local coordinates to the 'device', which for most purposes means p...
SkFontTypes.h
SkCanvas::readPixels
bool readPixels(const SkImageInfo &dstInfo, void *dstPixels, size_t dstRowBytes, int srcX, int srcY)
Copies SkRect of pixels from SkCanvas into dstPixels.
SkCanvas::quickReject
bool quickReject(const SkRect &rect) const
Returns true if SkRect rect, transformed by SkMatrix, can be quickly determined to be outside of clip...
SkCanvas::drawPatch
void drawPatch(const SkPoint cubics[12], const SkColor colors[4], const SkPoint texCoords[4], const SkPaint &paint)
Draws SkPath cubic Coons patch: the interpolation of four cubics with shared corners,...
Definition: SkCanvas.h:2286
SkPaint
Definition: SkPaint.h:39
SK_API
#define SK_API
Definition: SkTypes.h:181
SkASSERT
#define SkASSERT(cond)
Definition: SkTypes.h:460
SkCanvas::onClipPath
virtual void onClipPath(const SkPath &path, SkClipOp op, ClipEdgeStyle edgeStyle)
SkRect::isEmpty
bool isEmpty() const
Returns true if fLeft is equal to or greater than fRight, or if fTop is equal to or greater than fBot...
Definition: SkRect.h:685
SkCanvas::clipIRect
void clipIRect(const SkIRect &irect, SkClipOp op=SkClipOp::kIntersect)
Definition: SkCanvas.h:919
SkCanvas::drawLine
void drawLine(SkPoint p0, SkPoint p1, const SkPaint &paint)
Draws line segment from p0 to p1 using clip, SkMatrix, and SkPaint paint.
Definition: SkCanvas.h:1262
SkCanvas::readPixels
bool readPixels(const SkBitmap &bitmap, int srcX, int srcY)
Copies SkRect of pixels from SkCanvas into bitmap.
SkCanvas::Lattice::fYDivs
const int * fYDivs
y-axis values dividing bitmap
Definition: SkCanvas.h:1850
SkSurfaceProps
Describes properties and constraints of a given SkSurface.
Definition: SkSurfaceProps.h:51
SkCanvas::Lattice::fXDivs
const int * fXDivs
x-axis values dividing bitmap
Definition: SkCanvas.h:1849
SkCanvas::drawPath
void drawPath(const SkPath &path, const SkPaint &paint)
Draws SkPath path using clip, SkMatrix, and SkPaint paint.
SkImageInfo
Definition: SkImageInfo.h:283
SkCanvas::Lattice::kTransparent
@ kTransparent
skips lattice rectangle by making it transparent
Definition: SkCanvas.h:1845
SkCanvas::getTotalMatrix
SkMatrix getTotalMatrix() const
DEPRECATED Legacy version of getLocalToDevice(), which strips away any Z information,...
SkCanvas::kStrict_SrcRectConstraint
@ kStrict_SrcRectConstraint
sample only inside bounds; slower
Definition: SkCanvas.h:1487
SkCanvas::ClipEdgeStyle
ClipEdgeStyle
Definition: SkCanvas.h:2549
SkCanvas::SaveLayerRec
Definition: SkCanvas.h:649
SkCanvas::clear
void clear(const SkColor4f &color)
Fills clip with color color using SkBlendMode::kSrc.
Definition: SkCanvas.h:1136
SkCanvas::isClipRect
virtual bool isClipRect() const
Returns true if clip is SkRect and not empty.
SkCanvas::drawImageLattice
void drawImageLattice(const SkImage *image, const Lattice &lattice, const SkRect &dst, SkFilterMode filter, const SkPaint *paint=nullptr)
Draws SkImage image stretched proportionally to fit into SkRect dst.
SkCanvas::drawTextBlob
void drawTextBlob(const SkTextBlob *blob, SkScalar x, SkScalar y, const SkPaint &paint)
Draws SkTextBlob blob at (x, y), using clip, SkMatrix, and SkPaint paint.
SkCanvas::resetMatrix
void resetMatrix()
Sets SkMatrix to the identity matrix.
SkISize
Definition: SkSize.h:13
SkCanvas::onDrawPatch
virtual void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4], const SkPoint texCoords[4], SkBlendMode mode, const SkPaint &paint)
SkCanvas
Definition: SkCanvas.h:90
SkCanvas::didSetM44
virtual void didSetM44(const SkM44 &)
Definition: SkCanvas.h:2496
SkPicture
Definition: SkPicture.h:39
SkCanvas::quickReject
bool quickReject(const SkPath &path) const
Returns true if path, transformed by SkMatrix, can be quickly determined to be outside of clip.
SkCanvas::onClipRegion
virtual void onClipRegion(const SkRegion &deviceRgn, SkClipOp op)
SkCanvas::clipRRect
void clipRRect(const SkRRect &rrect, bool doAntiAlias=false)
Replaces clip with the intersection of clip and rrect, with an aliased or anti-aliased clip edge.
Definition: SkCanvas.h:968
SkRasterHandleAllocator.h
SkCanvas::rotate
void rotate(SkScalar degrees)
Rotates SkMatrix by degrees.
sk_sp::get
T * get() const
Definition: SkRefCnt.h:298
SkPoint.h
SkCanvas::experimental_DrawEdgeAAQuad
void experimental_DrawEdgeAAQuad(const SkRect &rect, const SkPoint clip[4], QuadAAFlags aaFlags, const SkColor4f &color, SkBlendMode mode)
This is an experimental API for the SkiaRenderer Chromium project, and its API will surely evolve if ...
SkSVGXmlSpace::kDefault
@ kDefault
SkDrawable
Base-class for objects that draw into SkCanvas.
Definition: SkDrawable.h:29
SkCanvas::skew
void skew(SkScalar sx, SkScalar sy)
Skews SkMatrix by sx on the x-axis and sy on the y-axis.
SkCanvas::clipRect
void clipRect(const SkRect &rect, bool doAntiAlias=false)
Replaces clip with the intersection of clip and rect.
Definition: SkCanvas.h:915
SkCanvas::onClipRect
virtual void onClipRect(const SkRect &rect, SkClipOp op, ClipEdgeStyle edgeStyle)
SkPaint.h
SkCanvas::drawImage
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1435
SkCanvas::getSaveCount
int getSaveCount() const
Returns the number of saved states, each containing: SkMatrix and clip.
SkOverdrawCanvas
Captures all drawing commands.
Definition: SkOverdrawCanvas.h:19
SkCanvas::onImageInfo
virtual SkImageInfo onImageInfo() const
SkCanvas::SaveLayerStrategy
SaveLayerStrategy
Definition: SkCanvas.h:2478
SkCanvas::onDrawVerticesObject
virtual void onDrawVerticesObject(const SkVertices *vertices, SkBlendMode mode, const SkPaint &paint)
SkCanvas::ImageSetEntry::fDstRect
SkRect fDstRect
Definition: SkCanvas.h:1923
SkCanvas::drawPicture
void drawPicture(const sk_sp< SkPicture > &picture)
Draws SkPicture picture, using clip and SkMatrix.
Definition: SkCanvas.h:2151
SkCanvas::drawImageRect
void drawImageRect(const SkImage *image, const SkIRect &isrc, const SkRect &dst, const SkPaint *paint, SrcRectConstraint constraint=kStrict_SrcRectConstraint)
Draws SkIRect isrc of SkImage image, scaled and translated to fill SkRect dst.
SkCanvas::drawVertices
void drawVertices(const sk_sp< SkVertices > &vertices, SkBlendMode mode, const SkPaint &paint)
Draws SkVertices vertices, a triangle mesh, using clip and SkMatrix.
SkBlendMode.h
SkCanvas::drawImage
void drawImage(const SkImage *, SkScalar x, SkScalar y, const SkSamplingOptions &, const SkPaint *=nullptr)
SkSurfaceProps.h
SkCanvas::drawRegion
void drawRegion(const SkRegion &region, const SkPaint &paint)
Draws SkRegion region using clip, SkMatrix, and SkPaint paint.
SkCanvas::drawColor
void drawColor(SkColor color, SkBlendMode mode=SkBlendMode::kSrcOver)
Fills clip with color color.
Definition: SkCanvas.h:1110
SkImageInfo::MakeN32Premul
static SkImageInfo MakeN32Premul(int width, int height, sk_sp< SkColorSpace > cs=nullptr)
Creates SkImageInfo from integral dimensions width and height, kN32_SkColorType, kPremul_SkAlphaType,...
Definition: SkImageInfo.h:381
SkScalar
float SkScalar
Definition: SkScalar.h:16
SkCanvas::onDrawDRRect
virtual void onDrawDRRect(const SkRRect &outer, const SkRRect &inner, const SkPaint &paint)
SkCanvas::onDrawArc
virtual void onDrawArc(const SkRect &rect, SkScalar startAngle, SkScalar sweepAngle, bool useCenter, const SkPaint &paint)
SkCanvas::Lattice::fColors
const SkColor * fColors
array of colors
Definition: SkCanvas.h:1855
SkCanvas::drawImage
void drawImage(const sk_sp< SkImage > &image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1438
SkCanvas::SaveLayerRec::SaveLayerRec
SaveLayerRec()
Sets fBounds, fPaint, and fBackdrop to nullptr.
Definition: SkCanvas.h:655
SkCanvas::SkCanvas
SkCanvas(sk_sp< SkBaseDevice > device)
Private.
SkCanvas::drawPatch
void drawPatch(const SkPoint cubics[12], const SkColor colors[4], const SkPoint texCoords[4], SkBlendMode mode, const SkPaint &paint)
Draws a Coons patch: the interpolation of four cubics with shared corners, associating a color,...
SkCanvas::writePixels
bool writePixels(const SkBitmap &bitmap, int x, int y)
Copies SkRect from pixels to SkCanvas.
SkIRect::MakeEmpty
static constexpr SkIRect SK_WARN_UNUSED_RESULT MakeEmpty()
Returns constructed SkIRect set to (0, 0, 0, 0).
Definition: SkRect.h:41
SkCanvas::getLocalToDeviceAs3x3
SkMatrix getLocalToDeviceAs3x3() const
Throws away the 3rd row and column in the matrix, so be warned.
Definition: SkCanvas.h:2430
SkCanvas::restoreToCount
void restoreToCount(int saveCount)
Restores state to SkMatrix and clip values when save(), saveLayer(), saveLayerPreserveLCDTextRequests...
SkCanvas::peekPixels
bool peekPixels(SkPixmap *pixmap)
Returns true if SkCanvas has direct access to its pixels.
SkCanvas::onDoSaveBehind
virtual bool onDoSaveBehind(const SkRect *)
Definition: SkCanvas.h:2490
SkCanvas::clipRect
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
Replaces clip with the intersection or difference of clip and rect, with an aliased or anti-aliased c...
SkTextEncoding
SkTextEncoding
Definition: SkFontTypes.h:11
SkClipOp
SkClipOp
Definition: SkClipOp.h:13
SkCanvas::imageInfo
SkImageInfo imageInfo() const
Returns SkImageInfo for SkCanvas.
SkCanvas::SaveLayerFlags
uint32_t SaveLayerFlags
Definition: SkCanvas.h:644
SkCanvas::drawBitmap
void drawBitmap(const SkBitmap &bitmap, SkScalar left, SkScalar top, const SkPaint *paint=nullptr)
Draws SkBitmap bitmap, with its top-left corner at (left, top), using clip, SkMatrix,...
SkCanvas::getSaveLayerStrategy
virtual SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec &)
Definition: SkCanvas.h:2485
SkCanvas::drawPaint
void drawPaint(const SkPaint &paint)
Fills clip with SkPaint paint.
SkCanvas::didConcat44
virtual void didConcat44(const SkM44 &)
Definition: SkCanvas.h:2495
SkPixmap
Definition: SkPixmap.h:31
SkCanvas::Lattice::fYCount
int fYCount
number of y-coordinates
Definition: SkCanvas.h:1853
SkCanvas::restore
void restore()
Removes changes to SkMatrix and clip since SkCanvas state was last saved.
SkAutoCanvasRestore
Definition: SkCanvas.h:2744
SkFilterMode::kNearest
@ kNearest
SkCanvas::SaveLayerRec::SaveLayerRec
SaveLayerRec(const SkRect *bounds, const SkPaint *paint, const SkImageFilter *backdrop, SaveLayerFlags saveLayerFlags)
Sets fBounds, fPaint, fBackdrop, and fSaveLayerFlags.
Definition: SkCanvas.h:682
SkCanvas::drawBitmapRect
void drawBitmapRect(const SkBitmap &bitmap, const SkIRect &isrc, const SkRect &dst, const SkPaint *paint, SrcRectConstraint constraint=kStrict_SrcRectConstraint)
Draws SkIRect isrc of SkBitmap bitmap, scaled and translated to fill SkRect dst.
SkCanvas::onDrawEdgeAAQuad
virtual void onDrawEdgeAAQuad(const SkRect &rect, const SkPoint clip[4], QuadAAFlags aaFlags, const SkColor4f &color, SkBlendMode mode)
SkCanvas::ImageSetEntry
This is used by the experimental API below.
Definition: SkCanvas.h:1909
SkCanvas::clipRect
void clipRect(const SkRect &rect, SkClipOp op)
Replaces clip with the intersection or difference of clip and rect.
Definition: SkCanvas.h:903
SkBlendMode::kSrc
@ kSrc
replaces destination
SkCanvas::onDrawDrawable
virtual void onDrawDrawable(SkDrawable *drawable, const SkMatrix *matrix)
SkCanvas::accessTopRasterHandle
SkRasterHandleAllocator::Handle accessTopRasterHandle() const
Returns custom context that tracks the SkMatrix and clip.
SkCanvas::kNoLayer_SaveLayerStrategy
@ kNoLayer_SaveLayerStrategy
Definition: SkCanvas.h:2480
SkMatrix
Definition: SkMatrix.h:48
SkMatrix.h
SkIRect
Definition: SkRect.h:28
SkString.h
SkCanvas::drawRRect
void drawRRect(const SkRRect &rrect, const SkPaint &paint)
Draws SkRRect rrect using clip, SkMatrix, and SkPaint paint.
SkCanvas::recordingContext
virtual GrRecordingContext * recordingContext()
Returns GPU context of the GPU surface associated with SkCanvas.
SkCanvas::drawPicture
void drawPicture(const SkPicture *picture, const SkMatrix *matrix, const SkPaint *paint)
Draws SkPicture picture, using clip and SkMatrix; transforming picture with SkMatrix matrix,...
SkCanvas::onDiscard
virtual void onDiscard()
SkCanvas::drawPicture
void drawPicture(const sk_sp< SkPicture > &picture, const SkMatrix *matrix, const SkPaint *paint)
Draws SkPicture picture, using clip and SkMatrix; transforming picture with SkMatrix matrix,...
Definition: SkCanvas.h:2183
SkPoint::y
constexpr SkScalar y() const
Returns y-axis value of SkPoint or vector.
Definition: SkPoint.h:184
SkCanvas::drawPoint
void drawPoint(SkPoint p, const SkPaint &paint)
Draws point p using clip, SkMatrix and SkPaint paint.
Definition: SkCanvas.h:1234
SkCanvas::SaveLayerRec::SaveLayerRec
SaveLayerRec(const SkRect *bounds, const SkPaint *paint, SaveLayerFlags saveLayerFlags=0)
Sets fBounds, fPaint, and fSaveLayerFlags; sets fBackdrop to nullptr.
Definition: SkCanvas.h:664
SkCanvas::didScale
virtual void didScale(SkScalar, SkScalar)
Definition: SkCanvas.h:2498
SkCanvas::drawAnnotation
void drawAnnotation(const SkRect &rect, const char key[], SkData *value)
Associates SkRect on SkCanvas with an annotation; a key-value pair, where the key is a null-terminate...
SkString::c_str
const char * c_str() const
Definition: SkString.h:129
SkCanvas::Lattice::fRectTypes
const RectType * fRectTypes
array of fill types
Definition: SkCanvas.h:1851
SkCanvas::onDrawTextBlob
virtual void onDrawTextBlob(const SkTextBlob *blob, SkScalar x, SkScalar y, const SkPaint &paint)
SkCanvas::onAccessTopLayerPixels
virtual bool onAccessTopLayerPixels(SkPixmap *pixmap)
SkCanvas::SkCanvas
SkCanvas(const SkBitmap &bitmap, const SkSurfaceProps &props)
Constructs a canvas that draws into bitmap.
SkCanvas::kLines_PointMode
@ kLines_PointMode
draw each pair of points as a line segment
Definition: SkCanvas.h:1170
SkCanvas::isClipEmpty
virtual bool isClipEmpty() const
Returns true if clip is empty; that is, nothing will draw.
SkCanvas::saveLayer
int saveLayer(const SkRect *bounds, const SkPaint *paint)
Saves SkMatrix and clip, and allocates a SkBitmap for subsequent drawing.
SkString
Definition: SkString.h:116
SkFont
Definition: SkFont.h:23
SkCanvas::SkCanvas
SkCanvas(const SkIRect &bounds)
SkCanvas::getDeviceClipBounds
SkIRect getDeviceClipBounds() const
Returns SkIRect bounds of clip, unaffected by SkMatrix.
SkCanvas::onGetProps
virtual bool onGetProps(SkSurfaceProps *props) const
SkBlendMode::kSrcOver
@ kSrcOver
source over destination
SkCanvas::onClipRRect
virtual void onClipRRect(const SkRRect &rrect, SkClipOp op, ClipEdgeStyle edgeStyle)
SkCanvas::getLocalClipBounds
bool getLocalClipBounds(SkRect *bounds) const
Returns bounds of clip, transformed by inverse of SkMatrix.
Definition: SkCanvas.h:1073
SkCanvas::drawImageRect
void drawImageRect(const SkImage *, const SkRect &dst, const SkSamplingOptions &, const SkPaint *=nullptr)
SkPMColor
uint32_t SkPMColor
32-bit ARGB color value, premultiplied.
Definition: SkColor.h:203
SkCanvas::clipRRect
void clipRRect(const SkRRect &rrect, SkClipOp op)
Replaces clip with the intersection or difference of clip and rrect.
Definition: SkCanvas.h:957
SkColor
uint32_t SkColor
32-bit ARGB color value, unpremultiplied.
Definition: SkColor.h:35
SkCanvas::onDrawAtlas2
virtual void onDrawAtlas2(const SkImage *, const SkRSXform[], const SkRect src[], const SkColor[], int count, SkBlendMode, const SkSamplingOptions &, const SkRect *cull, const SkPaint *)
SkRect
Definition: SkRect.h:572
SkCanvas::drawVertices
void drawVertices(const sk_sp< SkVertices > &vertices, const SkPaint &paint)
Variant of 3-parameter drawVertices, using the default of Modulate for the blend parameter.
Definition: SkCanvas.h:2228
SkCanvas::makeSurface
sk_sp< SkSurface > makeSurface(const SkImageInfo &info, const SkSurfaceProps *props=nullptr)
Creates SkSurface matching info and props, and associates it with SkCanvas.
SkCanvas::drawVertices
void drawVertices(const SkVertices *vertices, SkBlendMode mode, const SkPaint &paint)
Draws SkVertices vertices, a triangle mesh, using clip and SkMatrix.
SkCanvas::rotate
void rotate(SkScalar degrees, SkScalar px, SkScalar py)
Rotates SkMatrix by degrees about a point at (px, py).
SkCanvas::kFast_SrcRectConstraint
@ kFast_SrcRectConstraint
sample outside bounds; faster
Definition: SkCanvas.h:1488
SkCanvas::QuadAAFlags
QuadAAFlags
Experimental.
Definition: SkCanvas.h:1898
U8CPU
unsigned U8CPU
Fast type for unsigned 8 bits.
Definition: SkTypes.h:488
SkCanvas::didRestore
virtual void didRestore()
Definition: SkCanvas.h:2492
SkCanvas::kHard_ClipEdgeStyle
@ kHard_ClipEdgeStyle
Definition: SkCanvas.h:2550
SkCanvas::kPolygon_PointMode
@ kPolygon_PointMode
draw the array of points as a open polygon
Definition: SkCanvas.h:1171
SkCanvas::Lattice::RectType
RectType
Definition: SkCanvas.h:1843
SkRect::Make
static SkRect Make(const SkISize &size)
Returns constructed SkIRect set to (0, 0, size.width(), size.height()).
Definition: SkRect.h:661
SkIPoint
Definition: SkPoint.h:25
SkClipOp.h
SkCanvas::translate
void translate(SkScalar dx, SkScalar dy)
Translates SkMatrix by dx along the x-axis and dy along the y-axis.
SkCanvas::onDrawPaint
virtual void onDrawPaint(const SkPaint &paint)
SkCanvas::PointMode
PointMode
Definition: SkCanvas.h:1168
SkCanvas::onMarkCTM
virtual void onMarkCTM(const char *)
Definition: SkCanvas.h:2494
SkColor.h
SkCanvas::getBaseLayerSize
virtual SkISize getBaseLayerSize() const
Gets the size of the base or root layer in global canvas coordinates.
SkCanvas::setMatrix
void setMatrix(const SkM44 &matrix)
Replaces SkMatrix with matrix.
SkCanvas::drawImageRect
void drawImageRect(const SkImage *image, const SkRect &dst, const SkPaint *paint)
Draws SkImage image, scaled and translated to fill SkRect dst, using clip, SkMatrix,...
SkCanvas::Lattice
Definition: SkCanvas.h:1837
SkImageInfo.h
SkCanvas::drawTextBlob
void drawTextBlob(const sk_sp< SkTextBlob > &blob, SkScalar x, SkScalar y, const SkPaint &paint)
Draws SkTextBlob blob at (x, y), using clip, SkMatrix, and SkPaint paint.
Definition: SkCanvas.h:2127
SkBitmap
Definition: SkBitmap.h:50
SkCanvas::ImageSetEntry::ImageSetEntry
ImageSetEntry()
SkAutoCanvasRestore::restore
void restore()
Restores SkCanvas to saved state immediately.
Definition: SkCanvas.h:2774
SkCanvas::kPoints_PointMode
@ kPoints_PointMode
draw each point separately
Definition: SkCanvas.h:1169
SkCanvas::drawCircle
void drawCircle(SkPoint center, SkScalar radius, const SkPaint &paint)
Draws circle at center with radius using clip, SkMatrix, and SkPaint paint.
Definition: SkCanvas.h:1373
SkCanvas::temporary_internal_getRgnClip
void temporary_internal_getRgnClip(SkRegion *region)
Returns the global clip as a region.
SkCanvas::SaveLayerFlagsSet
SaveLayerFlagsSet
Definition: SkCanvas.h:635
SkCanvas::MakeRasterDirectN32
static std::unique_ptr< SkCanvas > MakeRasterDirectN32(int width, int height, SkPMColor *pixels, size_t rowBytes)
Allocates raster SkCanvas specified by inline image specification.
Definition: SkCanvas.h:147
SkCanvas::drawDRRect
void drawDRRect(const SkRRect &outer, const SkRRect &inner, const SkPaint &paint)
Draws SkRRect outer and inner using clip, SkMatrix, and SkPaint paint.
SkIRect::isEmpty
bool isEmpty() const
Returns true if width() or height() are zero or negative.
Definition: SkRect.h:200
SkCanvas::androidFramework_setDeviceClipRestriction
void androidFramework_setDeviceClipRestriction(const SkIRect &rect)
Sets the maximum clip rectangle, which can be set by clipRect(), clipRRect() and clipPath() and inter...
SkCanvas::Lattice::fBounds
const SkIRect * fBounds
source bounds to draw from
Definition: SkCanvas.h:1854
SkSamplingOptions.h
SkCanvas::clipRegion
void clipRegion(const SkRegion &deviceRgn, SkClipOp op=SkClipOp::kIntersect)
Replaces clip with the intersection or difference of clip and SkRegion deviceRgn.
SkImageFilter
Base class for image filters.
Definition: SkImageFilter.h:31
SkPoint::x
constexpr SkScalar x() const
Returns x-axis value of SkPoint or vector.
Definition: SkPoint.h:178
SkCanvas::drawImageRect
void drawImageRect(const sk_sp< SkImage > &image, const SkRect &src, const SkRect &dst, const SkSamplingOptions &sampling, const SkPaint *paint, SrcRectConstraint constraint)
Definition: SkCanvas.h:1674