OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkCanvas_DEFINED | 8 #ifndef SkCanvas_DEFINED |
9 #define SkCanvas_DEFINED | 9 #define SkCanvas_DEFINED |
10 | 10 |
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 | 785 |
786 @param image The image to be drawn | 786 @param image The image to be drawn |
787 @param src Optional: specify the subset of the image to be drawn | 787 @param src Optional: specify the subset of the image to be drawn |
788 @param dst The destination rectangle where the scaled/translated | 788 @param dst The destination rectangle where the scaled/translated |
789 image will be drawn | 789 image will be drawn |
790 @param paint The paint used to draw the image, or NULL | 790 @param paint The paint used to draw the image, or NULL |
791 */ | 791 */ |
792 void drawImageRect(const SkImage* image, const SkRect* src, const SkRect& ds
t, | 792 void drawImageRect(const SkImage* image, const SkRect* src, const SkRect& ds
t, |
793 const SkPaint* paint = NULL); | 793 const SkPaint* paint = NULL); |
794 | 794 |
| 795 /** |
| 796 * Draw the image stretched differentially to fit into dst. |
| 797 * center is a rect within the image, and logically divides the image |
| 798 * into 9 sections (3x3). For example, if the middle pixel of a [5x5] |
| 799 * image is the "center", then the center-rect should be [2, 2, 3, 3]. |
| 800 * |
| 801 * If the dst is >= the image size, then... |
| 802 * - The 4 corners are not stretched at all. |
| 803 * - The sides are stretched in only one axis. |
| 804 * - The center is stretched in both axes. |
| 805 * Else, for each axis where dst < image, |
| 806 * - The corners shrink proportionally |
| 807 * - The sides (along the shrink axis) and center are not drawn |
| 808 */ |
| 809 void drawImageNine(const SkImage*, const SkIRect& center, const SkRect& dst, |
| 810 const SkPaint* paint = NULL); |
| 811 |
795 /** Draw the specified bitmap, with its top/left corner at (x,y), using the | 812 /** Draw the specified bitmap, with its top/left corner at (x,y), using the |
796 specified paint, transformed by the current matrix. Note: if the paint | 813 specified paint, transformed by the current matrix. Note: if the paint |
797 contains a maskfilter that generates a mask which extends beyond the | 814 contains a maskfilter that generates a mask which extends beyond the |
798 bitmap's original width/height, then the bitmap will be drawn as if it | 815 bitmap's original width/height, then the bitmap will be drawn as if it |
799 were in a Shader with CLAMP mode. Thus the color outside of the original | 816 were in a Shader with CLAMP mode. Thus the color outside of the original |
800 width/height will be the edge color replicated. | 817 width/height will be the edge color replicated. |
801 | 818 |
802 If a shader is present on the paint it will be ignored, except in the | 819 If a shader is present on the paint it will be ignored, except in the |
803 case where the bitmap is kAlpha_8_SkColorType. In that case, the color i
s | 820 case where the bitmap is kAlpha_8_SkColorType. In that case, the color i
s |
804 generated by the shader. | 821 generated by the shader. |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1223 virtual void onDrawPoints(PointMode, size_t count, const SkPoint pts[], cons
t SkPaint&); | 1240 virtual void onDrawPoints(PointMode, size_t count, const SkPoint pts[], cons
t SkPaint&); |
1224 virtual void onDrawVertices(VertexMode, int vertexCount, const SkPoint verti
ces[], | 1241 virtual void onDrawVertices(VertexMode, int vertexCount, const SkPoint verti
ces[], |
1225 const SkPoint texs[], const SkColor colors[], Sk
Xfermode*, | 1242 const SkPoint texs[], const SkColor colors[], Sk
Xfermode*, |
1226 const uint16_t indices[], int indexCount, const
SkPaint&); | 1243 const uint16_t indices[], int indexCount, const
SkPaint&); |
1227 | 1244 |
1228 virtual void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[],
const SkColor[], | 1245 virtual void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[],
const SkColor[], |
1229 int count, SkXfermode::Mode, const SkRect* cull, co
nst SkPaint*); | 1246 int count, SkXfermode::Mode, const SkRect* cull, co
nst SkPaint*); |
1230 virtual void onDrawPath(const SkPath&, const SkPaint&); | 1247 virtual void onDrawPath(const SkPath&, const SkPaint&); |
1231 virtual void onDrawImage(const SkImage*, SkScalar dx, SkScalar dy, const SkP
aint*); | 1248 virtual void onDrawImage(const SkImage*, SkScalar dx, SkScalar dy, const SkP
aint*); |
1232 virtual void onDrawImageRect(const SkImage*, const SkRect*, const SkRect&, c
onst SkPaint*); | 1249 virtual void onDrawImageRect(const SkImage*, const SkRect*, const SkRect&, c
onst SkPaint*); |
| 1250 virtual void onDrawImageNine(const SkImage*, const SkIRect& center, const Sk
Rect& dst, |
| 1251 const SkPaint*); |
| 1252 |
1233 virtual void onDrawBitmap(const SkBitmap&, SkScalar dx, SkScalar dy, const S
kPaint*); | 1253 virtual void onDrawBitmap(const SkBitmap&, SkScalar dx, SkScalar dy, const S
kPaint*); |
1234 virtual void onDrawBitmapRect(const SkBitmap&, const SkRect*, const SkRect&,
const SkPaint*, | 1254 virtual void onDrawBitmapRect(const SkBitmap&, const SkRect*, const SkRect&,
const SkPaint*, |
1235 DrawBitmapRectFlags); | 1255 DrawBitmapRectFlags); |
1236 virtual void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const
SkRect& dst, | 1256 virtual void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const
SkRect& dst, |
1237 const SkPaint*); | 1257 const SkPaint*); |
1238 virtual void onDrawSprite(const SkBitmap&, int left, int top, const SkPaint*
); | 1258 virtual void onDrawSprite(const SkBitmap&, int left, int top, const SkPaint*
); |
1239 | 1259 |
1240 enum ClipEdgeStyle { | 1260 enum ClipEdgeStyle { |
1241 kHard_ClipEdgeStyle, | 1261 kHard_ClipEdgeStyle, |
1242 kSoft_ClipEdgeStyle | 1262 kSoft_ClipEdgeStyle |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1340 */ | 1360 */ |
1341 SkISize getTopLayerSize() const; | 1361 SkISize getTopLayerSize() const; |
1342 SkIPoint getTopLayerOrigin() const; | 1362 SkIPoint getTopLayerOrigin() const; |
1343 | 1363 |
1344 // internal methods are not virtual, so they can safely be called by other | 1364 // internal methods are not virtual, so they can safely be called by other |
1345 // canvas apis, without confusing subclasses (like SkPictureRecording) | 1365 // canvas apis, without confusing subclasses (like SkPictureRecording) |
1346 void internalDrawBitmap(const SkBitmap&, const SkMatrix& m, const SkPaint* p
aint); | 1366 void internalDrawBitmap(const SkBitmap&, const SkMatrix& m, const SkPaint* p
aint); |
1347 void internalDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, | 1367 void internalDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, |
1348 const SkRect& dst, const SkPaint* paint, | 1368 const SkRect& dst, const SkPaint* paint, |
1349 DrawBitmapRectFlags flags); | 1369 DrawBitmapRectFlags flags); |
1350 void internalDrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, | |
1351 const SkRect& dst, const SkPaint* paint); | |
1352 void internalDrawPaint(const SkPaint& paint); | 1370 void internalDrawPaint(const SkPaint& paint); |
1353 void internalSaveLayer(const SkRect* bounds, const SkPaint*, SaveFlags, Save
LayerStrategy); | 1371 void internalSaveLayer(const SkRect* bounds, const SkPaint*, SaveFlags, Save
LayerStrategy); |
1354 void internalDrawDevice(SkBaseDevice*, int x, int y, const SkPaint*, bool is
BitmapDevice); | 1372 void internalDrawDevice(SkBaseDevice*, int x, int y, const SkPaint*, bool is
BitmapDevice); |
1355 | 1373 |
1356 // shared by save() and saveLayer() | 1374 // shared by save() and saveLayer() |
1357 void internalSave(); | 1375 void internalSave(); |
1358 void internalRestore(); | 1376 void internalRestore(); |
1359 static void DrawRect(const SkDraw& draw, const SkPaint& paint, | 1377 static void DrawRect(const SkDraw& draw, const SkPaint& paint, |
1360 const SkRect& r, SkScalar textSize); | 1378 const SkRect& r, SkScalar textSize); |
1361 static void DrawTextDecorations(const SkDraw& draw, const SkPaint& paint, | 1379 static void DrawTextDecorations(const SkDraw& draw, const SkPaint& paint, |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1497 | 1515 |
1498 class SkCanvasClipVisitor { | 1516 class SkCanvasClipVisitor { |
1499 public: | 1517 public: |
1500 virtual ~SkCanvasClipVisitor(); | 1518 virtual ~SkCanvasClipVisitor(); |
1501 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; | 1519 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; |
1502 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; | 1520 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; |
1503 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; | 1521 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; |
1504 }; | 1522 }; |
1505 | 1523 |
1506 #endif | 1524 #endif |
OLD | NEW |