aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--dm/DMSrcSink.cpp7
-rw-r--r--docs/SkCanvas_Reference.bmh364
-rw-r--r--include/core/SkCanvas.h6
-rw-r--r--include/utils/SkNoDrawCanvas.h2
-rw-r--r--src/core/SkCanvas.cpp25
-rw-r--r--src/core/SkRemoteGlyphCache.cpp2
-rw-r--r--src/core/SkSpecialSurface.cpp2
-rw-r--r--src/image/SkSurface_Gpu.cpp2
-rw-r--r--src/pdf/SkPDFDevice.cpp4
-rw-r--r--src/pdf/SkPDFDocument.cpp2
-rw-r--r--src/pdf/SkPDFShader.cpp2
-rw-r--r--src/svg/SkSVGCanvas.cpp2
-rw-r--r--src/xps/SkXPSDocument.cpp2
-rw-r--r--tests/LayerDrawLooperTest.cpp6
-rw-r--r--tools/viewer/Viewer.cpp9
15 files changed, 218 insertions, 219 deletions
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index bab344b1e5..e6db22bcdb 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -32,6 +32,7 @@
#include "SkImageInfoPriv.h"
#include "SkLiteDL.h"
#include "SkLiteRecorder.h"
+#include "SkMakeUnique.h"
#include "SkMallocPixelRef.h"
#include "SkMultiPictureDocumentPriv.h"
#include "SkMultiPictureDraw.h"
@@ -1800,9 +1801,9 @@ ThreadedSink::ThreadedSink(SkColorType colorType, sk_sp<SkColorSpace> colorSpace
Error ThreadedSink::draw(const Src& src, SkBitmap* dst, SkWStream* stream, SkString* str) const {
this->allocPixels(src, dst);
- std::unique_ptr<SkThreadedBMPDevice> device(new SkThreadedBMPDevice(
- *dst, FLAGS_backendTiles, FLAGS_backendThreads, fExecutor.get()));
- std::unique_ptr<SkCanvas> canvas(new SkCanvas(device.get()));
+ auto canvas = skstd::make_unique<SkCanvas>(
+ sk_make_sp<SkThreadedBMPDevice>(
+ *dst, FLAGS_backendTiles, FLAGS_backendThreads, fExecutor.get()));
Error result = src.draw(canvas.get());
canvas->flush();
return result;
diff --git a/docs/SkCanvas_Reference.bmh b/docs/SkCanvas_Reference.bmh
index f4672c4dc5..2f4774f566 100644
--- a/docs/SkCanvas_Reference.bmh
+++ b/docs/SkCanvas_Reference.bmh
@@ -18,9 +18,9 @@ Matrix values in the stack. The transformed geometry is clipped by the intersect
of all of Clip values in the stack. The Canvas draw calls use Paint to supply drawing
state such as Color, Typeface, text size, stroke width, Shader and so on.
-To draw to a pixel-based destination, create Raster_Surface or GPU_Surface.
-Request Canvas from Surface to obtain the interface to draw.
-Canvas generated by Raster_Surface draws to memory visible to the CPU.
+To draw to a pixel-based destination, create Raster_Surface or GPU_Surface.
+Request Canvas from Surface to obtain the interface to draw.
+Canvas generated by Raster_Surface draws to memory visible to the CPU.
Canvas generated by GPU_Surface uses Vulkan or OpenGL to draw to the GPU.
To draw to a document, obtain Canvas from SVG_Canvas, Document_PDF, or Picture_Recorder.
@@ -28,7 +28,7 @@ Document based Canvas and other Canvas Subclasses reference Device describing th
destination.
Canvas can be constructed to draw to Bitmap without first creating Raster_Surface.
-This approach may be deprecated in the future.
+This approach may be deprecated in the future.
#Subtopic Related_Function
#Populate
@@ -71,7 +71,7 @@ info contains Color_Type and Alpha_Type supported by Raster_Surface;
pixels is not nullptr;
rowBytes is zero or large enough to contain info width pixels of Color_Type.
-Pass zero for rowBytes to compute rowBytes from info width and size of pixel.
+Pass zero for rowBytes to compute rowBytes from info width and size of pixel.
If rowBytes is greater than zero, it must be equal to or greater than
info width times bytes required for Color_Type.
@@ -133,7 +133,7 @@ void draw(SkCanvas* ) {
# ------------------------------------------------------------------------------
#Method static std::unique_ptr<SkCanvas> MakeRasterDirectN32(int width, int height, SkPMColor* pixels,
- size_t rowBytes)
+ size_t rowBytes)
#In Constructor
#Line # creates from image data and Pixel_Storage ##
@@ -149,7 +149,7 @@ width and height are zero or positive;
pixels is not nullptr;
rowBytes is zero or large enough to contain width pixels of kN32_SkColorType.
-Pass zero for rowBytes to compute rowBytes from width and size of pixel.
+Pass zero for rowBytes to compute rowBytes from width and size of pixel.
If rowBytes is greater than zero, it must be equal to or greater than
width times bytes required for Color_Type.
@@ -210,7 +210,7 @@ void draw(SkCanvas* ) {
#Method SkCanvas()
#Line # creates with no Surface, no dimensions ##
-Creates an empty Canvas with no backing device or pixels, with
+Creates an empty Canvas with no backing device or pixels, with
a width and height of zero.
#Return empty Canvas ##
@@ -267,7 +267,7 @@ Creates Canvas of the specified dimensions without a Surface.
Used by Subclasses with custom implementations for draw methods.
If props equals nullptr, Surface_Properties are created with
-Surface_Properties_Legacy_Font_Host settings, which choose the pixel striping
+Surface_Properties_Legacy_Font_Host settings, which choose the pixel striping
direction and order. Since a platform may dynamically change its direction when
the device is rotated, and since a platform may have multiple monitors with
different characteristics, it is best not to rely on this legacy behavior.
@@ -296,7 +296,7 @@ different characteristics, it is best not to rely on this legacy behavior.
# ------------------------------------------------------------------------------
-#Method explicit SkCanvas(SkBaseDevice* device)
+#Method explicit SkCanvas(sk_sp<SkBaseDevice> device)
#Deprecated soon
##
@@ -306,7 +306,7 @@ different characteristics, it is best not to rely on this legacy behavior.
#Line # uses existing Bitmap ##
Construct a canvas that draws into bitmap.
-Sets SkSurfaceProps::kLegacyFontHost_InitType in constructed Surface.
+Sets SkSurfaceProps::kLegacyFontHost_InitType in constructed Surface.
Bitmap is copied so that subsequently editing bitmap will not affect
constructed Canvas.
@@ -407,7 +407,7 @@ bitmap is copied so that subsequently editing bitmap will not affect
constructed Canvas.
#Param bitmap width, height, Color_Type, Alpha_Type,
- and pixel storage of Raster_Surface
+ and pixel storage of Raster_Surface
##
#Param props order and orientation of RGB striping; and whether to use
device independent fonts
@@ -599,7 +599,7 @@ return false and leave props unchanged.
#Method void flush()
#In Utility
#Line # triggers execution of all pending draw operations ##
-Triggers the immediate execution of all pending draw operations.
+Triggers the immediate execution of all pending draw operations.
If Canvas is associated with GPU_Surface, resolves all pending GPU operations.
If Canvas is associated with Raster_Surface, has no effect; raster draw
operations are never deferred.
@@ -720,7 +720,7 @@ void draw(SkCanvas* canvas) {
#ToDo fiddle should show both CPU and GPU out ##
-#SeeAlso GrContext
+#SeeAlso GrContext
##
@@ -759,7 +759,7 @@ void draw(SkCanvas* canvas) {
#Description
Draws "ABC" on the device. Then draws "DEF" in Layer, and reads
Layer to add a large dotted "DEF". Finally blends Layer with the
-device.
+device.
The Layer and blended result appear on the CPU and GPU but the large dotted
"DEF" appear only on the CPU.
@@ -914,7 +914,7 @@ Canvas or Surface call may invalidate the pixmap values.
#Line # copies and converts rectangle of pixels from Canvas ##
Copies Rect of pixels from Canvas into dstPixels. Matrix and Clip are
-ignored.
+ignored.
Source Rect corners are (srcX, srcY) and (imageInfo().width(), imageInfo().height()).
Destination Rect corners are (0, 0) and (dstInfo.width(), dstInfo.height()).
@@ -968,7 +968,7 @@ Does not copy, and returns false if:
for (int x : { 32, -32 } ) {
for (int y : { 32, -32 } ) {
canvas->readPixels(info, data->writable_data(), info.minRowBytes(), x, y);
- }
+ }
}
sk_sp<SkImage> image = SkImage::MakeRasterData(info, data, info.minRowBytes());
canvas->drawImage(image, 0, 0);
@@ -1290,10 +1290,10 @@ Note that the second clipRect is not permitted to enlarge Clip.
#Height 160
void draw(SkCanvas* canvas) {
SkPaint paint;
- canvas->save(); // records stack depth to restore
+ canvas->save(); // records stack depth to restore
canvas->clipRect(SkRect::MakeWH(100, 100)); // constrains drawing to clip
canvas->clear(SK_ColorRED); // draws to limit of clip
- canvas->save(); // records stack depth to restore
+ canvas->save(); // records stack depth to restore
canvas->clipRect(SkRect::MakeWH(50, 150)); // Rect below 100 is ignored
canvas->clear(SK_ColorBLUE); // draws to smaller clip
canvas->restore(); // enlarges clip
@@ -1301,7 +1301,7 @@ void draw(SkCanvas* canvas) {
canvas->restore(); // enlarges clip
canvas->drawLine(150, 20, 50, 120, paint); // line below 100 is drawn
}
-##
+##
Each Clip uses the current Matrix for its coordinates.
@@ -1341,7 +1341,7 @@ Call restoreToCount with result to restore this and subsequent saves.
#Return depth of saved stack ##
#Example
-#Description
+#Description
The black square is translated 50 pixels down and to the right.
Restoring Canvas state removes translate() from Canvas stack;
the red square is not translated, and is drawn at the origin.
@@ -1371,9 +1371,9 @@ void draw(SkCanvas* canvas) {
#In State_Stack
#Line # restores changes to Clip and Matrix, pops save stack ##
Removes changes to Matrix, Clip, and Draw_Filter since Canvas state was
-last saved. The state is removed from the stack.
+last saved. The state is removed from the stack.
-Does nothing if the stack is empty.
+Does nothing if the stack is empty.
#Example
void draw(SkCanvas* canvas) {
@@ -1395,7 +1395,7 @@ void draw(SkCanvas* canvas) {
#In State_Stack
#Line # returns depth of stack containing Clip and Matrix ##
Returns the number of saved states, each containing: Matrix, Clip, and Draw_Filter.
-Equals the number of save() calls less the number of restore() calls plus one.
+Equals the number of save() calls less the number of restore() calls plus one.
The save count of a new canvas is one.
#Return depth of save state stack ##
@@ -1429,7 +1429,7 @@ depth = 1
Restores state to Matrix, Clip, and Draw_Filter values when save(), saveLayer,
saveLayerPreserveLCDTextRequests, or saveLayerAlpha returned saveCount.
-Does nothing if saveCount is greater than state stack count.
+Does nothing if saveCount is greater than state stack count.
Restores state to initial values if saveCount is less than or equal to one.
#Param saveCount depth of state stack to restore ##
@@ -1450,7 +1450,7 @@ depth = 1
##
##
-#SeeAlso restore() getSaveCount save()
+#SeeAlso restore() getSaveCount save()
##
@@ -1464,7 +1464,7 @@ depth = 1
#Line # temporary Bitmap to draw into ##
Layer allocates a temporary Bitmap to draw into. When the drawing is
-complete, the Bitmap is drawn into the Canvas.
+complete, the Bitmap is drawn into the Canvas.
Layer is saved in a stack along with other saved state. When state with a Layer
is restored, the Bitmap is drawn into the previous Layer.
@@ -1483,7 +1483,7 @@ Calling restore() discards changes to Matrix, Clip, and Draw_Filter,
and draws the Bitmap.
Matrix may be changed by translate(), scale(), rotate(), skew(), concat(),
-setMatrix, and resetMatrix. Clip may be changed by clipRect, clipRRect,
+setMatrix, and resetMatrix. Clip may be changed by clipRect, clipRRect,
clipPath, clipRegion.
Rect bounds suggests but does not define the Bitmap size. To clip drawing to
@@ -1522,7 +1522,7 @@ void draw(SkCanvas* canvas) {
##
-#Method int saveLayer(const SkRect& bounds, const SkPaint* paint)
+#Method int saveLayer(const SkRect& bounds, const SkPaint* paint)
#In Layer
Saves Matrix, Clip, and Draw_Filter (Draw_Filter deprecated on most platforms),
@@ -1550,7 +1550,7 @@ Call restoreToCount with returned value to restore this and subsequent saves.
#Example
#Description
Rectangles are blurred by Image_Filter when restore() draws Layer to main Canvas.
-The red rectangle is clipped; it does not fully fit on Layer.
+The red rectangle is clipped; it does not fully fit on Layer.
Image_Filter blurs past edge of Layer so red rectangle is blurred on all sides.
##
#Height 128
@@ -1585,7 +1585,7 @@ and draws Layer.
Matrix may be changed by translate(), scale(), rotate(), skew(), concat(),
setMatrix, and resetMatrix. Clip may be changed by clipRect, clipRRect,
clipPath, clipRegion.
-
+
Rect bounds suggests but does not define the Layer size. To clip drawing to
a specific rectangle, use clipRect.
@@ -1673,7 +1673,7 @@ Call restoreToCount with returned value to restore this and subsequent saves.
##
-#ToDo
+#ToDo
add new markup to associate typedef SaveLayerFlags with Enum so that, for
documentation purposes, this enum is named rather than anonymous
##
@@ -1715,7 +1715,7 @@ defining how Layer allocated by saveLayer operates.
#Height 160
#Description
Canvas Layer captures red and blue circles scaled up by four.
-scalePaint blends Layer back with transparency.
+scalePaint blends Layer back with transparency.
##
void draw(SkCanvas* canvas) {
SkPaint redPaint, bluePaint, scalePaint;
@@ -1729,7 +1729,7 @@ void draw(SkCanvas* canvas) {
scalePaint.setImageFilter(
SkImageFilter::MakeMatrixFilter(matrix, kNone_SkFilterQuality, nullptr));
SkCanvas::SaveLayerRec saveLayerRec(nullptr, &scalePaint,
- SkCanvas::kInitWithPrevious_SaveLayerFlag);
+ SkCanvas::kInitWithPrevious_SaveLayerFlag);
canvas->saveLayer(saveLayerRec);
canvas->restore();
}
@@ -1756,7 +1756,7 @@ void draw(SkCanvas* canvas) {
};
##
-SaveLayerRec contains the state used to create the Layer.
+SaveLayerRec contains the state used to create the Layer.
#Member const SkRect* fBounds
fBounds is used as a hint to limit the size of Layer; may be nullptr.
@@ -1782,7 +1782,7 @@ SaveLayerRec contains the state used to create the Layer.
##
#Member const SkMatrix* fClipMatrix
- fClipMatrix transforms fClipMask before it clips Layer. If
+ fClipMatrix transforms fClipMask before it clips Layer. If
fClipMask describes a translucent gradient, it may be scaled and rotated
without introducing artifacts. fClipMatrix may be nullptr.
##
@@ -1798,7 +1798,7 @@ SaveLayerRec contains the state used to create the Layer.
#Description
Canvas Layer captures a red Anti-aliased circle and a blue Aliased circle scaled
up by four. After drawing another red circle without scaling on top, the Layer is
-transferred to the main canvas.
+transferred to the main canvas.
##
void draw(SkCanvas* canvas) {
SkPaint redPaint, bluePaint;
@@ -1810,7 +1810,7 @@ void draw(SkCanvas* canvas) {
SkMatrix matrix;
matrix.setScale(4, 4);
auto scaler = SkImageFilter::MakeMatrixFilter(matrix, kNone_SkFilterQuality, nullptr);
- SkCanvas::SaveLayerRec saveLayerRec(nullptr, nullptr, scaler.get(), 0);
+ SkCanvas::SaveLayerRec saveLayerRec(nullptr, nullptr, scaler.get(), 0);
canvas->saveLayer(saveLayerRec);
canvas->drawCircle(125, 85, 8, redPaint);
canvas->restore();
@@ -1921,7 +1921,7 @@ Implementation is not complete; has no effect if Device is GPU-backed.
##
#Param clipMask clip applied to Layer; may be nullptr ##
#Param clipMatrix matrix applied to clipMask; may be nullptr to use
- identity matrix
+ identity matrix
##
#Param saveLayerFlags SaveLayerRec options to modify Layer ##
@@ -1994,7 +1994,7 @@ Outside of the circle the mandrill is brightened.
Translate Matrix by dx along the x-axis and dy along the y-axis.
Mathematically, replace Matrix with a translation matrix
-Premultiplied with Matrix.
+Premultiplied with Matrix.
This has the effect of moving the drawing by (dx, dy) before transforming
the result with Matrix.
@@ -2006,10 +2006,10 @@ the result with Matrix.
#Height 128
#Description
scale() followed by translate() produces different results from translate() followed
-by scale().
+by scale().
The blue stroke follows translate of (50, 50); a black
-fill follows scale of (2, 1/2.f). After restoring the clip, which resets
+fill follows scale of (2, 1/2.f). After restoring the clip, which resets
Matrix, a red frame follows the same scale of (2, 1/2.f); a gray fill
follows translate of (50, 50).
##
@@ -2046,7 +2046,7 @@ void draw(SkCanvas* canvas) {
Scale Matrix by sx on the x-axis and sy on the y-axis.
Mathematically, replace Matrix with a scale matrix
-Premultiplied with Matrix.
+Premultiplied with Matrix.
This has the effect of scaling the drawing by (sx, sy) before transforming
the result with Matrix.
@@ -2080,7 +2080,7 @@ void draw(SkCanvas* canvas) {
Rotate Matrix by degrees. Positive degrees rotates clockwise.
Mathematically, replace Matrix with a rotation matrix
-Premultiplied with Matrix.
+Premultiplied with Matrix.
This has the effect of rotating the drawing by degrees before transforming
the result with Matrix.
@@ -2099,7 +2099,7 @@ void draw(SkCanvas* canvas) {
canvas->drawCircle(0, 0, 60, paint);
canvas->save();
canvas->rotate(10 * 360 / 60); // 10 minutes of 60 scaled to 360 degrees
- canvas->drawLine(0, 0, 0, -50, paint);
+ canvas->drawLine(0, 0, 0, -50, paint);
canvas->restore();
canvas->rotate((5 + 10.f/60) * 360 / 12); // 5 and 10/60 hours of 12 scaled to 360 degrees
canvas->drawLine(0, 0, 0, -30, paint);
@@ -2120,7 +2120,7 @@ clockwise.
Mathematically, construct a rotation matrix. Premultiply the rotation matrix by
a translation matrix, then replace Matrix with the resulting matrix
-Premultiplied with Matrix.
+Premultiplied with Matrix.
This has the effect of rotating the drawing about a given point before
transforming the result with Matrix.
@@ -2154,7 +2154,7 @@ Skew Matrix by sx on the x-axis and sy on the y-axis. A positive value of sx
skews the drawing right as y increases; a positive value of sy skews the drawing
down as x increases.
-Mathematically, replace Matrix with a skew matrix Premultiplied with Matrix.
+Mathematically, replace Matrix with a skew matrix Premultiplied with Matrix.
This has the effect of skewing the drawing by (sx, sy) before transforming
the result with Matrix.
@@ -2163,7 +2163,7 @@ the result with Matrix.
#Param sy amount to skew in y ##
#Example
- #Description
+ #Description
Black text mimics an oblique text style by using a negative skew in x that
shifts the geometry to the right as the y values decrease.
Red text uses a positive skew in y to shift the geometry down as the x values
@@ -2307,13 +2307,13 @@ This does not account for translation by Device or Surface.
#Line # stack of clipping Paths ##
Clip is built from a stack of clipping paths. Each Path in the
-stack can be constructed from one or more Path_Contour elements. The
+stack can be constructed from one or more Path_Contour elements. The
Path_Contour may be composed of any number of Path_Verb segments. Each
Path_Contour forms a closed area; Path_Fill_Type defines the area enclosed
by Path_Contour.
Clip stack of Path elements successfully restrict the Path area. Each
-Path is transformed by Matrix, then intersected with or subtracted from the
+Path is transformed by Matrix, then intersected with or subtracted from the
prior Clip to form the replacement Clip. Use SkClipOp::kDifference
to subtract Path from Clip; use SkClipOp::kIntersect to intersect Path
with Clip.
@@ -2324,7 +2324,7 @@ to either be inside or outside the clip. The fastest drawing has a Aliased,
rectangular clip.
If clipping Path has Anti-alias set, clip may partially clip a pixel, requiring
-that drawing blend partially with the destination along the edge. A rotated
+that drawing blend partially with the destination along the edge. A rotated
rectangular Anti-aliased clip looks smoother but draws slower.
Clip can combine with Rect and Round_Rect primitives; like
@@ -2358,7 +2358,7 @@ and is unaffected by Matrix.
scalePaint.setImageFilter(
SkImageFilter::MakeMatrixFilter(matrix, kNone_SkFilterQuality, nullptr));
SkCanvas::SaveLayerRec saveLayerRec(
- nullptr, &scalePaint, SkCanvas::kInitWithPrevious_SaveLayerFlag);
+ nullptr, &scalePaint, SkCanvas::kInitWithPrevious_SaveLayerFlag);
canvas->saveLayer(saveLayerRec);
canvas->restore();
##
@@ -2395,7 +2395,7 @@ void draw(SkCanvas* canvas) {
##
-#Method void clipRect(const SkRect& rect, SkClipOp op)
+#Method void clipRect(const SkRect& rect, SkClipOp op)
#In Clip
Replace Clip with the intersection or difference of Clip and rect.
@@ -2424,7 +2424,7 @@ void draw(SkCanvas* canvas) {
##
-#Method void clipRect(const SkRect& rect, bool doAntiAlias = false)
+#Method void clipRect(const SkRect& rect, bool doAntiAlias = false)
#In Clip
Replace Clip with the intersection of Clip and rect.
@@ -2475,7 +2475,7 @@ clipPath and intersect the current clip with the specified rect.
The maximum clip affects only future clipping operations; it is not retroactive.
The clip restriction is not recorded in pictures.
-Pass an empty rect to disable maximum clip.
+Pass an empty rect to disable maximum clip.
#Private
This is private API to be used only by Android framework.
@@ -2517,7 +2517,7 @@ void draw(SkCanvas* canvas) {
##
-#Method void clipRRect(const SkRRect& rrect, SkClipOp op)
+#Method void clipRRect(const SkRRect& rrect, SkClipOp op)
#In Clip
Replace Clip with the intersection or difference of Clip and rrect.
@@ -2542,7 +2542,7 @@ void draw(SkCanvas* canvas) {
##
-#Method void clipRRect(const SkRRect& rrect, bool doAntiAlias = false)
+#Method void clipRRect(const SkRRect& rrect, bool doAntiAlias = false)
#In Clip
Replace Clip with the intersection of Clip and rrect,
@@ -2610,7 +2610,7 @@ void draw(SkCanvas* canvas) {
##
-#Method void clipPath(const SkPath& path, SkClipOp op)
+#Method void clipPath(const SkPath& path, SkClipOp op)
#In Clip
Replace Clip with the intersection or difference of Clip and path.
@@ -2627,7 +2627,7 @@ before it is combined with Clip.
#Example
#Description
Overlapping Rects form a clip. When clip Path_Fill_Type is set to
-SkPath::kWinding_FillType, the overlap is included. Set to
+SkPath::kWinding_FillType, the overlap is included. Set to
SkPath::kEvenOdd_FillType, the overlap is excluded and forms a hole.
##
void draw(SkCanvas* canvas) {
@@ -2652,7 +2652,7 @@ void draw(SkCanvas* canvas) {
##
-#Method void clipPath(const SkPath& path, bool doAntiAlias = false)
+#Method void clipPath(const SkPath& path, bool doAntiAlias = false)
#In Clip
Replace Clip with the intersection of Clip and path.
@@ -2668,8 +2668,8 @@ path is transformed by Matrix before it is combined with Clip.
#Example
#Height 212
#Description
-Clip loops over itself covering its center twice. When clip Path_Fill_Type
-is set to SkPath::kWinding_FillType, the overlap is included. Set to
+Clip loops over itself covering its center twice. When clip Path_Fill_Type
+is set to SkPath::kWinding_FillType, the overlap is included. Set to
SkPath::kEvenOdd_FillType, the overlap is excluded and forms a hole.
##
void draw(SkCanvas* canvas) {
@@ -2697,7 +2697,7 @@ void draw(SkCanvas* canvas) {
# ------------------------------------------------------------------------------
-#Method void setAllowSimplifyClip(bool allow)
+#Method void setAllowSimplifyClip(bool allow)
#In Clip
#Line # experimental ##
@@ -2763,8 +2763,8 @@ Use to check if an area to be drawn is clipped out, to skip subsequent draw call
#Example
void draw(SkCanvas* canvas) {
- SkRect testRect = {30, 30, 120, 129 };
- SkRect clipRect = {30, 130, 120, 230 };
+ SkRect testRect = {30, 30, 120, 129 };
+ SkRect clipRect = {30, 130, 120, 230 };
canvas->save();
canvas->clipRect(clipRect);
SkDebugf("quickReject %s\n", canvas->quickReject(testRect) ? "true" : "false");
@@ -2797,8 +2797,8 @@ Use to check if an area to be drawn is clipped out, to skip subsequent draw call
#Example
void draw(SkCanvas* canvas) {
- SkPoint testPoints[] = {{30, 30}, {120, 30}, {120, 129} };
- SkPoint clipPoints[] = {{30, 130}, {120, 130}, {120, 230} };
+ SkPoint testPoints[] = {{30, 30}, {120, 30}, {120, 129} };
+ SkPoint clipPoints[] = {{30, 130}, {120, 130}, {120, 230} };
SkPath testPath, clipPath;
testPath.addPoly(testPoints, SK_ARRAY_COUNT(testPoints), true);
clipPath.addPoly(clipPoints, SK_ARRAY_COUNT(clipPoints), true);
@@ -2820,7 +2820,7 @@ void draw(SkCanvas* canvas) {
##
-#Method SkRect getLocalClipBounds() const
+#Method SkRect getLocalClipBounds() const
#In Clip
#Line # returns Clip bounds in source coordinates ##
@@ -2833,7 +2833,7 @@ is Anti-aliased.
#Return bounds of Clip in local coordinates ##
#Example
- #Description
+ #Description
Initial bounds is device bounds outset by 1 on all sides.
Clipped bounds is clipPath bounds outset by 1 on all sides.
Scaling the canvas by two in x and y scales the local bounds by 1/2 in x and y.
@@ -2843,7 +2843,7 @@ is Anti-aliased.
SkRect bounds = canvas->getLocalClipBounds();
SkDebugf("left:%g top:%g right:%g bottom:%g\n",
bounds.fLeft, bounds.fTop, bounds.fRight, bounds.fBottom);
- SkPoint clipPoints[] = {{30, 130}, {120, 130}, {120, 230} };
+ SkPoint clipPoints[] = {{30, 130}, {120, 130}, {120, 230} };
SkPath clipPath;
clipPath.addPoly(clipPoints, SK_ARRAY_COUNT(clipPoints), true);
canvas->clipPath(clipPath);
@@ -2867,7 +2867,7 @@ is Anti-aliased.
##
-#Method bool getLocalClipBounds(SkRect* bounds) const
+#Method bool getLocalClipBounds(SkRect* bounds) const
#In Clip
Return bounds of Clip, transformed by inverse of Matrix. If Clip is empty,
@@ -2904,14 +2904,14 @@ is Anti-aliased.
##
-#Method SkIRect getDeviceClipBounds() const
+#Method SkIRect getDeviceClipBounds() const
#In Clip
#Line # returns IRect bounds of Clip ##
Return IRect bounds of Clip, unaffected by Matrix. If Clip is empty,
return SkRect::MakeEmpty, where all Rect sides equal zero.
-Unlike getLocalClipBounds, returned IRect is not outset.
+Unlike getLocalClipBounds, returned IRect is not outset.
#Return bounds of Clip in Device coordinates ##
@@ -2927,7 +2927,7 @@ void draw(SkCanvas* canvas) {
SkIRect bounds = canvas->getDeviceClipBounds();
SkDebugf("left:%d top:%d right:%d bottom:%d\n",
bounds.fLeft, bounds.fTop, bounds.fRight, bounds.fBottom);
- SkPoint clipPoints[] = {{30, 130}, {120, 130}, {120, 230} };
+ SkPoint clipPoints[] = {{30, 130}, {120, 130}, {120, 230} };
SkPath clipPath;
clipPath.addPoly(clipPoints, SK_ARRAY_COUNT(clipPoints), true);
canvas->save();
@@ -2957,13 +2957,13 @@ void draw(SkCanvas* canvas) {
##
-#Method bool getDeviceClipBounds(SkIRect* bounds) const
+#Method bool getDeviceClipBounds(SkIRect* bounds) const
#In Clip
Return IRect bounds of Clip, unaffected by Matrix. If Clip is empty,
return false, and set bounds to SkRect::MakeEmpty, where all Rect sides equal zero.
-Unlike getLocalClipBounds, bounds is not outset.
+Unlike getLocalClipBounds, bounds is not outset.
#Param bounds Rect of Clip in device coordinates ##
@@ -3020,10 +3020,10 @@ mode determines how Color_ARGB is combined with destination.
# ------------------------------------------------------------------------------
-#Method void clear(SkColor color)
+#Method void clear(SkColor color)
#In Draw
#Line # fills Clip with Color ##
-Fill Clip with Color color using SkBlendMode::kSrc.
+Fill Clip with Color color using SkBlendMode::kSrc.
This has the effect of replacing all pixels contained by Clip with color.
#Param color Unpremultiplied Color_ARGB ##
@@ -3032,7 +3032,7 @@ This has the effect of replacing all pixels contained by Clip with color.
void draw(SkCanvas* canvas) {
canvas->save();
canvas->clipRect(SkRect::MakeWH(256, 128));
- canvas->clear(SkColorSetARGB(0x80, 0xFF, 0x00, 0x00));
+ canvas->clear(SkColorSetARGB(0x80, 0xFF, 0x00, 0x00));
canvas->restore();
canvas->save();
canvas->clipRect(SkRect::MakeWH(150, 192));
@@ -3049,7 +3049,7 @@ void draw(SkCanvas* canvas) {
# ------------------------------------------------------------------------------
-#Method void discard()
+#Method void discard()
#In Utility
#Line # makes Canvas contents undefined ##
Make Canvas contents undefined. Subsequent calls that read Canvas pixels,
@@ -3067,7 +3067,7 @@ any cached data is deleted when owning Surface or Device is deleted.
#ToDo example? not sure how to make this meaningful w/o more implementation detail ##
#SeeAlso flush() SkSurface::prepareForExternalIO GrContext::abandonContext
-#NoExample
+#NoExample
##
##
@@ -3128,7 +3128,7 @@ an open polygon.
##
#Example
- #Description
+ #Description
The upper left corner shows three squares when drawn as points.
The upper right corner shows one line; when drawn as lines, two points are required per line.
The lower right corner shows two lines; when draw as polygon, no miter is drawn at the corner.
@@ -3172,7 +3172,7 @@ Paint_Stroke_Width.
If mode is kLines_PointMode, each pair of points draws a line segment.
One line is drawn for every two points; each point is used once. If count is odd,
-the final point is ignored.
+the final point is ignored.
If mode is kPolygon_PointMode, each adjacent pair of points draws a line segment.
count minus one lines are drawn; the first and last point are used once.
@@ -3182,7 +3182,7 @@ Paint_Style is ignored, as if were set to SkPaint::kStroke_Style.
Always draws each element one at a time; is not affected by
Paint_Stroke_Join, and unlike drawPath, does not create a mask from all points
-and lines before drawing.
+and lines before drawing.
#Param mode whether pts draws points or lines ##
#Param count number of points in the array ##
@@ -3191,7 +3191,7 @@ and lines before drawing.
#Example
#Height 200
- #Description
+ #Description
#List
# The first column draws points. ##
# The second column draws points as lines. ##
@@ -3211,7 +3211,7 @@ void draw(SkCanvas* canvas) {
paint.setStrokeWidth(10);
paint.setColor(0x80349a45);
const SkPoint points[] = {{32, 16}, {48, 48}, {16, 32}};
- const SkPaint::Join join[] = { SkPaint::kRound_Join,
+ const SkPaint::Join join[] = { SkPaint::kRound_Join,
SkPaint::kMiter_Join,
SkPaint::kBevel_Join };
int joinIndex = 0;
@@ -3245,7 +3245,7 @@ Draw point at (x, y) using Clip, Matrix and Paint paint.
The shape of point drawn depends on paint Paint_Stroke_Cap.
If paint is set to SkPaint::kRound_Cap, draw a circle of diameter
-Paint_Stroke_Width. If paint is set to SkPaint::kSquare_Cap or SkPaint::kButt_Cap,
+Paint_Stroke_Width. If paint is set to SkPaint::kSquare_Cap or SkPaint::kButt_Cap,
draw a square of width and height Paint_Stroke_Width.
Paint_Style is ignored, as if were set to SkPaint::kStroke_Style.
@@ -3279,7 +3279,7 @@ Draw point p using Clip, Matrix and Paint paint.
The shape of point drawn depends on paint Paint_Stroke_Cap.
If paint is set to SkPaint::kRound_Cap, draw a circle of diameter
-Paint_Stroke_Width. If paint is set to SkPaint::kSquare_Cap or SkPaint::kButt_Cap,
+Paint_Stroke_Width. If paint is set to SkPaint::kSquare_Cap or SkPaint::kButt_Cap,
draw a square of width and height Paint_Stroke_Width.
Paint_Style is ignored, as if were set to SkPaint::kStroke_Style.
@@ -3369,7 +3369,7 @@ Paint_Style is ignored, as if were set to SkPaint::kStroke_Style.
#In Draw
#Line # draws Rect using Clip, Matrix, and Paint ##
Draw Rect rect using Clip, Matrix, and Paint paint.
-In paint: Paint_Style determines if rectangle is stroked or filled;
+In paint: Paint_Style determines if rectangle is stroked or filled;
if stroked, Paint_Stroke_Width describes the line thickness, and
Paint_Stroke_Join draws the corners rounded or square.
@@ -3396,17 +3396,17 @@ void draw(SkCanvas* canvas) {
}
##
-#SeeAlso drawIRect drawRRect drawRoundRect drawRegion drawPath drawLine
+#SeeAlso drawIRect drawRRect drawRoundRect drawRegion drawPath drawLine
##
# ------------------------------------------------------------------------------
-#Method void drawIRect(const SkIRect& rect, const SkPaint& paint)
+#Method void drawIRect(const SkIRect& rect, const SkPaint& paint)
#In Draw
#Line # draws IRect using Clip, Matrix, and Paint ##
Draw IRect rect using Clip, Matrix, and Paint paint.
-In paint: Paint_Style determines if rectangle is stroked or filled;
+In paint: Paint_Style determines if rectangle is stroked or filled;
if stroked, Paint_Stroke_Width describes the line thickness, and
Paint_Stroke_Join draws the corners rounded or square.
@@ -3437,7 +3437,7 @@ Paint_Stroke_Join draws the corners rounded or square.
#In Draw
#Line # draws Region using Clip, Matrix, and Paint ##
Draw Region region using Clip, Matrix, and Paint paint.
-In paint: Paint_Style determines if rectangle is stroked or filled;
+In paint: Paint_Style determines if rectangle is stroked or filled;
if stroked, Paint_Stroke_Width describes the line thickness, and
Paint_Stroke_Join draws the corners rounded or square.
@@ -3468,7 +3468,7 @@ void draw(SkCanvas* canvas) {
#In Draw
#Line # draws Oval using Clip, Matrix, and Paint ##
Draw Oval oval using Clip, Matrix, and Paint.
-In paint: Paint_Style determines if Oval is stroked or filled;
+In paint: Paint_Style determines if Oval is stroked or filled;
if stroked, Paint_Stroke_Width describes the line thickness.
#Param oval Rect bounds of Oval ##
@@ -3500,7 +3500,7 @@ void draw(SkCanvas* canvas) {
#In Draw
#Line # draws Round_Rect using Clip, Matrix, and Paint ##
Draw Round_Rect rrect using Clip, Matrix, and Paint paint.
-In paint: Paint_Style determines if rrect is stroked or filled;
+In paint: Paint_Style determines if rrect is stroked or filled;
if stroked, Paint_Stroke_Width describes the line thickness.
rrect may represent a rectangle, circle, oval, uniformly rounded rectangle, or
@@ -3521,11 +3521,11 @@ void draw(SkCanvas* canvas) {
paint.setColor(SK_ColorWHITE);
canvas->drawLine(outer.fLeft + radii.fLeft, outer.fTop,
outer.fLeft + radii.fLeft, outer.fBottom, paint);
- canvas->drawLine(outer.fRight - radii.fRight, outer.fTop,
+ canvas->drawLine(outer.fRight - radii.fRight, outer.fTop,
outer.fRight - radii.fRight, outer.fBottom, paint);
- canvas->drawLine(outer.fLeft, outer.fTop + radii.fTop,
+ canvas->drawLine(outer.fLeft, outer.fTop + radii.fTop,
outer.fRight, outer.fTop + radii.fTop, paint);
- canvas->drawLine(outer.fLeft, outer.fBottom - radii.fBottom,
+ canvas->drawLine(outer.fLeft, outer.fBottom - radii.fBottom,
outer.fRight, outer.fBottom - radii.fBottom, paint);
}
##
@@ -3540,16 +3540,16 @@ void draw(SkCanvas* canvas) {
#In Draw
#Line # draws double Round_Rect stroked or filled ##
Draw Round_Rect outer and inner
-using Clip, Matrix, and Paint paint.
+using Clip, Matrix, and Paint paint.
outer must contain inner or the drawing is undefined.
-In paint: Paint_Style determines if Round_Rect is stroked or filled;
+In paint: Paint_Style determines if Round_Rect is stroked or filled;
if stroked, Paint_Stroke_Width describes the line thickness.
If stroked and Round_Rect corner has zero length radii, Paint_Stroke_Join can
-draw corners rounded or square.
+draw corners rounded or square.
GPU-backed platforms optimize drawing when both outer and inner are
concave and outer contains inner. These platforms may not be able to draw
-Path built with identical data as fast.
+Path built with identical data as fast.
#Param outer Round_Rect outer bounds to draw ##
#Param inner Round_Rect inner bounds to draw ##
@@ -3596,7 +3596,7 @@ void draw(SkCanvas* canvas) {
#Line # draws Circle using Clip, Matrix, and Paint ##
Draw Circle at (cx, cy) with radius using Clip, Matrix, and Paint paint.
If radius is zero or less, nothing is drawn.
-In paint: Paint_Style determines if Circle is stroked or filled;
+In paint: Paint_Style determines if Circle is stroked or filled;
if stroked, Paint_Stroke_Width describes the line thickness.
#Param cx Circle center on the x-axis ##
@@ -3624,7 +3624,7 @@ if stroked, Paint_Stroke_Width describes the line thickness.
Draw Circle at center with radius using Clip, Matrix, and Paint paint.
If radius is zero or less, nothing is drawn.
-In paint: Paint_Style determines if Circle is stroked or filled;
+In paint: Paint_Style determines if Circle is stroked or filled;
if stroked, Paint_Stroke_Width describes the line thickness.
#Param center Circle center ##
@@ -3721,7 +3721,7 @@ If Rect oval is empty or sweepAngle is zero, nothing is drawn.
Draw Round_Rect bounded by Rect rect, with corner radii (rx, ry) using Clip,
Matrix, and Paint paint.
-In paint: Paint_Style determines if Round_Rect is stroked or filled;
+In paint: Paint_Style determines if Round_Rect is stroked or filled;
if stroked, Paint_Stroke_Width describes the line thickness.
If rx or ry are less than zero, they are treated as if they are zero.
If rx plus ry exceeds rect width or rect height, radii are scaled down to fit.
@@ -3782,7 +3782,7 @@ corners are drawn.
#Description
Top rows draw stroked path with combinations of joins and caps. The open contour
is affected by caps; the closed contour is affected by joins.
- Bottom row draws fill the same for open and closed contour.
+ Bottom row draws fill the same for open and closed contour.
First bottom column shows winding fills overlap.
Second bottom column shows even odd fills exclude overlap.
Third bottom column shows inverse winding fills area outside both contours.
@@ -3808,8 +3808,8 @@ void draw(SkCanvas* canvas) {
canvas->translate(-240, 60);
}
paint.setStyle(SkPaint::kFill_Style);
- for (auto fill : { SkPath::kWinding_FillType,
- SkPath::kEvenOdd_FillType,
+ for (auto fill : { SkPath::kWinding_FillType,
+ SkPath::kEvenOdd_FillType,
SkPath::kInverseWinding_FillType } ) {
path.setFillType(fill);
canvas->save();
@@ -3844,7 +3844,7 @@ and Draw_Looper. If image is kAlpha_8_SkColorType, apply Shader.
If paint contains Mask_Filter, generate mask from image bounds. If generated
mask extends beyond image bounds, replicate image edge colors, just as Shader
made from SkImage::makeShader with SkShader::kClamp_TileMode set replicates the
-image edge color when it samples outside of its bounds.
+image edge color when it samples outside of its bounds.
#Param image uncompressed rectangular map of pixels ##
#Param left left side of image ##
@@ -3874,7 +3874,7 @@ void draw(SkCanvas* canvas) {
# ------------------------------------------------------------------------------
#Method void drawImage(const sk_sp<SkImage>& image, SkScalar left, SkScalar top,
- const SkPaint* paint = nullptr)
+ const SkPaint* paint = nullptr)
Draw Image image, with its top-left corner at (left, top),
using Clip, Matrix, and optional Paint paint.
@@ -3884,7 +3884,7 @@ Blend_Mode, and Draw_Looper. If image is kAlpha_8_SkColorType, apply Shader.
If paint contains Mask_Filter, generate mask from image bounds. If generated
mask extends beyond image bounds, replicate image edge colors, just as Shader
made from SkImage::makeShader with SkShader::kClamp_TileMode set replicates the
-image edge color when it samples outside of its bounds.
+image edge color when it samples outside of its bounds.
#Param image uncompressed rectangular map of pixels ##
#Param left left side of image ##
@@ -3917,8 +3917,8 @@ void draw(SkCanvas* canvas) {
#Code
enum SrcRectConstraint {
- kStrict_SrcRectConstraint,
- kFast_SrcRectConstraint,
+ kStrict_SrcRectConstraint,
+ kFast_SrcRectConstraint,
};
##
@@ -3927,7 +3927,7 @@ provided to drawImageRect, trading off speed for precision.
Image_Filter in Paint may sample multiple pixels in the image. Source Rect
restricts the bounds of pixels that may be read. Image_Filter may slow down if
-it cannot read outside the bounds, when sampling near the edge of source Rect.
+it cannot read outside the bounds, when sampling near the edge of source Rect.
SrcRectConstraint specifies whether an Image_Filter is allowed to read pixels
outside source Rect.
@@ -4021,13 +4021,13 @@ improve performance.
with kFast_SrcRectConstraint red bleeds on the edges.
##
void draw(SkCanvas* canvas) {
- uint32_t pixels[][4] = {
+ uint32_t pixels[][4] = {
{ 0xFFFF0000, 0xFFFF0000, 0xFFFF0000, 0xFFFF0000 },
{ 0xFFFF0000, 0xFF000000, 0xFFFFFFFF, 0xFFFF0000 },
{ 0xFFFF0000, 0xFFFFFFFF, 0xFF000000, 0xFFFF0000 },
{ 0xFFFF0000, 0xFFFF0000, 0xFFFF0000, 0xFFFF0000 } };
SkBitmap redBorder;
- redBorder.installPixels(SkImageInfo::MakeN32Premul(4, 4),
+ redBorder.installPixels(SkImageInfo::MakeN32Premul(4, 4),
(void*) pixels, sizeof(pixels[0]));
sk_sp<SkImage> image = SkImage::MakeFromBitmap(redBorder);
SkPaint lowPaint;
@@ -4057,7 +4057,7 @@ void draw(SkCanvas* canvas) {
Draw IRect isrc of Image image, scaled and translated to fill Rect dst.
Note that isrc is on integer pixel boundaries; dst may include fractional
boundaries. Additionally transform draw using Clip, Matrix, and optional Paint
-paint.
+paint.
If Paint paint is supplied, apply Color_Filter, Color_Alpha, Image_Filter,
Blend_Mode, and Draw_Looper. If image is kAlpha_8_SkColorType, apply Shader.
@@ -4084,7 +4084,7 @@ improve performance.
void draw(SkCanvas* canvas) {
// sk_sp<SkImage> image;
for (auto i : { 1, 2, 4, 8 } ) {
- canvas->drawImageRect(image.get(), SkIRect::MakeLTRB(0, 0, 100, 100),
+ canvas->drawImageRect(image.get(), SkIRect::MakeLTRB(0, 0, 100, 100),
SkRect::MakeXYWH(i * 20, i * 20, i * 20, i * 20), nullptr);
}
}
@@ -4141,7 +4141,7 @@ void draw(SkCanvas* canvas) {
#Method void drawImageRect(const sk_sp<SkImage>& image, const SkRect& src, const SkRect& dst,
const SkPaint* paint,
- SrcRectConstraint constraint = kStrict_SrcRectConstraint)
+ SrcRectConstraint constraint = kStrict_SrcRectConstraint)
#In Draw_Image
#In Draw
Draw Rect src of Image image, scaled and translated to fill Rect dst.
@@ -4177,7 +4177,7 @@ void draw(SkCanvas* canvas) {
uint32_t pixels[][2] = { { SK_ColorBLACK, SK_ColorWHITE },
{ SK_ColorWHITE, SK_ColorBLACK } };
SkBitmap bitmap;
- bitmap.installPixels(SkImageInfo::MakeN32Premul(2, 2),
+ bitmap.installPixels(SkImageInfo::MakeN32Premul(2, 2),
(void*) pixels, sizeof(pixels[0]));
sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap);
SkPaint paint;
@@ -4197,7 +4197,7 @@ void draw(SkCanvas* canvas) {
# ------------------------------------------------------------------------------
#Method void drawImageRect(const sk_sp<SkImage>& image, const SkIRect& isrc, const SkRect& dst,
- const SkPaint* paint, SrcRectConstraint constraint = kStrict_SrcRectConstraint)
+ const SkPaint* paint, SrcRectConstraint constraint = kStrict_SrcRectConstraint)
#In Draw_Image
#In Draw
Draw IRect isrc of Image image, scaled and translated to fill Rect dst.
@@ -4230,7 +4230,7 @@ void draw(SkCanvas* canvas) {
uint32_t pixels[][2] = { { 0x00000000, 0x55555555},
{ 0xAAAAAAAA, 0xFFFFFFFF} };
SkBitmap bitmap;
- bitmap.installPixels(SkImageInfo::MakeN32Premul(2, 2),
+ bitmap.installPixels(SkImageInfo::MakeN32Premul(2, 2),
(void*) pixels, sizeof(pixels[0]));
sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap);
SkPaint paint;
@@ -4250,7 +4250,7 @@ void draw(SkCanvas* canvas) {
# ------------------------------------------------------------------------------
#Method void drawImageRect(const sk_sp<SkImage>& image, const SkRect& dst, const SkPaint* paint,
- SrcRectConstraint constraint = kStrict_SrcRectConstraint)
+ SrcRectConstraint constraint = kStrict_SrcRectConstraint)
#In Draw_Image
#In Draw
Draw Image image, scaled and translated to fill Rect dst,
@@ -4281,7 +4281,7 @@ void draw(SkCanvas* canvas) {
uint32_t pixels[][2] = { { 0x00000000, 0x55550000},
{ 0xAAAA0000, 0xFFFF0000} };
SkBitmap bitmap;
- bitmap.installPixels(SkImageInfo::MakeN32Premul(2, 2),
+ bitmap.installPixels(SkImageInfo::MakeN32Premul(2, 2),
(void*) pixels, sizeof(pixels[0]));
sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap);
SkPaint paint;
@@ -4352,7 +4352,7 @@ void draw(SkCanvas* canvas) {
gray += 0x001f1f1f;
top = bottom;
}
- left = right;
+ left = right;
}
sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap);
SkImage* imagePtr = image.get();
@@ -4370,7 +4370,7 @@ void draw(SkCanvas* canvas) {
# ------------------------------------------------------------------------------
#Method void drawImageNine(const sk_sp<SkImage>& image, const SkIRect& center, const SkRect& dst,
- const SkPaint* paint = nullptr)
+ const SkPaint* paint = nullptr)
#In Draw_Image
#In Draw
Draw Image image stretched proportionally to fit into Rect dst.
@@ -4400,7 +4400,7 @@ replicates the image edge color when it samples outside of its bounds.
#Description
The two leftmost images has four corners and sides to the left and right of center.
The leftmost image scales the width of corners proportionately to fit.
- The third and fourth image corners are not scaled; the sides and center are scaled to
+ The third and fourth image corners are not scaled; the sides and center are scaled to
fill the remaining space.
The rightmost image has four corners scaled vertically to fit, and uses sides above
and below center to fill the remaining space.
@@ -4421,7 +4421,7 @@ void draw(SkCanvas* canvas) {
gray += 0x001f1f1f;
top = bottom;
}
- left = right;
+ left = right;
}
sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap);
for (auto dest: { 20, 30, 40, 60, 90 } ) {
@@ -4453,7 +4453,7 @@ If paint contains Mask_Filter, generate mask from bitmap bounds.
If generated mask extends beyond bitmap bounds, replicate bitmap edge colors,
just as Shader made from SkShader::MakeBitmapShader with
SkShader::kClamp_TileMode set replicates the bitmap edge color when it samples
-outside of its bounds.
+outside of its bounds.
#Param bitmap Bitmap containing pixels, dimensions, and format ##
#Param left left side of bitmap ##
@@ -4474,7 +4474,7 @@ void draw(SkCanvas* canvas) {
{ 0x00, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0x00},
{ 0xFF, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0xFF} };
SkBitmap bitmap;
- bitmap.installPixels(SkImageInfo::MakeA8(8, 8),
+ bitmap.installPixels(SkImageInfo::MakeA8(8, 8),
(void*) pixels, sizeof(pixels[0]));
SkPaint paint;
canvas->scale(4, 4);
@@ -4534,7 +4534,7 @@ void draw(SkCanvas* canvas) {
{ 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00},
{ 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00} };
SkBitmap bitmap;
- bitmap.installPixels(SkImageInfo::MakeA8(8, 8),
+ bitmap.installPixels(SkImageInfo::MakeA8(8, 8),
(void*) pixels, sizeof(pixels[0]));
SkPaint paint;
paint.setMaskFilter(SkMaskFilter::MakeBlur(kSolid_SkBlurStyle, 6));
@@ -4593,7 +4593,7 @@ void draw(SkCanvas* canvas) {
{ 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00},
{ 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00} };
SkBitmap bitmap;
- bitmap.installPixels(SkImageInfo::MakeA8(8, 8),
+ bitmap.installPixels(SkImageInfo::MakeA8(8, 8),
(void*) pixels, sizeof(pixels[0]));
SkPaint paint;
paint.setFilterQuality(kHigh_SkFilterQuality);
@@ -4645,7 +4645,7 @@ void draw(SkCanvas* canvas) {
uint32_t pixels[][2] = { { 0x00000000, 0x55550000},
{ 0xAAAA0000, 0xFFFF0000} };
SkBitmap bitmap;
- bitmap.installPixels(SkImageInfo::MakeN32Premul(2, 2),
+ bitmap.installPixels(SkImageInfo::MakeN32Premul(2, 2),
(void*) pixels, sizeof(pixels[0]));
SkPaint paint;
canvas->scale(4, 4);
@@ -4698,7 +4698,7 @@ outside of its bounds.
#Description
The two leftmost bitmap draws has four corners and sides to the left and right of center.
The leftmost bitmap draw scales the width of corners proportionately to fit.
- The third and fourth draw corners are not scaled; the sides and center are scaled to
+ The third and fourth draw corners are not scaled; the sides and center are scaled to
fill the remaining space.
The rightmost bitmap draw has four corners scaled vertically to fit, and uses sides above
and below center to fill the remaining space.
@@ -4719,7 +4719,7 @@ void draw(SkCanvas* canvas) {
gray += 0x001f1f1f;
top = bottom;
}
- left = right;
+ left = right;
}
for (auto dest: { 20, 30, 40, 60, 90 } ) {
canvas->drawBitmapNine(bitmap, center, SkRect::MakeWH(dest, 110 - dest), nullptr);
@@ -4878,7 +4878,7 @@ outside of its bounds.
#Description
The two leftmost bitmap draws has four corners and sides to the left and right of center.
The leftmost bitmap draw scales the width of corners proportionately to fit.
- The third and fourth draw corners are not scaled; the sides are scaled to
+ The third and fourth draw corners are not scaled; the sides are scaled to
fill the remaining space; the center is transparent.
The rightmost bitmap draw has four corners scaled vertically to fit, and uses sides above
and below center to fill the remaining space.
@@ -4899,7 +4899,7 @@ void draw(SkCanvas* canvas) {
gray += 0x001f1f1f;
top = bottom;
}
- left = right;
+ left = right;
}
const int xDivs[] = { center.fLeft, center.fRight };
const int yDivs[] = { center.fTop, center.fBottom };
@@ -4978,7 +4978,7 @@ void draw(SkCanvas* canvas) {
gray += 0x001f1f1f;
top = bottom;
}
- left = right;
+ left = right;
}
sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap);
SkImage* imagePtr = image.get();
@@ -5014,7 +5014,7 @@ UTF-8.
x and y meaning depends on Paint_Text_Align and Paint_Vertical_Text; by default
text draws left to right, positioning the first glyph left side bearing at x
-and its baseline at y. Text size is affected by Matrix and Paint_Text_Size.
+and its baseline at y. Text size is affected by Matrix and Paint_Text_Size.
All elements of paint: Path_Effect, Mask_Filter, Shader,
Color_Filter, Image_Filter, and Draw_Looper; apply to text. By default, draws
@@ -5030,7 +5030,7 @@ filled 12 point black Glyphs.
#Height 200
#Description
The same text is drawn varying Paint_Text_Size and varying
- Matrix.
+ Matrix.
##
void draw(SkCanvas* canvas) {
SkPaint paint;
@@ -5050,7 +5050,7 @@ void draw(SkCanvas* canvas) {
canvas->translate(100, 0);
canvas->scale(scale, scale);
canvas->drawText("Aa", 2, 10 / scale, yPos / scale, paint);
- yPos += size * 2;
+ yPos += size * 2;
}
}
##
@@ -5073,7 +5073,7 @@ results, since zero bytes may be embedded in the string.
x and y meaning depends on Paint_Text_Align and Paint_Vertical_Text; by default
string draws left to right, positioning the first glyph left side bearing at x
-and its baseline at y. Text size is affected by Matrix and Paint_Text_Size.
+and its baseline at y. Text size is affected by Matrix and Paint_Text_Size.
All elements of paint: Path_Effect, Mask_Filter, Shader,
Color_Filter, Image_Filter, and Draw_Looper; apply to text. By default, draws
@@ -5106,7 +5106,7 @@ results, since zero bytes may be embedded in the string.
x and y meaning depends on Paint_Text_Align and Paint_Vertical_Text; by default
string draws left to right, positioning the first glyph left side bearing at x
-and its baseline at y. Text size is affected by Matrix and Paint_Text_Size.
+and its baseline at y. Text size is affected by Matrix and Paint_Text_Size.
All elements of paint: Path_Effect, Mask_Filter, Shader,
Color_Filter, Image_Filter, and Draw_Looper; apply to text. By default, draws
@@ -5145,7 +5145,7 @@ text meaning depends on Paint_Text_Encoding; by default, text is encoded as
UTF-8. pos elements' meaning depends on Paint_Text_Align and Paint_Vertical_Text;
by default each glyph left side bearing is positioned at x and its
baseline is positioned at y. Text size is affected by Matrix and
-Paint_Text_Size.
+Paint_Text_Size.
All elements of paint: Path_Effect, Mask_Filter, Shader,
Color_Filter, Image_Filter, and Draw_Looper; apply to text. By default, draws
@@ -5191,7 +5191,7 @@ text meaning depends on Paint_Text_Encoding; by default, text is encoded as
UTF-8. xpos elements' meaning depends on Paint_Text_Align and Paint_Vertical_Text;
by default each glyph left side bearing is positioned at an xpos element and
its baseline is positioned at constY. Text size is affected by Matrix and
-Paint_Text_Size.
+Paint_Text_Size.
All elements of paint: Path_Effect, Mask_Filter, Shader,
Color_Filter, Image_Filter, and Draw_Looper; apply to text. By default, draws
@@ -5239,7 +5239,7 @@ than the path length, the excess text is clipped.
text meaning depends on Paint_Text_Encoding; by default, text is encoded as
UTF-8. Origin meaning depends on Paint_Text_Align and Paint_Vertical_Text; by
default text positions the first glyph left side bearing at origin x and its
-baseline at origin y. Text size is affected by Matrix and Paint_Text_Size.
+baseline at origin y. Text size is affected by Matrix and Paint_Text_Size.
All elements of paint: Path_Effect, Mask_Filter, Shader,
Color_Filter, Image_Filter, and Draw_Looper; apply to text. By default, draws
@@ -5253,7 +5253,7 @@ filled 12 point black Glyphs.
#Param paint text size, blend, color, and so on, used to draw ##
#Example
- void draw(SkCanvas* canvas) {
+ void draw(SkCanvas* canvas) {
const char aero[] = "correo a" "\xC3" "\xA9" "reo";
const size_t len = sizeof(aero) - 1;
SkPath path;
@@ -5290,7 +5290,7 @@ than the path length, the excess text is clipped.
text meaning depends on Paint_Text_Encoding; by default, text is encoded as
UTF-8. Origin meaning depends on Paint_Text_Align and Paint_Vertical_Text; by
default text positions the first glyph left side bearing at origin x and its
-baseline at origin y. Text size is affected by Matrix and Paint_Text_Size.
+baseline at origin y. Text size is affected by Matrix and Paint_Text_Size.
All elements of paint: Path_Effect, Mask_Filter, Shader,
Color_Filter, Image_Filter, and Draw_Looper; apply to text. By default, draws
@@ -5305,7 +5305,7 @@ filled 12 point black Glyphs.
#Param paint text size, blend, color, and so on, used to draw ##
#Example
- void draw(SkCanvas* canvas) {
+ void draw(SkCanvas* canvas) {
const char roller[] = "rollercoaster";
const size_t len = sizeof(roller) - 1;
SkPath path;
@@ -5339,7 +5339,7 @@ filled 12 point black Glyphs.
Draw text, transforming each glyph by the corresponding SkRSXform,
using Clip, Matrix, and Paint paint.
-RSXform array specifies a separate square scale, rotation, and translation for
+RSXform array specifies a separate square scale, rotation, and translation for
each glyph.
Optional Rect cullRect is a conservative bounds of text, taking into account
@@ -5356,7 +5356,7 @@ filled 12 point black Glyphs.
#Param paint text size, blend, color, and so on, used to draw ##
#Example
-void draw(SkCanvas* canvas) {
+void draw(SkCanvas* canvas) {
const int iterations = 26;
SkRSXform transforms[iterations];
char alphabet[iterations];
@@ -5420,7 +5420,7 @@ Image_Filter, and Draw_Looper; apply to blob.
int glyphIndex = 0;
for (auto runLen : runs) {
paint.setTextSize(1 == runLen ? 20 : 50);
- const SkTextBlobBuilder::RunBuffer& run =
+ const SkTextBlobBuilder::RunBuffer& run =
textBlobBuilder.allocRun(paint, runLen, textPos.fX, textPos.fY);
memcpy(run.glyphs, &glyphs[glyphIndex], sizeof(glyphs[0]) * runLen);
textPos.fX += paint.measureText(&glyphs[glyphIndex], sizeof(glyphs[0]) * runLen, nullptr);
@@ -5438,7 +5438,7 @@ Image_Filter, and Draw_Looper; apply to blob.
# ------------------------------------------------------------------------------
-#Method void drawTextBlob(const sk_sp<SkTextBlob>& blob, SkScalar x, SkScalar y, const SkPaint& paint)
+#Method void drawTextBlob(const sk_sp<SkTextBlob>& blob, SkScalar x, SkScalar y, const SkPaint& paint)
Draw Text_Blob blob at (x, y), using Clip, Matrix, and Paint paint.
@@ -5450,7 +5450,7 @@ Subpixel_Text, and Paint_Vertical_Text.
Paint_Text_Encoding must be set to SkPaint::kGlyphID_TextEncoding.
-Elements of paint: Path_Effect, Mask_Filter, Shader, Color_Filter,
+Elements of paint: Path_Effect, Mask_Filter, Shader, Color_Filter,
Image_Filter, and Draw_Looper; apply to blob.
#Param blob Glyphs, positions, and their paints' text size, typeface, and so on ##
@@ -5470,7 +5470,7 @@ Paint attributes related to text, like text size, have no effect on paint passed
paint.setTextSize(50);
paint.setColor(SK_ColorRED);
paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
- const SkTextBlobBuilder::RunBuffer& run =
+ const SkTextBlobBuilder::RunBuffer& run =
textBlobBuilder.allocRun(paint, 1, 20, 100);
run.glyphs[0] = 20;
sk_sp<const SkTextBlob> blob = textBlobBuilder.make();
@@ -5486,7 +5486,7 @@ Paint attributes related to text, like text size, have no effect on paint passed
# ------------------------------------------------------------------------------
-#Method void drawPicture(const SkPicture* picture)
+#Method void drawPicture(const SkPicture* picture)
#In Draw
#Line # draws Picture using Clip and Matrix ##
Draw Picture picture, using Clip and Matrix.
@@ -5498,7 +5498,7 @@ Picture records a series of draw commands for later playback.
#Param picture recorded drawing commands to play ##
#Example
-void draw(SkCanvas* canvas) {
+void draw(SkCanvas* canvas) {
SkPictureRecorder recorder;
SkCanvas* recordingCanvas = recorder.beginRecording(50, 50);
for (auto color : { SK_ColorRED, SK_ColorBLUE, 0xff007f00 } ) {
@@ -5522,7 +5522,7 @@ void draw(SkCanvas* canvas) {
# ------------------------------------------------------------------------------
-#Method void drawPicture(const sk_sp<SkPicture>& picture)
+#Method void drawPicture(const sk_sp<SkPicture>& picture)
Draw Picture picture, using Clip and Matrix.
Clip and Matrix are unchanged by picture contents, as if
@@ -5533,7 +5533,7 @@ Picture records a series of draw commands for later playback.
#Param picture recorded drawing commands to play ##
#Example
-void draw(SkCanvas* canvas) {
+void draw(SkCanvas* canvas) {
SkPictureRecorder recorder;
SkCanvas* recordingCanvas = recorder.beginRecording(50, 50);
for (auto color : { SK_ColorRED, SK_ColorBLUE, 0xff007f00 } ) {
@@ -5571,7 +5571,7 @@ paint use is equivalent to: saveLayer, drawPicture, restore().
#Param paint Paint to apply transparency, filtering, and so on; may be nullptr ##
#Example
-void draw(SkCanvas* canvas) {
+void draw(SkCanvas* canvas) {
SkPaint paint;
SkPictureRecorder recorder;
SkCanvas* recordingCanvas = recorder.beginRecording(50, 50);
@@ -5599,7 +5599,7 @@ void draw(SkCanvas* canvas) {
# ------------------------------------------------------------------------------
-#Method void drawPicture(const sk_sp<SkPicture>& picture, const SkMatrix* matrix, const SkPaint* paint)
+#Method void drawPicture(const sk_sp<SkPicture>& picture, const SkMatrix* matrix, const SkPaint* paint)
Draw Picture picture, using Clip and Matrix; transforming picture with
Matrix matrix, if provided; and use Paint paint Color_Alpha, Color_Filter,
@@ -5613,7 +5613,7 @@ paint use is equivalent to: saveLayer, drawPicture, restore().
#Param paint Paint to apply transparency, filtering, and so on; may be nullptr ##
#Example
-void draw(SkCanvas* canvas) {
+void draw(SkCanvas* canvas) {
SkPaint paint;
SkPictureRecorder recorder;
SkCanvas* recordingCanvas = recorder.beginRecording(50, 50);
@@ -5703,7 +5703,7 @@ void draw(SkCanvas* canvas) {
#In Draw
#Line # draws Coons_Patch ##
-Draws a Coons_Patch: the interpolation of four cubics with shared corners,
+Draws a Coons_Patch: the interpolation of four cubics with shared corners,
associating a color, and optionally a texture coordinate, with each corner.
Coons_Patch uses Clip and Matrix, paint Shader, Color_Filter,
@@ -5711,7 +5711,7 @@ Color_Alpha, Image_Filter, and Blend_Mode. If Shader is provided it is treated
as Coons_Patch texture; Blend_Mode mode combines Color colors and Shader if
both are provided.
-Point array cubics specifies four Cubics starting at the top-left corner,
+Point array cubics specifies four Cubics starting at the top-left corner,
in clockwise order, sharing every fourth point. The last Cubic ends at the
first point.
@@ -5724,7 +5724,7 @@ corners in top-left, top-right, bottom-right, bottom-left order.
#Param cubics Path_Cubic array, sharing common points ##
#Param colors Color array, one for each corner ##
#Param texCoords Point array of texture coordinates, mapping Shader to corners;
- may be nullptr
+ may be nullptr
#Param ##
#Param mode Blend_Mode for colors, and for Shader if paint has one ##
#Param paint Shader, Color_Filter, Blend_Mode, used to draw ##
@@ -5760,9 +5760,9 @@ void draw(SkCanvas* canvas) {
# ------------------------------------------------------------------------------
#Method void drawPatch(const SkPoint cubics[12], const SkColor colors[4],
- const SkPoint texCoords[4], const SkPaint& paint)
+ const SkPoint texCoords[4], const SkPaint& paint)
-Draws Cubic Coons_Patch: the interpolation of four cubics with shared corners,
+Draws Cubic Coons_Patch: the interpolation of four cubics with shared corners,
associating a color, and optionally a texture coordinate, with each corner.
Coons_Patch uses Clip and Matrix, paint Shader, Color_Filter,
@@ -5770,7 +5770,7 @@ Color_Alpha, Image_Filter, and Blend_Mode. If Shader is provided it is treated
as Coons_Patch texture; Blend_Mode mode combines Color colors and Shader if
both are provided.
-Point array cubics specifies four Cubics starting at the top-left corner,
+Point array cubics specifies four Cubics starting at the top-left corner,
in clockwise order, sharing every fourth point. The last Cubic ends at the
first point.
@@ -5783,7 +5783,7 @@ corners in top-left, top-right, bottom-right, bottom-left order.
#Param cubics Path_Cubic array, sharing common points ##
#Param colors Color array, one for each corner ##
#Param texCoords Point array of texture coordinates, mapping Shader to corners;
- may be nullptr
+ may be nullptr
#Param ##
#Param paint Shader, Color_Filter, Blend_Mode, used to draw ##
@@ -5854,7 +5854,7 @@ atlas, and RSXform xform transforms it into destination space.
xform, text, and colors if present, must contain count entries.
Optional colors are applied for each sprite using Blend_Mode.
-Optional cullRect is a conservative bounds of all transformed sprites.
+Optional cullRect is a conservative bounds of all transformed sprites.
If cullRect is outside of Clip, canvas can skip drawing.
#Param atlas Image containing sprites ##
@@ -5886,7 +5886,7 @@ void draw(SkCanvas* canvas) {
#Method void drawAtlas(const sk_sp<SkImage>& atlas, const SkRSXform xform[], const SkRect tex[],
const SkColor colors[], int count, SkBlendMode mode, const SkRect* cullRect,
- const SkPaint* paint)
+ const SkPaint* paint)
Draw a set of sprites from atlas, using Clip, Matrix, and optional Paint paint.
paint uses Anti-alias, Color_Alpha, Color_Filter, Image_Filter, and Blend_Mode
@@ -5895,7 +5895,7 @@ atlas, and RSXform xform transforms it into destination space.
xform, text, and colors if present, must contain count entries.
Optional colors is applied for each sprite using Blend_Mode.
-Optional cullRect is a conservative bounds of all transformed sprites.
+Optional cullRect is a conservative bounds of all transformed sprites.
If cullRect is outside of Clip, canvas can skip drawing.
#Param atlas Image containing sprites ##
@@ -5929,7 +5929,7 @@ void draw(SkCanvas* canvas) {
# ------------------------------------------------------------------------------
#Method void drawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect tex[], int count,
- const SkRect* cullRect, const SkPaint* paint)
+ const SkRect* cullRect, const SkPaint* paint)
Draw a set of sprites from atlas, using Clip, Matrix, and optional Paint paint.
paint uses Anti-alias, Color_Alpha, Color_Filter, Image_Filter, and Blend_Mode
@@ -5937,7 +5937,7 @@ to draw, if present. For each entry in the array, Rect tex locates sprite in
atlas, and RSXform xform transforms it into destination space.
xform and text must contain count entries.
-Optional cullRect is a conservative bounds of all transformed sprites.
+Optional cullRect is a conservative bounds of all transformed sprites.
If cullRect is outside of Clip, canvas can skip drawing.
#Param atlas Image containing sprites ##
@@ -5965,7 +5965,7 @@ void draw(SkCanvas* canvas) {
# ------------------------------------------------------------------------------
#Method void drawAtlas(const sk_sp<SkImage>& atlas, const SkRSXform xform[], const SkRect tex[],
- int count, const SkRect* cullRect, const SkPaint* paint)
+ int count, const SkRect* cullRect, const SkPaint* paint)
Draw a set of sprites from atlas, using Clip, Matrix, and optional Paint paint.
paint uses Anti-alias, Color_Alpha, Color_Filter, Image_Filter, and Blend_Mode
@@ -5973,7 +5973,7 @@ to draw, if present. For each entry in the array, Rect tex locates sprite in
atlas, and RSXform xform transforms it into destination space.
xform and text must contain count entries.
-Optional cullRect is a conservative bounds of all transformed sprites.
+Optional cullRect is a conservative bounds of all transformed sprites.
If cullRect is outside of Clip, canvas can skip drawing.
#Param atlas Image containing sprites ##
@@ -6002,10 +6002,10 @@ void draw(SkCanvas* canvas) {
#Method void drawDrawable(SkDrawable* drawable, const SkMatrix* matrix = nullptr)
#In Draw
#Line # draws Drawable, encapsulated drawing commands ##
-Draw Drawable drawable using Clip and Matrix, concatenated with
+Draw Drawable drawable using Clip and Matrix, concatenated with
optional matrix.
-If Canvas has an asynchronous implementation, as is the case
+If Canvas has an asynchronous implementation, as is the case
when it is recording into Picture, then drawable will be referenced,
so that SkDrawable::draw() can be called when the operation is finalized. To force
immediate drawing, call SkDrawable::draw() instead.
@@ -6050,7 +6050,7 @@ void draw(SkCanvas* canvas) {
Draw Drawable drawable using Clip and Matrix, offset by (x, y).
-If Canvas has an asynchronous implementation, as is the case
+If Canvas has an asynchronous implementation, as is the case
when it is recording into Picture, then drawable will be referenced,
so that SkDrawable::draw() can be called when the operation is finalized. To force
immediate drawing, call SkDrawable::draw() instead.
@@ -6097,7 +6097,7 @@ void draw(SkCanvas* canvas) {
Associate Rect on Canvas with an annotation; a key-value pair, where the key is
a null-terminated utf8 string, and optional value is stored as Data.
-Only some canvas implementations, such as recording to Picture, or drawing to
+Only some canvas implementations, such as recording to Picture, or drawing to
Document_PDF, use annotations.
#Param rect Rect extent of canvas to annotate ##
@@ -6122,12 +6122,12 @@ Document_PDF, use annotations.
# ------------------------------------------------------------------------------
-#Method void drawAnnotation(const SkRect& rect, const char key[], const sk_sp<SkData>& value)
+#Method void drawAnnotation(const SkRect& rect, const char key[], const sk_sp<SkData>& value)
Associate Rect on Canvas when an annotation; a key-value pair, where the key is
a null-terminated utf8 string, and optional value is stored as Data.
-Only some canvas implementations, such as recording to Picture, or drawing to
+Only some canvas implementations, such as recording to Picture, or drawing to
Document_PDF, use annotations.
#Param rect Rect extent of canvas to annotate ##
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index f32fd0535c..12f1926844 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -155,7 +155,7 @@ public:
/** To be deprecated soon.
*/
- explicit SkCanvas(SkBaseDevice* device);
+ explicit SkCanvas(sk_sp<SkBaseDevice> device);
/** Construct a canvas that draws into bitmap.
Sets SkSurfaceProps::kLegacyFontHost_InitType in constructed SkSurface.
@@ -2689,7 +2689,7 @@ protected:
// For use by SkNoDrawCanvas (via SkCanvasVirtualEnforcer, which can't be a friend)
SkCanvas(const SkIRect& bounds, InitFlags);
private:
- SkCanvas(SkBaseDevice* device, InitFlags);
+ SkCanvas(sk_sp<SkBaseDevice> device, InitFlags);
SkCanvas(const SkBitmap&, std::unique_ptr<SkRasterHandleAllocator>,
SkRasterHandleAllocator::Handle);
@@ -2703,7 +2703,7 @@ private:
// - internalSaveLayer
void setupDevice(SkBaseDevice*);
- SkBaseDevice* init(SkBaseDevice*, InitFlags);
+ void init(sk_sp<SkBaseDevice>, InitFlags);
/**
* Gets the bounds of the top level layer in global canvas coordinates. We don't want this
diff --git a/include/utils/SkNoDrawCanvas.h b/include/utils/SkNoDrawCanvas.h
index 4c67226946..518d090786 100644
--- a/include/utils/SkNoDrawCanvas.h
+++ b/include/utils/SkNoDrawCanvas.h
@@ -29,7 +29,7 @@ public:
// TODO: investigate the users of this ctor.
SkNoDrawCanvas(const SkIRect&);
- explicit SkNoDrawCanvas(SkBaseDevice* device);
+ explicit SkNoDrawCanvas(sk_sp<SkBaseDevice> device);
// Optimization to reset state to be the same as after construction.
void resetCanvas(int width, int height) {
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 0a718f2063..82237cf823 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -557,7 +557,7 @@ void SkCanvas::resetForNextPicture(const SkIRect& bounds) {
fIsScaleTranslate = true;
}
-SkBaseDevice* SkCanvas::init(SkBaseDevice* device, InitFlags flags) {
+void SkCanvas::init(sk_sp<SkBaseDevice> device, InitFlags flags) {
if (device && device->forceConservativeRasterClip()) {
flags = InitFlags(flags | kConservativeRasterClip_InitFlag);
}
@@ -573,7 +573,7 @@ SkBaseDevice* SkCanvas::init(SkBaseDevice* device, InitFlags flags) {
SkASSERT(sizeof(DeviceCM) <= sizeof(fDeviceCMStorage));
fMCRec->fLayer = (DeviceCM*)fDeviceCMStorage;
- new (fDeviceCMStorage) DeviceCM(sk_ref_sp(device), nullptr, fMCRec->fMatrix, nullptr, nullptr);
+ new (fDeviceCMStorage) DeviceCM(device, nullptr, fMCRec->fMatrix, nullptr, nullptr);
fMCRec->fTopLayer = fMCRec->fLayer;
@@ -587,8 +587,6 @@ SkBaseDevice* SkCanvas::init(SkBaseDevice* device, InitFlags flags) {
device->androidFramework_setDeviceClipRestriction(&fClipRestrictionRect);
}
-
- return device;
}
SkCanvas::SkCanvas()
@@ -605,9 +603,8 @@ SkCanvas::SkCanvas(int width, int height, const SkSurfaceProps* props)
, fProps(SkSurfacePropsCopyOrDefault(props))
{
inc_canvas();
-
- this->init(new SkNoPixelsDevice(SkIRect::MakeWH(SkTMax(width, 0), SkTMax(height, 0)), fProps),
- kDefault_InitFlags)->unref();
+ this->init(sk_make_sp<SkNoPixelsDevice>(
+ SkIRect::MakeWH(SkTMax(width, 0), SkTMax(height, 0)), fProps), kDefault_InitFlags);
}
SkCanvas::SkCanvas(const SkIRect& bounds, InitFlags flags)
@@ -617,10 +614,10 @@ SkCanvas::SkCanvas(const SkIRect& bounds, InitFlags flags)
inc_canvas();
SkIRect r = bounds.isEmpty() ? SkIRect::MakeEmpty() : bounds;
- this->init(new SkNoPixelsDevice(r, fProps), flags)->unref();
+ this->init(sk_make_sp<SkNoPixelsDevice>(r, fProps), flags);
}
-SkCanvas::SkCanvas(SkBaseDevice* device)
+SkCanvas::SkCanvas(sk_sp<SkBaseDevice> device)
: fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage))
, fProps(device->surfaceProps())
{
@@ -629,7 +626,7 @@ SkCanvas::SkCanvas(SkBaseDevice* device)
this->init(device, kDefault_InitFlags);
}
-SkCanvas::SkCanvas(SkBaseDevice* device, InitFlags flags)
+SkCanvas::SkCanvas(sk_sp<SkBaseDevice> device, InitFlags flags)
: fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage))
, fProps(device->surfaceProps())
{
@@ -645,7 +642,7 @@ SkCanvas::SkCanvas(const SkBitmap& bitmap, const SkSurfaceProps& props)
inc_canvas();
sk_sp<SkBaseDevice> device(new SkBitmapDevice(bitmap, fProps, nullptr, nullptr));
- this->init(device.get(), kDefault_InitFlags);
+ this->init(device, kDefault_InitFlags);
}
SkCanvas::SkCanvas(const SkBitmap& bitmap, std::unique_ptr<SkRasterHandleAllocator> alloc,
@@ -657,7 +654,7 @@ SkCanvas::SkCanvas(const SkBitmap& bitmap, std::unique_ptr<SkRasterHandleAllocat
inc_canvas();
sk_sp<SkBaseDevice> device(new SkBitmapDevice(bitmap, fProps, hndl, nullptr));
- this->init(device.get(), kDefault_InitFlags);
+ this->init(device, kDefault_InitFlags);
}
SkCanvas::SkCanvas(const SkBitmap& bitmap) : SkCanvas(bitmap, nullptr, nullptr) {}
@@ -673,7 +670,7 @@ SkCanvas::SkCanvas(const SkBitmap& bitmap, ColorBehavior)
SkBitmap tmp(bitmap);
*const_cast<SkImageInfo*>(&tmp.info()) = tmp.info().makeColorSpace(nullptr);
sk_sp<SkBaseDevice> device(new SkBitmapDevice(tmp, fProps, nullptr, nullptr));
- this->init(device.get(), kDefault_InitFlags);
+ this->init(device, kDefault_InitFlags);
}
#endif
@@ -2869,7 +2866,7 @@ SkNoDrawCanvas::SkNoDrawCanvas(int width, int height)
SkNoDrawCanvas::SkNoDrawCanvas(const SkIRect& bounds)
: INHERITED(bounds, kConservativeRasterClip_InitFlag) {}
-SkNoDrawCanvas::SkNoDrawCanvas(SkBaseDevice *device)
+SkNoDrawCanvas::SkNoDrawCanvas(sk_sp<SkBaseDevice> device)
: INHERITED(device) {}
SkCanvas::SaveLayerStrategy SkNoDrawCanvas::getSaveLayerStrategy(const SaveLayerRec& rec) {
diff --git a/src/core/SkRemoteGlyphCache.cpp b/src/core/SkRemoteGlyphCache.cpp
index ed484dd6fd..63c3fe9eb9 100644
--- a/src/core/SkRemoteGlyphCache.cpp
+++ b/src/core/SkRemoteGlyphCache.cpp
@@ -188,7 +188,7 @@ SkTextBlobCacheDiffCanvas::SkTextBlobCacheDiffCanvas(
const SkSurfaceProps& props,
SkScalerContextFlags flags,
SkStrikeCacheDifferenceSpec* strikeDiffs)
- : SkNoDrawCanvas{new TrackLayerDevice{SkIRect::MakeWH(width, height), props}}
+ : SkNoDrawCanvas{sk_make_sp<TrackLayerDevice>(SkIRect::MakeWH(width, height), props)}
, fDeviceMatrix{deviceMatrix}
, fSurfaceProps{props}
, fScalerContextFlags{flags}
diff --git a/src/core/SkSpecialSurface.cpp b/src/core/SkSpecialSurface.cpp
index 19a149fe45..f7cddcdf91 100644
--- a/src/core/SkSpecialSurface.cpp
+++ b/src/core/SkSpecialSurface.cpp
@@ -133,7 +133,7 @@ public:
return;
}
- fCanvas.reset(new SkCanvas(device.get()));
+ fCanvas.reset(new SkCanvas(device));
fCanvas->clipRect(SkRect::Make(subset));
#ifdef SK_IS_BOT
fCanvas->clear(SK_ColorRED); // catch any imageFilter sloppiness
diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp
index 21ed1f90eb..b47cfbcf7a 100644
--- a/src/image/SkSurface_Gpu.cpp
+++ b/src/image/SkSurface_Gpu.cpp
@@ -100,7 +100,7 @@ SkCanvas* SkSurface_Gpu::onNewCanvas() {
SkCanvas::InitFlags flags = SkCanvas::kDefault_InitFlags;
flags = static_cast<SkCanvas::InitFlags>(flags | SkCanvas::kConservativeRasterClip_InitFlag);
- return new SkCanvas(fDevice.get(), flags);
+ return new SkCanvas(fDevice, flags);
}
sk_sp<SkSurface> SkSurface_Gpu::onNewSurface(const SkImageInfo& info) {
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp
index ff14c41fae..6e36fb3d82 100644
--- a/src/pdf/SkPDFDevice.cpp
+++ b/src/pdf/SkPDFDevice.cpp
@@ -819,7 +819,7 @@ void SkPDFDevice::internalDrawPathWithFilter(const SkClipStack& clipStack,
// Must mask with a Form XObject.
sk_sp<SkPDFDevice> maskDevice = this->makeCongruentDevice();
{
- SkCanvas canvas(maskDevice.get());
+ SkCanvas canvas(maskDevice);
canvas.drawImage(mask, dstMaskBounds.x(), dstMaskBounds.y());
}
if (!ctm.isIdentity() && paint->getShader()) {
@@ -2098,7 +2098,7 @@ void SkPDFDevice::internalDrawImageRect(SkKeyedImage imageSubset,
// Must mask with a Form XObject.
sk_sp<SkPDFDevice> maskDevice = this->makeCongruentDevice();
{
- SkCanvas canvas(maskDevice.get());
+ SkCanvas canvas(maskDevice);
if (paint.getMaskFilter()) {
// This clip prevents the mask image shader from covering
// entire device if unnecessary.
diff --git a/src/pdf/SkPDFDocument.cpp b/src/pdf/SkPDFDocument.cpp
index 16f0c11a40..b06b8b1a96 100644
--- a/src/pdf/SkPDFDocument.cpp
+++ b/src/pdf/SkPDFDocument.cpp
@@ -211,7 +211,7 @@ SkCanvas* SkPDFDocument::onBeginPage(SkScalar width, SkScalar height) {
SkScalarRoundToInt(width), SkScalarRoundToInt(height));
fPageDevice = sk_make_sp<SkPDFDevice>(pageSize, this);
fPageDevice->setFlip(); // Only the top-level device needs to be flipped.
- fCanvas.reset(new SkCanvas(fPageDevice.get()));
+ fCanvas.reset(new SkCanvas(fPageDevice));
return fCanvas.get();
}
diff --git a/src/pdf/SkPDFShader.cpp b/src/pdf/SkPDFShader.cpp
index 73a6e6b350..63611d43d5 100644
--- a/src/pdf/SkPDFShader.cpp
+++ b/src/pdf/SkPDFShader.cpp
@@ -72,7 +72,7 @@ static sk_sp<SkPDFStream> make_image_shader(SkPDFDocument* doc,
SkISize patternDeviceSize = {SkScalarCeilToInt(deviceBounds.width()),
SkScalarCeilToInt(deviceBounds.height())};
auto patternDevice = sk_make_sp<SkPDFDevice>(patternDeviceSize, doc);
- SkCanvas canvas(patternDevice.get());
+ SkCanvas canvas(patternDevice);
SkRect patternBBox = SkRect::Make(image->bounds());
diff --git a/src/svg/SkSVGCanvas.cpp b/src/svg/SkSVGCanvas.cpp
index a95bdf0687..3d1ff0e74a 100644
--- a/src/svg/SkSVGCanvas.cpp
+++ b/src/svg/SkSVGCanvas.cpp
@@ -15,7 +15,7 @@ std::unique_ptr<SkCanvas> SkSVGCanvas::Make(const SkRect& bounds, SkXMLWriter* w
SkISize size = bounds.roundOut().size();
sk_sp<SkBaseDevice> device(SkSVGDevice::Create(size, writer));
- return skstd::make_unique<SkCanvas>(device.get());
+ return skstd::make_unique<SkCanvas>(device);
}
std::unique_ptr<SkCanvas> SkSVGCanvas::Make(const SkRect& bounds, SkWStream* writer) {
diff --git a/src/xps/SkXPSDocument.cpp b/src/xps/SkXPSDocument.cpp
index 2665e90b63..60809068f9 100644
--- a/src/xps/SkXPSDocument.cpp
+++ b/src/xps/SkXPSDocument.cpp
@@ -35,7 +35,7 @@ SkXPSDocument::~SkXPSDocument() {
SkCanvas* SkXPSDocument::onBeginPage(SkScalar width, SkScalar height) {
fDevice.beginSheet(fUnitsPerMeter, fPixelsPerMeter, {width, height});
- fCanvas.reset(new SkCanvas(&fDevice));
+ fCanvas.reset(new SkCanvas(sk_ref_sp(&fDevice)));
return fCanvas.get();
}
diff --git a/tests/LayerDrawLooperTest.cpp b/tests/LayerDrawLooperTest.cpp
index 1a1e68b0c8..e0d082a9f5 100644
--- a/tests/LayerDrawLooperTest.cpp
+++ b/tests/LayerDrawLooperTest.cpp
@@ -56,7 +56,7 @@ static void test_frontToBack(skiatest::Reporter* reporter) {
layerPaint->setBlendMode(SkBlendMode::kSrc);
FakeDevice device;
- SkCanvas canvas(&device);
+ SkCanvas canvas(sk_ref_sp(&device));
SkPaint paint;
auto looper(looperBuilder.detach());
SkArenaAlloc alloc{48};
@@ -95,7 +95,7 @@ static void test_backToFront(skiatest::Reporter* reporter) {
layerPaint->setBlendMode(SkBlendMode::kSrc);
FakeDevice device;
- SkCanvas canvas(&device);
+ SkCanvas canvas(sk_ref_sp(&device));
SkPaint paint;
auto looper(looperBuilder.detach());
SkArenaAlloc alloc{48};
@@ -134,7 +134,7 @@ static void test_mixed(skiatest::Reporter* reporter) {
layerPaint->setBlendMode(SkBlendMode::kSrc);
FakeDevice device;
- SkCanvas canvas(&device);
+ SkCanvas canvas(sk_ref_sp(&device));
SkPaint paint;
sk_sp<SkDrawLooper> looper(looperBuilder.detach());
SkArenaAlloc alloc{48};
diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp
index 566ab80cc2..5d8b431e93 100644
--- a/tools/viewer/Viewer.cpp
+++ b/tools/viewer/Viewer.cpp
@@ -28,6 +28,7 @@
#include "SkFontMgrPriv.h"
#include "SkGraphics.h"
#include "SkImagePriv.h"
+#include "SkMakeUnique.h"
#include "SkOSFile.h"
#include "SkOSPath.h"
#include "SkPaintFilterCanvas.h"
@@ -1027,7 +1028,6 @@ void Viewer::drawSlide(SkCanvas* canvas) {
// we need to render offscreen. We also need to render offscreen if we're in any raster mode,
// because the window surface is actually GL.
sk_sp<SkSurface> offscreenSurface = nullptr;
- std::unique_ptr<SkThreadedBMPDevice> threadedDevice;
std::unique_ptr<SkCanvas> threadedCanvas;
if (Window::kRaster_BackendType == fBackendType ||
ColorMode::kColorManagedLinearF16 == fColorMode ||
@@ -1052,9 +1052,10 @@ void Viewer::drawSlide(SkCanvas* canvas) {
if (fTileCnt > 0 && offscreenSurface->peekPixels(&offscreenPixmap)) {
SkBitmap offscreenBitmap;
offscreenBitmap.installPixels(offscreenPixmap);
- threadedDevice.reset(new SkThreadedBMPDevice(offscreenBitmap, fTileCnt,
- fThreadCnt, fExecutor.get()));
- threadedCanvas.reset(new SkCanvas(threadedDevice.get()));
+ threadedCanvas =
+ skstd::make_unique<SkCanvas>(
+ sk_make_sp<SkThreadedBMPDevice>(
+ offscreenBitmap, fTileCnt, fThreadCnt, fExecutor.get()));
slideCanvas = threadedCanvas.get();
} else {
slideCanvas = offscreenSurface->getCanvas();