SkCanvas.h revision 210ce003a5ec039dda80de0569fb47ca4efc4dc7
1ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com 28a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/* 3ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Copyright 2006 The Android Open Source Project 48a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * 5ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Use of this source code is governed by a BSD-style license that can be 6ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * found in the LICENSE file. 78a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 88a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 9ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com 108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifndef SkCanvas_DEFINED 118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define SkCanvas_DEFINED 128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkTypes.h" 148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkBitmap.h" 158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkDeque.h" 165c3d1471e4908706cd053a5e2ea9ded3a6c2eaebreed@google.com#include "SkClipStack.h" 178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkPaint.h" 188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkRefCnt.h" 198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkPath.h" 208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkRegion.h" 218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkScalarCompare.h" 22845fdaca174f4675e9acc164b510e3a5ffa9053creed@android.com#include "SkXfermode.h" 238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkBounder; 258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkDevice; 268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkDraw; 278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkDrawFilter; 288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkPicture; 298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/** \class SkCanvas 318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com A Canvas encapsulates all of the state about drawing into a device (bitmap). 338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com This includes a reference to the device itself, and a stack of matrix/clip 348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com values. For any given draw call (e.g. drawRect), the geometry of the object 358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com being drawn is transformed by the concatenation of all the matrices in the 368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com stack. The transformed geometry is clipped by the intersection of all of 378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com the clips in the stack. 388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com While the Canvas holds the state of the drawing device, the state (style) 408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com of the object being drawn is held by the Paint, which is provided as a 418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com parameter to each of the draw() methods. The Paint holds attributes such as 428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com color, typeface, textSize, strokeWidth, shader (e.g. gradients, patterns), 438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com etc. 448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com*/ 457ffb1b21abcc7bbed5a0fc711f6dd7b9dbb4f577ctguil@chromium.orgclass SK_API SkCanvas : public SkRefCnt { 468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic: 47cde92111d50a96b6d0f3e166fbac7c9bc6eca349reed@google.com SkCanvas(); 488d84fac294682647694b0d2d8a87ac2bd19b6aabvandebo@chromium.org 496dc745506e6d6cc0936fed4de24443dc1ecb5a34reed@google.com /** Construct a canvas with the specified device to draw into. 50e97f0856a8044866b12527819d14cdfbcdfd96f2bsalomon@google.com 518d84fac294682647694b0d2d8a87ac2bd19b6aabvandebo@chromium.org @param device Specifies a device for the canvas to draw into. 528d84fac294682647694b0d2d8a87ac2bd19b6aabvandebo@chromium.org */ 538d84fac294682647694b0d2d8a87ac2bd19b6aabvandebo@chromium.org explicit SkCanvas(SkDevice* device); 548d84fac294682647694b0d2d8a87ac2bd19b6aabvandebo@chromium.org 558d84fac294682647694b0d2d8a87ac2bd19b6aabvandebo@chromium.org /** Deprecated - Construct a canvas with the specified bitmap to draw into. 568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param bitmap Specifies a bitmap for the canvas to draw into. Its 578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com structure are copied to the canvas. 588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com explicit SkCanvas(const SkBitmap& bitmap); 608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual ~SkCanvas(); 618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /////////////////////////////////////////////////////////////////////////// 638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 64210ce003a5ec039dda80de0569fb47ca4efc4dc7reed@google.com /** 65210ce003a5ec039dda80de0569fb47ca4efc4dc7reed@google.com * Return the width/height of the underlying device. The current drawable 66210ce003a5ec039dda80de0569fb47ca4efc4dc7reed@google.com * area may be small (due to clipping or saveLayer). For a canvas with 67210ce003a5ec039dda80de0569fb47ca4efc4dc7reed@google.com * no device, 0,0 will be returned. 68210ce003a5ec039dda80de0569fb47ca4efc4dc7reed@google.com */ 69210ce003a5ec039dda80de0569fb47ca4efc4dc7reed@google.com SkISize getDeviceSize() const; 70210ce003a5ec039dda80de0569fb47ca4efc4dc7reed@google.com 718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Return the canvas' device object, which may be null. The device holds 728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com the bitmap of the pixels that the canvas draws into. The reference count 738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com of the returned device is not changed by this call. 748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkDevice* getDevice() const; 768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Specify a device for this canvas to draw into. If it is not null, its 788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com reference count is incremented. If the canvas was already holding a 798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com device, its reference count is decremented. The new device is returned. 808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkDevice* setDevice(SkDevice* device); 828d84fac294682647694b0d2d8a87ac2bd19b6aabvandebo@chromium.org 839266fed56a46a4edc710a52c7be8d46fd7c2bc7areed@google.com /** 849266fed56a46a4edc710a52c7be8d46fd7c2bc7areed@google.com * saveLayer() can create another device (which is later drawn onto 859266fed56a46a4edc710a52c7be8d46fd7c2bc7areed@google.com * the previous device). getTopDevice() returns the top-most device current 869266fed56a46a4edc710a52c7be8d46fd7c2bc7areed@google.com * installed. Note that this can change on other calls like save/restore, 879266fed56a46a4edc710a52c7be8d46fd7c2bc7areed@google.com * so do not access this device after subsequent canvas calls. 889266fed56a46a4edc710a52c7be8d46fd7c2bc7areed@google.com * The reference count of the device is not changed. 899266fed56a46a4edc710a52c7be8d46fd7c2bc7areed@google.com */ 909266fed56a46a4edc710a52c7be8d46fd7c2bc7areed@google.com SkDevice* getTopDevice() const; 919266fed56a46a4edc710a52c7be8d46fd7c2bc7areed@google.com 92f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com /** 93f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com * Create a new raster device and make it current. This also returns 94f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com * the new device. 95f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com */ 96af951c9bc4cbb6e60b430194fe5127ebe99c53fbreed@google.com SkDevice* setBitmapDevice(const SkBitmap& bitmap); 978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 9851df9e3fe3c1aec370854b2718df16fc02faa1b2reed@google.com /** 99cde92111d50a96b6d0f3e166fbac7c9bc6eca349reed@google.com * Shortcut for getDevice()->createCompatibleDevice(...). 100cde92111d50a96b6d0f3e166fbac7c9bc6eca349reed@google.com * If getDevice() == NULL, this method does nothing, and returns NULL. 101e97f0856a8044866b12527819d14cdfbcdfd96f2bsalomon@google.com */ 102e97f0856a8044866b12527819d14cdfbcdfd96f2bsalomon@google.com SkDevice* createCompatibleDevice(SkBitmap::Config config, 103e97f0856a8044866b12527819d14cdfbcdfd96f2bsalomon@google.com int width, int height, 104e97f0856a8044866b12527819d14cdfbcdfd96f2bsalomon@google.com bool isOpaque); 105e97f0856a8044866b12527819d14cdfbcdfd96f2bsalomon@google.com 1064b226023832011bc3bcdd1e5092ff0645ad0bdeereed@google.com /////////////////////////////////////////////////////////////////////////// 1074b226023832011bc3bcdd1e5092ff0645ad0bdeereed@google.com 1084b226023832011bc3bcdd1e5092ff0645ad0bdeereed@google.com /** 10951df9e3fe3c1aec370854b2718df16fc02faa1b2reed@google.com * Copy the pixels from the device into bitmap. Returns true on success. 11051df9e3fe3c1aec370854b2718df16fc02faa1b2reed@google.com * If false is returned, then the bitmap parameter is left unchanged. 1113dd42b3c87299ad17b4df93fe251f6f9362495dcreed@google.com * The bitmap parameter is treated as output-only, and will be completely 1123dd42b3c87299ad17b4df93fe251f6f9362495dcreed@google.com * overwritten (if the method returns true). 11351df9e3fe3c1aec370854b2718df16fc02faa1b2reed@google.com */ 11451df9e3fe3c1aec370854b2718df16fc02faa1b2reed@google.com bool readPixels(const SkIRect& srcRect, SkBitmap* bitmap); 11551df9e3fe3c1aec370854b2718df16fc02faa1b2reed@google.com bool readPixels(SkBitmap* bitmap); 11651df9e3fe3c1aec370854b2718df16fc02faa1b2reed@google.com 11751df9e3fe3c1aec370854b2718df16fc02faa1b2reed@google.com /** 11851df9e3fe3c1aec370854b2718df16fc02faa1b2reed@google.com * Similar to draw sprite, this method will copy the pixels in bitmap onto 11951df9e3fe3c1aec370854b2718df16fc02faa1b2reed@google.com * the device, with the top/left corner specified by (x, y). The pixel 12051df9e3fe3c1aec370854b2718df16fc02faa1b2reed@google.com * values in the device are completely replaced: there is no blending. 1214f1151ab27485aff393d16559086c4c461f137a4epoger@google.com * 1224f1151ab27485aff393d16559086c4c461f137a4epoger@google.com * Note: If you are recording drawing commands on this canvas to 1234f1151ab27485aff393d16559086c4c461f137a4epoger@google.com * SkPicture, writePixels() is ignored! 12451df9e3fe3c1aec370854b2718df16fc02faa1b2reed@google.com */ 12551df9e3fe3c1aec370854b2718df16fc02faa1b2reed@google.com void writePixels(const SkBitmap& bitmap, int x, int y); 1264b226023832011bc3bcdd1e5092ff0645ad0bdeereed@google.com 1278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /////////////////////////////////////////////////////////////////////////// 1288d84fac294682647694b0d2d8a87ac2bd19b6aabvandebo@chromium.org 1298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com enum SaveFlags { 1308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** save the matrix state, restoring it on restore() */ 1318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kMatrix_SaveFlag = 0x01, 1328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** save the clip state, restoring it on restore() */ 1338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kClip_SaveFlag = 0x02, 1348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** the layer needs to support per-pixel alpha */ 1358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kHasAlphaLayer_SaveFlag = 0x04, 1368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** the layer needs to support 8-bits per color component */ 1378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kFullColorLayer_SaveFlag = 0x08, 1388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** the layer should clip against the bounds argument */ 1398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kClipToLayer_SaveFlag = 0x10, 1408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com // helper masks for common choices 1428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kMatrixClip_SaveFlag = 0x03, 1438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kARGB_NoClipLayer_SaveFlag = 0x0F, 1448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kARGB_ClipLayer_SaveFlag = 0x1F 1458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com }; 1468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 147dc3381fc8194a6192af39539c6ac9787b20209d3reed@android.com /** This call saves the current matrix, clip, and drawFilter, and pushes a 1488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com copy onto a private stack. Subsequent calls to translate, scale, 149dc3381fc8194a6192af39539c6ac9787b20209d3reed@android.com rotate, skew, concat or clipRect, clipPath, and setDrawFilter all 150dc3381fc8194a6192af39539c6ac9787b20209d3reed@android.com operate on this copy. 151dc3381fc8194a6192af39539c6ac9787b20209d3reed@android.com When the balancing call to restore() is made, the previous matrix, clip, 152dc3381fc8194a6192af39539c6ac9787b20209d3reed@android.com and drawFilter are restored. 1538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return The value to pass to restoreToCount() to balance this save() 1548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 1558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual int save(SaveFlags flags = kMatrixClip_SaveFlag); 1568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** This behaves the same as save(), but in addition it allocates an 1588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com offscreen bitmap. All drawing calls are directed there, and only when 1598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com the balancing call to restore() is made is that offscreen transfered to 160dc3381fc8194a6192af39539c6ac9787b20209d3reed@android.com the canvas (or the previous layer). 161ad164b2025cba65131ca68221a6ea7640d7b1de8reed@android.com @param bounds (may be null) This rect, if non-null, is used as a hint to 162ad164b2025cba65131ca68221a6ea7640d7b1de8reed@android.com limit the size of the offscreen, and thus drawing may be 163ad164b2025cba65131ca68221a6ea7640d7b1de8reed@android.com clipped to it, though that clipping is not guaranteed to 164ad164b2025cba65131ca68221a6ea7640d7b1de8reed@android.com happen. If exact clipping is desired, use clipRect(). 1658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param paint (may be null) This is copied, and is applied to the 1668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com offscreen when restore() is called 1678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param flags LayerFlags 1688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return The value to pass to restoreToCount() to balance this save() 1698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 1708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual int saveLayer(const SkRect* bounds, const SkPaint* paint, 1718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SaveFlags flags = kARGB_ClipLayer_SaveFlag); 1728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** This behaves the same as save(), but in addition it allocates an 1748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com offscreen bitmap. All drawing calls are directed there, and only when 1758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com the balancing call to restore() is made is that offscreen transfered to 176dc3381fc8194a6192af39539c6ac9787b20209d3reed@android.com the canvas (or the previous layer). 17740408614655c4057d93842c9b0f09aa6dfff9e02reed@android.com @param bounds (may be null) This rect, if non-null, is used as a hint to 17840408614655c4057d93842c9b0f09aa6dfff9e02reed@android.com limit the size of the offscreen, and thus drawing may be 17940408614655c4057d93842c9b0f09aa6dfff9e02reed@android.com clipped to it, though that clipping is not guaranteed to 18040408614655c4057d93842c9b0f09aa6dfff9e02reed@android.com happen. If exact clipping is desired, use clipRect(). 1818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param alpha This is applied to the offscreen when restore() is called. 1828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param flags LayerFlags 1838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return The value to pass to restoreToCount() to balance this save() 1848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 1858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com int saveLayerAlpha(const SkRect* bounds, U8CPU alpha, 1868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SaveFlags flags = kARGB_ClipLayer_SaveFlag); 1878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** This call balances a previous call to save(), and is used to remove all 189dc3381fc8194a6192af39539c6ac9787b20209d3reed@android.com modifications to the matrix/clip/drawFilter state since the last save 190dc3381fc8194a6192af39539c6ac9787b20209d3reed@android.com call. 191dc3381fc8194a6192af39539c6ac9787b20209d3reed@android.com It is an error to call restore() more times than save() was called. 1928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 1938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void restore(); 1948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Returns the number of matrix/clip states on the SkCanvas' private stack. 1968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com This will equal # save() calls - # restore() calls. 1978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 1988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com int getSaveCount() const; 1998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Efficient way to pop any calls to save() that happened after the save 2018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com count reached saveCount. It is an error for saveCount to be less than 2028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com getSaveCount() 2038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param saveCount The number of save() levels to restore from 2048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 2058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void restoreToCount(int saveCount); 2068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Preconcat the current matrix with the specified translation 2088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param dx The distance to translate in X 2098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param dy The distance to translate in Y 2108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com returns true if the operation succeeded (e.g. did not overflow) 2118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 2128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual bool translate(SkScalar dx, SkScalar dy); 2138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Preconcat the current matrix with the specified scale. 2158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param sx The amount to scale in X 2168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param sy The amount to scale in Y 2178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com returns true if the operation succeeded (e.g. did not overflow) 2188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 2198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual bool scale(SkScalar sx, SkScalar sy); 2208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Preconcat the current matrix with the specified rotation. 2228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param degrees The amount to rotate, in degrees 2238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com returns true if the operation succeeded (e.g. did not overflow) 2248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 2258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual bool rotate(SkScalar degrees); 2268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Preconcat the current matrix with the specified skew. 2288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param sx The amount to skew in X 2298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param sy The amount to skew in Y 2308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com returns true if the operation succeeded (e.g. did not overflow) 2318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 2328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual bool skew(SkScalar sx, SkScalar sy); 2338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Preconcat the current matrix with the specified matrix. 2358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param matrix The matrix to preconcatenate with the current matrix 2368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return true if the operation succeeded (e.g. did not overflow) 2378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 2388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual bool concat(const SkMatrix& matrix); 2394b226023832011bc3bcdd1e5092ff0645ad0bdeereed@google.com 2408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Replace the current matrix with a copy of the specified matrix. 2418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param matrix The matrix that will be copied into the current matrix. 2428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 2438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void setMatrix(const SkMatrix& matrix); 2444b226023832011bc3bcdd1e5092ff0645ad0bdeereed@google.com 2458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Helper for setMatrix(identity). Sets the current matrix to identity. 2468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 2478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void resetMatrix(); 2488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Modify the current clip with the specified rectangle. 2508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param rect The rect to intersect with the current clip 2518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param op The region op to apply to the current clip 2528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return true if the canvas' clip is non-empty 2538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 2548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual bool clipRect(const SkRect& rect, 255071eef918d70b6ca8334bc1241d1ea6923e828d5reed@google.com SkRegion::Op op = SkRegion::kIntersect_Op, 256071eef918d70b6ca8334bc1241d1ea6923e828d5reed@google.com bool doAntiAlias = false); 2578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Modify the current clip with the specified path. 2598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param path The path to apply to the current clip 2608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param op The region op to apply to the current clip 2618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return true if the canvas' new clip is non-empty 2628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 2638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual bool clipPath(const SkPath& path, 264071eef918d70b6ca8334bc1241d1ea6923e828d5reed@google.com SkRegion::Op op = SkRegion::kIntersect_Op, 265071eef918d70b6ca8334bc1241d1ea6923e828d5reed@google.com bool doAntiAlias = false); 2668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Modify the current clip with the specified region. Note that unlike 2688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com clipRect() and clipPath() which transform their arguments by the current 2698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com matrix, clipRegion() assumes its argument is already in device 2708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com coordinates, and so no transformation is performed. 2718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param deviceRgn The region to apply to the current clip 2728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param op The region op to apply to the current clip 2738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return true if the canvas' new clip is non-empty 2748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 2758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual bool clipRegion(const SkRegion& deviceRgn, 2768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkRegion::Op op = SkRegion::kIntersect_Op); 2778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Helper for clipRegion(rgn, kReplace_Op). Sets the current clip to the 2798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com specified region. This does not intersect or in any other way account 2808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com for the existing clip region. 2818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param deviceRgn The region to copy into the current clip. 2828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return true if the new clip region is non-empty 2838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 2848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool setClipRegion(const SkRegion& deviceRgn) { 2858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com return this->clipRegion(deviceRgn, SkRegion::kReplace_Op); 2868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 2878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Enum describing how to treat edges when performing quick-reject tests 2898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com of a geometry against the current clip. Treating them as antialiased 2908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com (kAA_EdgeType) will take into account the extra pixels that may be drawn 2918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com if the edge does not lie exactly on a device pixel boundary (after being 2928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com transformed by the current matrix). 2938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 2948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com enum EdgeType { 2958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Treat the edges as B&W (not antialiased) for the purposes of testing 2968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com against the current clip 2978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 2988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kBW_EdgeType, 2998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Treat the edges as antialiased for the purposes of testing 3008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com against the current clip 3018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 3028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kAA_EdgeType 3038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com }; 3048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Return true if the specified rectangle, after being transformed by the 3068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com current matrix, would lie completely outside of the current clip. Call 3078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com this to check if an area you intend to draw into is clipped out (and 3088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com therefore you can skip making the draw calls). 3098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param rect the rect to compare with the current clip 3108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param et specifies how to treat the edges (see EdgeType) 3118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return true if the rect (transformed by the canvas' matrix) does not 3128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com intersect with the canvas' clip 3138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 3148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool quickReject(const SkRect& rect, EdgeType et) const; 3158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Return true if the specified path, after being transformed by the 3178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com current matrix, would lie completely outside of the current clip. Call 3188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com this to check if an area you intend to draw into is clipped out (and 3198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com therefore you can skip making the draw calls). Note, for speed it may 3208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com return false even if the path itself might not intersect the clip 3218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com (i.e. the bounds of the path intersects, but the path does not). 3228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param path The path to compare with the current clip 3238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param et specifies how to treat the edges (see EdgeType) 3248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return true if the path (transformed by the canvas' matrix) does not 3258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com intersect with the canvas' clip 3268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 3278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool quickReject(const SkPath& path, EdgeType et) const; 3288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Return true if the horizontal band specified by top and bottom is 3308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com completely clipped out. This is a conservative calculation, meaning 3318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com that it is possible that if the method returns false, the band may still 3328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com in fact be clipped out, but the converse is not true. If this method 3338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com returns true, then the band is guaranteed to be clipped out. 3348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param top The top of the horizontal band to compare with the clip 3358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param bottom The bottom of the horizontal and to compare with the clip 3368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return true if the horizontal band is completely clipped out (i.e. does 3378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com not intersect the current clip) 3388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 3398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool quickRejectY(SkScalar top, SkScalar bottom, EdgeType et) const; 3408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Return the bounds of the current clip (in local coordinates) in the 3428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bounds parameter, and return true if it is non-empty. This can be useful 3438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com in a way similar to quickReject, in that it tells you that drawing 3448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com outside of these bounds will be clipped out. 3458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 3468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool getClipBounds(SkRect* bounds, EdgeType et = kAA_EdgeType) const; 3478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 348bcb671c82a7341253864cda3a5c46d396402d7fbtomhudson@google.com /** Return the bounds of the current clip, in device coordinates; returns 349bcb671c82a7341253864cda3a5c46d396402d7fbtomhudson@google.com true if non-empty. Maybe faster than getting the clip explicitly and 350bcb671c82a7341253864cda3a5c46d396402d7fbtomhudson@google.com then taking its bounds. 351bcb671c82a7341253864cda3a5c46d396402d7fbtomhudson@google.com */ 352bcb671c82a7341253864cda3a5c46d396402d7fbtomhudson@google.com bool getClipDeviceBounds(SkIRect* bounds) const; 353bcb671c82a7341253864cda3a5c46d396402d7fbtomhudson@google.com 354bcb671c82a7341253864cda3a5c46d396402d7fbtomhudson@google.com 3558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Fill the entire canvas' bitmap (restricted to the current clip) with the 356845fdaca174f4675e9acc164b510e3a5ffa9053creed@android.com specified ARGB color, using the specified mode. 3578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param a the alpha component (0..255) of the color to fill the canvas 3588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param r the red component (0..255) of the color to fill the canvas 3598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param g the green component (0..255) of the color to fill the canvas 3608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param b the blue component (0..255) of the color to fill the canvas 3618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param mode the mode to apply the color in (defaults to SrcOver) 3628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 3638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void drawARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b, 364845fdaca174f4675e9acc164b510e3a5ffa9053creed@android.com SkXfermode::Mode mode = SkXfermode::kSrcOver_Mode); 3658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Fill the entire canvas' bitmap (restricted to the current clip) with the 367845fdaca174f4675e9acc164b510e3a5ffa9053creed@android.com specified color and mode. 3688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param color the color to draw with 3698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param mode the mode to apply the color in (defaults to SrcOver) 3708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 3718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void drawColor(SkColor color, 372845fdaca174f4675e9acc164b510e3a5ffa9053creed@android.com SkXfermode::Mode mode = SkXfermode::kSrcOver_Mode); 3738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3742a98181f048c11f21f52fbd99f803f5fd6118261reed@google.com /** 3752a98181f048c11f21f52fbd99f803f5fd6118261reed@google.com * This erases the entire drawing surface to the specified color, 3762a98181f048c11f21f52fbd99f803f5fd6118261reed@google.com * irrespective of the clip. It does not blend with the previous pixels, 3772a98181f048c11f21f52fbd99f803f5fd6118261reed@google.com * but always overwrites them. 3782a98181f048c11f21f52fbd99f803f5fd6118261reed@google.com * 3792a98181f048c11f21f52fbd99f803f5fd6118261reed@google.com * It is roughly equivalent to the following: 3802a98181f048c11f21f52fbd99f803f5fd6118261reed@google.com * canvas.save(); 3812a98181f048c11f21f52fbd99f803f5fd6118261reed@google.com * canvas.clipRect(hugeRect, kReplace_Op); 3822a98181f048c11f21f52fbd99f803f5fd6118261reed@google.com * paint.setColor(color); 3832a98181f048c11f21f52fbd99f803f5fd6118261reed@google.com * paint.setXfermodeMode(kSrc_Mode); 3842a98181f048c11f21f52fbd99f803f5fd6118261reed@google.com * canvas.drawPaint(paint); 3852a98181f048c11f21f52fbd99f803f5fd6118261reed@google.com * canvas.restore(); 3862a98181f048c11f21f52fbd99f803f5fd6118261reed@google.com * though it is almost always much more efficient. 3872a98181f048c11f21f52fbd99f803f5fd6118261reed@google.com */ 3882a98181f048c11f21f52fbd99f803f5fd6118261reed@google.com virtual void clear(SkColor); 3892a98181f048c11f21f52fbd99f803f5fd6118261reed@google.com 3902a98181f048c11f21f52fbd99f803f5fd6118261reed@google.com /** 3912a98181f048c11f21f52fbd99f803f5fd6118261reed@google.com * Fill the entire canvas' bitmap (restricted to the current clip) with the 3922a98181f048c11f21f52fbd99f803f5fd6118261reed@google.com * specified paint. 3932a98181f048c11f21f52fbd99f803f5fd6118261reed@google.com * @param paint The paint used to fill the canvas 3942a98181f048c11f21f52fbd99f803f5fd6118261reed@google.com */ 3958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void drawPaint(const SkPaint& paint); 3968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com enum PointMode { 3988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** drawPoints draws each point separately */ 3998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kPoints_PointMode, 4008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** drawPoints draws each pair of points as a line segment */ 4018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kLines_PointMode, 4028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** drawPoints draws the array of points as a polygon */ 4038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kPolygon_PointMode 4048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com }; 4058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Draw a series of points, interpreted based on the PointMode mode. For 4078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com all modes, the count parameter is interpreted as the total number of 4088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com points. For kLine mode, count/2 line segments are drawn. 4098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com For kPoint mode, each point is drawn centered at its coordinate, and its 4108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com size is specified by the paint's stroke-width. It draws as a square, 4118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com unless the paint's cap-type is round, in which the points are drawn as 4128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com circles. 4138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com For kLine mode, each pair of points is drawn as a line segment, 4148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com respecting the paint's settings for cap/join/width. 4158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com For kPolygon mode, the entire array is drawn as a series of connected 4168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com line segments. 4178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com Note that, while similar, kLine and kPolygon modes draw slightly 4188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com differently than the equivalent path built with a series of moveto, 4198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com lineto calls, in that the path will draw all of its contours at once, 4208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com with no interactions if contours intersect each other (think XOR 4218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com xfermode). drawPoints always draws each element one at a time. 4228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param mode PointMode specifying how to draw the array of points. 4238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param count The number of points in the array 4248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param pts Array of points to draw 4258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param paint The paint used to draw the points 4268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 4278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void drawPoints(PointMode mode, size_t count, const SkPoint pts[], 4288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPaint& paint); 4298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Helper method for drawing a single point. See drawPoints() for a more 4318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com details. 4328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 4338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void drawPoint(SkScalar x, SkScalar y, const SkPaint& paint); 4344b226023832011bc3bcdd1e5092ff0645ad0bdeereed@google.com 4358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Draws a single pixel in the specified color. 4368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param x The X coordinate of which pixel to draw 4378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param y The Y coordiante of which pixel to draw 4388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param color The color to draw 4398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 4408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void drawPoint(SkScalar x, SkScalar y, SkColor color); 4418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Draw a line segment with the specified start and stop x,y coordinates, 4438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com using the specified paint. NOTE: since a line is always "framed", the 4448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com paint's Style is ignored. 4458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param x0 The x-coordinate of the start point of the line 4468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param y0 The y-coordinate of the start point of the line 4478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param x1 The x-coordinate of the end point of the line 4488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param y1 The y-coordinate of the end point of the line 4498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param paint The paint used to draw the line 4508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 4518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void drawLine(SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1, 4528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPaint& paint); 4538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Draw the specified rectangle using the specified paint. The rectangle 4558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com will be filled or stroked based on the Style in the paint. 4568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param rect The rect to be drawn 4578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param paint The paint used to draw the rect 4588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 4598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void drawRect(const SkRect& rect, const SkPaint& paint); 4608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Draw the specified rectangle using the specified paint. The rectangle 4628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com will be filled or framed based on the Style in the paint. 4638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param rect The rect to be drawn 4648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param paint The paint used to draw the rect 4658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 4668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void drawIRect(const SkIRect& rect, const SkPaint& paint) 4678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com { 4688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkRect r; 4698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com r.set(rect); // promotes the ints to scalars 4708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com this->drawRect(r, paint); 4718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 4724b226023832011bc3bcdd1e5092ff0645ad0bdeereed@google.com 4738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Draw the specified rectangle using the specified paint. The rectangle 4748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com will be filled or framed based on the Style in the paint. 4758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param left The left side of the rectangle to be drawn 4768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param top The top side of the rectangle to be drawn 4778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param right The right side of the rectangle to be drawn 4788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param bottom The bottom side of the rectangle to be drawn 4798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param paint The paint used to draw the rect 4808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 4818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void drawRectCoords(SkScalar left, SkScalar top, SkScalar right, 4828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkScalar bottom, const SkPaint& paint); 4838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Draw the specified oval using the specified paint. The oval will be 4858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com filled or framed based on the Style in the paint. 4868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param oval The rectangle bounds of the oval to be drawn 4878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param paint The paint used to draw the oval 4888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 4898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void drawOval(const SkRect& oval, const SkPaint&); 4908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Draw the specified circle using the specified paint. If radius is <= 0, 4928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com then nothing will be drawn. The circle will be filled 4938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com or framed based on the Style in the paint. 4948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param cx The x-coordinate of the center of the cirle to be drawn 4958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param cy The y-coordinate of the center of the cirle to be drawn 4968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param radius The radius of the cirle to be drawn 4978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param paint The paint used to draw the circle 4988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 4998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void drawCircle(SkScalar cx, SkScalar cy, SkScalar radius, 5008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPaint& paint); 5018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 5028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Draw the specified arc, which will be scaled to fit inside the 5038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com specified oval. If the sweep angle is >= 360, then the oval is drawn 5048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com completely. Note that this differs slightly from SkPath::arcTo, which 5058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com treats the sweep angle mod 360. 5068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param oval The bounds of oval used to define the shape of the arc 5078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param startAngle Starting angle (in degrees) where the arc begins 5088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param sweepAngle Sweep angle (in degrees) measured clockwise 5098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param useCenter true means include the center of the oval. For filling 5108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com this will draw a wedge. False means just use the arc. 5118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param paint The paint used to draw the arc 5128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 5138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void drawArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle, 5148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool useCenter, const SkPaint& paint); 5158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 5168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Draw the specified round-rect using the specified paint. The round-rect 5178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com will be filled or framed based on the Style in the paint. 5188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param rect The rectangular bounds of the roundRect to be drawn 5198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param rx The x-radius of the oval used to round the corners 5208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param ry The y-radius of the oval used to round the corners 5218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param paint The paint used to draw the roundRect 5228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 5238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void drawRoundRect(const SkRect& rect, SkScalar rx, SkScalar ry, 5248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPaint& paint); 5258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 5268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Draw the specified path using the specified paint. The path will be 5278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com filled or framed based on the Style in the paint. 5288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param path The path to be drawn 5298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param paint The paint used to draw the path 5308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 5318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void drawPath(const SkPath& path, const SkPaint& paint); 5328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 5338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Draw the specified bitmap, with its top/left corner at (x,y), using the 5348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com specified paint, transformed by the current matrix. Note: if the paint 5358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com contains a maskfilter that generates a mask which extends beyond the 5368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bitmap's original width/height, then the bitmap will be drawn as if it 5378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com were in a Shader with CLAMP mode. Thus the color outside of the original 5388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com width/height will be the edge color replicated. 5398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param bitmap The bitmap to be drawn 5408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param left The position of the left side of the bitmap being drawn 5418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param top The position of the top side of the bitmap being drawn 5428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param paint The paint used to draw the bitmap, or NULL 5438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 5448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top, 5458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPaint* paint = NULL); 5468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 5478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Draw the specified bitmap, with the specified matrix applied (before the 5488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com canvas' matrix is applied). 5498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param bitmap The bitmap to be drawn 5508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param src Optional: specify the subset of the bitmap to be drawn 5518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param dst The destination rectangle where the scaled/translated 5528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com image will be drawn 5538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param paint The paint used to draw the bitmap, or NULL 5548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 5558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void drawBitmapRect(const SkBitmap& bitmap, const SkIRect* src, 5568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkRect& dst, const SkPaint* paint = NULL); 5578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 5588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m, 5598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPaint* paint = NULL); 5604b226023832011bc3bcdd1e5092ff0645ad0bdeereed@google.com 561f0b5e1190af9807a027c0adba2f1380663c8e910reed@google.com /** 562f0b5e1190af9807a027c0adba2f1380663c8e910reed@google.com * Draw the bitmap stretched differentially to fit into dst. 563f0b5e1190af9807a027c0adba2f1380663c8e910reed@google.com * center is a rect within the bitmap, and logically divides the bitmap 564f0b5e1190af9807a027c0adba2f1380663c8e910reed@google.com * into 9 sections (3x3). For example, if the middle pixel of a [5x5] 565f0b5e1190af9807a027c0adba2f1380663c8e910reed@google.com * bitmap is the "center", then the center-rect should be [2, 2, 3, 3]. 566f0b5e1190af9807a027c0adba2f1380663c8e910reed@google.com * 567f0b5e1190af9807a027c0adba2f1380663c8e910reed@google.com * If the dst is >= the bitmap size, then... 568f0b5e1190af9807a027c0adba2f1380663c8e910reed@google.com * - The 4 corners are not stretch at all. 569f0b5e1190af9807a027c0adba2f1380663c8e910reed@google.com * - The sides are stretch in only one axis. 570f0b5e1190af9807a027c0adba2f1380663c8e910reed@google.com * - The center is stretch in both axes. 571f0b5e1190af9807a027c0adba2f1380663c8e910reed@google.com * Else, for each axis where dst < bitmap, 572f0b5e1190af9807a027c0adba2f1380663c8e910reed@google.com * - The corners shrink proportionally 573f0b5e1190af9807a027c0adba2f1380663c8e910reed@google.com * - The sides (along the shrink axis) and center are not drawn 574f0b5e1190af9807a027c0adba2f1380663c8e910reed@google.com */ 575f0b5e1190af9807a027c0adba2f1380663c8e910reed@google.com virtual void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, 576f0b5e1190af9807a027c0adba2f1380663c8e910reed@google.com const SkRect& dst, const SkPaint* paint = NULL); 577f0b5e1190af9807a027c0adba2f1380663c8e910reed@google.com 5788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Draw the specified bitmap, with its top/left corner at (x,y), 5798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com NOT transformed by the current matrix. Note: if the paint 5808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com contains a maskfilter that generates a mask which extends beyond the 5818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bitmap's original width/height, then the bitmap will be drawn as if it 5828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com were in a Shader with CLAMP mode. Thus the color outside of the original 5838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com width/height will be the edge color replicated. 5848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param bitmap The bitmap to be drawn 5858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param left The position of the left side of the bitmap being drawn 5868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param top The position of the top side of the bitmap being drawn 5878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param paint The paint used to draw the bitmap, or NULL 5888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 5898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void drawSprite(const SkBitmap& bitmap, int left, int top, 5908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPaint* paint = NULL); 5918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 5928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Draw the text, with origin at (x,y), using the specified paint. 5938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com The origin is interpreted based on the Align setting in the paint. 5948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param text The text to be drawn 5958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param byteLength The number of bytes to read from the text parameter 5968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param x The x-coordinate of the origin of the text being drawn 5978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param y The y-coordinate of the origin of the text being drawn 5988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param paint The paint used for the text (e.g. color, size, style) 5998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 6008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void drawText(const void* text, size_t byteLength, SkScalar x, 6018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkScalar y, const SkPaint& paint); 6028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 6038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Draw the text, with each character/glyph origin specified by the pos[] 6044b226023832011bc3bcdd1e5092ff0645ad0bdeereed@google.com array. The origin is interpreted by the Align setting in the paint. 6058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param text The text to be drawn 6068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param byteLength The number of bytes to read from the text parameter 6078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param pos Array of positions, used to position each character 6088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param paint The paint used for the text (e.g. color, size, style) 6098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 6108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void drawPosText(const void* text, size_t byteLength, 6118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPoint pos[], const SkPaint& paint); 6124b226023832011bc3bcdd1e5092ff0645ad0bdeereed@google.com 6138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Draw the text, with each character/glyph origin specified by the x 6148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com coordinate taken from the xpos[] array, and the y from the constY param. 6154b226023832011bc3bcdd1e5092ff0645ad0bdeereed@google.com The origin is interpreted by the Align setting in the paint. 6168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param text The text to be drawn 6178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param byteLength The number of bytes to read from the text parameter 6188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param xpos Array of x-positions, used to position each character 6198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param constY The shared Y coordinate for all of the positions 6208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param paint The paint used for the text (e.g. color, size, style) 6218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 6228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void drawPosTextH(const void* text, size_t byteLength, 6238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkScalar xpos[], SkScalar constY, 6248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPaint& paint); 6254b226023832011bc3bcdd1e5092ff0645ad0bdeereed@google.com 6268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Draw the text, with origin at (x,y), using the specified paint, along 6278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com the specified path. The paint's Align setting determins where along the 6288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com path to start the text. 6298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param text The text to be drawn 6308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param byteLength The number of bytes to read from the text parameter 6318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param path The path the text should follow for its baseline 6328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param hOffset The distance along the path to add to the text's 6338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com starting position 6348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param vOffset The distance above(-) or below(+) the path to 6358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com position the text 6368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param paint The paint used for the text 6378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 6388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void drawTextOnPathHV(const void* text, size_t byteLength, 6398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPath& path, SkScalar hOffset, 6408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkScalar vOffset, const SkPaint& paint); 6418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 6428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Draw the text, with origin at (x,y), using the specified paint, along 6438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com the specified path. The paint's Align setting determins where along the 6448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com path to start the text. 6458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param text The text to be drawn 6468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param byteLength The number of bytes to read from the text parameter 6478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param path The path the text should follow for its baseline 6488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param matrix (may be null) Applied to the text before it is 6498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com mapped onto the path 6508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param paint The paint used for the text 6518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 6528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void drawTextOnPath(const void* text, size_t byteLength, 6538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPath& path, const SkMatrix* matrix, 6548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPaint& paint); 6558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 656cd9d69b9ce7eb301a9fd8d91b9f95fd99b07bae5djsollen@google.com#ifdef ANDROID 657cd9d69b9ce7eb301a9fd8d91b9f95fd99b07bae5djsollen@google.com /** Draw the text on path, with each character/glyph origin specified by the pos[] 658cd9d69b9ce7eb301a9fd8d91b9f95fd99b07bae5djsollen@google.com array. The origin is interpreted by the Align setting in the paint. 659cd9d69b9ce7eb301a9fd8d91b9f95fd99b07bae5djsollen@google.com @param text The text to be drawn 660cd9d69b9ce7eb301a9fd8d91b9f95fd99b07bae5djsollen@google.com @param byteLength The number of bytes to read from the text parameter 661cd9d69b9ce7eb301a9fd8d91b9f95fd99b07bae5djsollen@google.com @param pos Array of positions, used to position each character 662cd9d69b9ce7eb301a9fd8d91b9f95fd99b07bae5djsollen@google.com @param paint The paint used for the text (e.g. color, size, style) 663cd9d69b9ce7eb301a9fd8d91b9f95fd99b07bae5djsollen@google.com @param path The path to draw on 664cd9d69b9ce7eb301a9fd8d91b9f95fd99b07bae5djsollen@google.com @param matrix The canvas matrix 665cd9d69b9ce7eb301a9fd8d91b9f95fd99b07bae5djsollen@google.com */ 666cd9d69b9ce7eb301a9fd8d91b9f95fd99b07bae5djsollen@google.com void drawPosTextOnPath(const void* text, size_t byteLength, 667cd9d69b9ce7eb301a9fd8d91b9f95fd99b07bae5djsollen@google.com const SkPoint pos[], const SkPaint& paint, 668cd9d69b9ce7eb301a9fd8d91b9f95fd99b07bae5djsollen@google.com const SkPath& path, const SkMatrix* matrix); 669cd9d69b9ce7eb301a9fd8d91b9f95fd99b07bae5djsollen@google.com#endif 670cd9d69b9ce7eb301a9fd8d91b9f95fd99b07bae5djsollen@google.com 6718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Draw the picture into this canvas. This method effective brackets the 6728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com playback of the picture's draw calls with save/restore, so the state 6738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com of this canvas will be unchanged after this call. This contrasts with 6748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com the more immediate method SkPicture::draw(), which does not bracket 6758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com the canvas with save/restore, thus the canvas may be left in a changed 6768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com state after the call. 6778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param picture The recorded drawing commands to playback into this 6788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com canvas. 6798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 6808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void drawPicture(SkPicture& picture); 6814b226023832011bc3bcdd1e5092ff0645ad0bdeereed@google.com 6828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com enum VertexMode { 6838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kTriangles_VertexMode, 6848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kTriangleStrip_VertexMode, 6858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kTriangleFan_VertexMode 6868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com }; 6874b226023832011bc3bcdd1e5092ff0645ad0bdeereed@google.com 6888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Draw the array of vertices, interpreted as triangles (based on mode). 6898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param vmode How to interpret the array of vertices 6908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param vertexCount The number of points in the vertices array (and 6918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com corresponding texs and colors arrays if non-null) 6928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param vertices Array of vertices for the mesh 6938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param texs May be null. If not null, specifies the coordinate 6948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com in texture space for each vertex. 6958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param colors May be null. If not null, specifies a color for each 6968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com vertex, to be interpolated across the triangle. 6978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param xmode Used if both texs and colors are present. In this 6988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com case the colors are combined with the texture using mode, 6998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com before being drawn using the paint. If mode is null, then 700845fdaca174f4675e9acc164b510e3a5ffa9053creed@android.com kMultiply_Mode is used. 7018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param indices If not null, array of indices to reference into the 7028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com vertex (texs, colors) array. 7038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param indexCount number of entries in the indices array (if not null) 7044b226023832011bc3bcdd1e5092ff0645ad0bdeereed@google.com @param paint Specifies the shader/texture if present. 7058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 7068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void drawVertices(VertexMode vmode, int vertexCount, 7078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPoint vertices[], const SkPoint texs[], 7088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkColor colors[], SkXfermode* xmode, 7098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const uint16_t indices[], int indexCount, 7108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPaint& paint); 7118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 712cb60844b34766aad4151df5e87c144d4a57e9abereed@android.com /** Send a blob of data to the canvas. 713cb60844b34766aad4151df5e87c144d4a57e9abereed@android.com For canvases that draw, this call is effectively a no-op, as the data 714cb60844b34766aad4151df5e87c144d4a57e9abereed@android.com is not parsed, but just ignored. However, this call exists for 715cb60844b34766aad4151df5e87c144d4a57e9abereed@android.com subclasses like SkPicture's recording canvas, that can store the data 716cb60844b34766aad4151df5e87c144d4a57e9abereed@android.com and then play it back later (via another call to drawData). 717cb60844b34766aad4151df5e87c144d4a57e9abereed@android.com */ 718cb60844b34766aad4151df5e87c144d4a57e9abereed@android.com virtual void drawData(const void* data, size_t length); 719cb60844b34766aad4151df5e87c144d4a57e9abereed@android.com 7208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com ////////////////////////////////////////////////////////////////////////// 7214b226023832011bc3bcdd1e5092ff0645ad0bdeereed@google.com 7228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Get the current bounder object. 7238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com The bounder's reference count is unchaged. 7248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the canva's bounder (or NULL). 7258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 7268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkBounder* getBounder() const { return fBounder; } 7278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 7288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Set a new bounder (or NULL). 7298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com Pass NULL to clear any previous bounder. 7308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com As a convenience, the parameter passed is also returned. 7318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com If a previous bounder exists, its reference count is decremented. 7328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com If bounder is not NULL, its reference count is incremented. 7338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param bounder the new bounder (or NULL) to be installed in the canvas 7348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the set bounder object 7358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 7368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual SkBounder* setBounder(SkBounder* bounder); 7374b226023832011bc3bcdd1e5092ff0645ad0bdeereed@google.com 7388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Get the current filter object. The filter's reference count is not 739dc3381fc8194a6192af39539c6ac9787b20209d3reed@android.com affected. The filter is saved/restored, just like the matrix and clip. 7408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the canvas' filter (or NULL). 7418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 7428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkDrawFilter* getDrawFilter() const; 7434b226023832011bc3bcdd1e5092ff0645ad0bdeereed@google.com 7448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Set the new filter (or NULL). Pass NULL to clear any existing filter. 7458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com As a convenience, the parameter is returned. If an existing filter 7468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com exists, its refcnt is decrement. If the new filter is not null, its 747dc3381fc8194a6192af39539c6ac9787b20209d3reed@android.com refcnt is incremented. The filter is saved/restored, just like the 748dc3381fc8194a6192af39539c6ac9787b20209d3reed@android.com matrix and clip. 7498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param filter the new filter (or NULL) 7508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the new filter 7518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 7528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual SkDrawFilter* setDrawFilter(SkDrawFilter* filter); 7538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 7548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com ////////////////////////////////////////////////////////////////////////// 7558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 7568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Return the current matrix on the canvas. 7578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com This does not account for the translate in any of the devices. 7588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return The current matrix on the canvas. 7598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 7608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkMatrix& getTotalMatrix() const; 7618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 762bcb671c82a7341253864cda3a5c46d396402d7fbtomhudson@google.com enum ClipType { 763bcb671c82a7341253864cda3a5c46d396402d7fbtomhudson@google.com kEmpty_ClipType = 0, 764bcb671c82a7341253864cda3a5c46d396402d7fbtomhudson@google.com kRect_ClipType, 765bcb671c82a7341253864cda3a5c46d396402d7fbtomhudson@google.com kComplex_ClipType 766bcb671c82a7341253864cda3a5c46d396402d7fbtomhudson@google.com }; 767bcb671c82a7341253864cda3a5c46d396402d7fbtomhudson@google.com 768bcb671c82a7341253864cda3a5c46d396402d7fbtomhudson@google.com /** Returns a description of the total clip; may be cheaper than 769bcb671c82a7341253864cda3a5c46d396402d7fbtomhudson@google.com getting the clip and querying it directly. 770bcb671c82a7341253864cda3a5c46d396402d7fbtomhudson@google.com */ 771bcb671c82a7341253864cda3a5c46d396402d7fbtomhudson@google.com ClipType getClipType() const; 772bcb671c82a7341253864cda3a5c46d396402d7fbtomhudson@google.com 7738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Return the current device clip (concatenation of all clip calls). 7748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com This does not account for the translate in any of the devices. 7758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the current device clip (concatenation of all clip calls). 7768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 7778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkRegion& getTotalClip() const; 7788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 7797d7ca79c3e6e6be7b7849b0d9a7fe26effb89c38reed@google.com /** 7805e2457ef2eba0c3f2e4c8fc89be7f36659e4f3b1reed@google.com * Return true if the current clip is non-empty. 7815e2457ef2eba0c3f2e4c8fc89be7f36659e4f3b1reed@google.com * 7825e2457ef2eba0c3f2e4c8fc89be7f36659e4f3b1reed@google.com * If bounds is not NULL, set it to the bounds of the current clip 7835e2457ef2eba0c3f2e4c8fc89be7f36659e4f3b1reed@google.com * in global coordinates. 7845e2457ef2eba0c3f2e4c8fc89be7f36659e4f3b1reed@google.com */ 7855e2457ef2eba0c3f2e4c8fc89be7f36659e4f3b1reed@google.com bool getTotalClipBounds(SkIRect* bounds) const; 7865e2457ef2eba0c3f2e4c8fc89be7f36659e4f3b1reed@google.com 7875e2457ef2eba0c3f2e4c8fc89be7f36659e4f3b1reed@google.com /** 7887d7ca79c3e6e6be7b7849b0d9a7fe26effb89c38reed@google.com * Return the current clipstack. This mirrors the result in getTotalClip() 7897d7ca79c3e6e6be7b7849b0d9a7fe26effb89c38reed@google.com * but is represented as a stack of geometric clips + region-ops. 7907d7ca79c3e6e6be7b7849b0d9a7fe26effb89c38reed@google.com */ 7917d7ca79c3e6e6be7b7849b0d9a7fe26effb89c38reed@google.com const SkClipStack& getTotalClipStack() const; 7927d7ca79c3e6e6be7b7849b0d9a7fe26effb89c38reed@google.com 793f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com void setExternalMatrix(const SkMatrix* = NULL); 7948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 7958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /////////////////////////////////////////////////////////////////////////// 7968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 7978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** After calling saveLayer(), there can be any number of devices that make 7988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com up the top-most drawing area. LayerIter can be used to iterate through 7998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com those devices. Note that the iterator is only valid until the next API 8008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com call made on the canvas. Ownership of all pointers in the iterator stays 8018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com with the canvas, so none of them should be modified or deleted. 8028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 8037ffb1b21abcc7bbed5a0fc711f6dd7b9dbb4f577ctguil@chromium.org class SK_API LayerIter /*: SkNoncopyable*/ { 8048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com public: 8058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Initialize iterator with canvas, and set values for 1st device */ 8068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com LayerIter(SkCanvas*, bool skipEmptyClips); 8078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com ~LayerIter(); 8084b226023832011bc3bcdd1e5092ff0645ad0bdeereed@google.com 8098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Return true if the iterator is done */ 8108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool done() const { return fDone; } 8118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Cycle to the next device */ 8128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void next(); 8134b226023832011bc3bcdd1e5092ff0645ad0bdeereed@google.com 8148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com // These reflect the current device in the iterator 8158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 8168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkDevice* device() const; 8178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkMatrix& matrix() const; 8188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkRegion& clip() const; 8198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPaint& paint() const; 8208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com int x() const; 8218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com int y() const; 8224b226023832011bc3bcdd1e5092ff0645ad0bdeereed@google.com 8238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com private: 8248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com // used to embed the SkDrawIter object directly in our instance, w/o 8258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com // having to expose that class def to the public. There is an assert 8268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com // in our constructor to ensure that fStorage is large enough 8278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com // (though needs to be a compile-time-assert!). We use intptr_t to work 8288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com // safely with 32 and 64 bit machines (to ensure the storage is enough) 829f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com intptr_t fStorage[32]; 8308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com class SkDrawIter* fImpl; // this points at fStorage 8318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkPaint fDefaultPaint; 8328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool fDone; 8338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com }; 8348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 8358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprotected: 8368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com // all of the drawBitmap variants call this guy 837f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com virtual void commonDrawBitmap(const SkBitmap&, const SkIRect*, 838f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com const SkMatrix&, const SkPaint& paint); 8394b226023832011bc3bcdd1e5092ff0645ad0bdeereed@google.com 8408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprivate: 8418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com class MCRec; 8428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 8435c3d1471e4908706cd053a5e2ea9ded3a6c2eaebreed@google.com SkClipStack fClipStack; 8448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkDeque fMCStack; 8458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com // points to top of stack 8468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com MCRec* fMCRec; 8478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com // the first N recs that can fit here mean we won't call malloc 8488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com uint32_t fMCRecStorage[32]; 8498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 8508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkBounder* fBounder; 851199f108f14a5f60a9c2205ffa79b26102a206ad0reed@android.com SkDevice* fLastDeviceToGainFocus; 8528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 853d302f1401b3c9aea094804bad4e76de98782cfe8bsalomon@google.com void prepareForDeviceDraw(SkDevice*, const SkMatrix&, const SkRegion&, 854d302f1401b3c9aea094804bad4e76de98782cfe8bsalomon@google.com const SkClipStack& clipStack); 8554b226023832011bc3bcdd1e5092ff0645ad0bdeereed@google.com 8568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool fDeviceCMDirty; // cleared by updateDeviceCMCache() 8578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void updateDeviceCMCache(); 8588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 8598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com friend class SkDrawIter; // needs setupDrawForLayerDevice() 8608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 861e97f0856a8044866b12527819d14cdfbcdfd96f2bsalomon@google.com SkDevice* createLayerDevice(SkBitmap::Config, int width, int height, 862e97f0856a8044866b12527819d14cdfbcdfd96f2bsalomon@google.com bool isOpaque); 863e97f0856a8044866b12527819d14cdfbcdfd96f2bsalomon@google.com 8648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkDevice* init(SkDevice*); 865f0b5e1190af9807a027c0adba2f1380663c8e910reed@google.com 866f0b5e1190af9807a027c0adba2f1380663c8e910reed@google.com // internal methods are not virtual, so they can safely be called by other 867f0b5e1190af9807a027c0adba2f1380663c8e910reed@google.com // canvas apis, without confusing subclasses (like SkPictureRecording) 868f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com void internalDrawBitmap(const SkBitmap&, const SkIRect*, const SkMatrix& m, 8698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPaint* paint); 870f0b5e1190af9807a027c0adba2f1380663c8e910reed@google.com void internalDrawBitmapRect(const SkBitmap& bitmap, const SkIRect* src, 871f0b5e1190af9807a027c0adba2f1380663c8e910reed@google.com const SkRect& dst, const SkPaint* paint); 872f0b5e1190af9807a027c0adba2f1380663c8e910reed@google.com void internalDrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, 873f0b5e1190af9807a027c0adba2f1380663c8e910reed@google.com const SkRect& dst, const SkPaint* paint); 874fa6ac938e64fe11b442d05fe8a90ddac2d1951f9bsalomon@google.com void internalDrawPaint(const SkPaint& paint); 875fa6ac938e64fe11b442d05fe8a90ddac2d1951f9bsalomon@google.com 876f0b5e1190af9807a027c0adba2f1380663c8e910reed@google.com 8778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void drawDevice(SkDevice*, int x, int y, const SkPaint*); 8788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com // shared by save() and saveLayer() 8798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com int internalSave(SaveFlags flags); 8808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void internalRestore(); 88152c748b1691f02f90b27c35bc05074fcef709e66bungeman@google.com static void DrawRect(const SkDraw& draw, const SkPaint& paint, 88252c748b1691f02f90b27c35bc05074fcef709e66bungeman@google.com const SkRect& r, SkScalar textSize); 88352c748b1691f02f90b27c35bc05074fcef709e66bungeman@google.com static void DrawTextDecorations(const SkDraw& draw, const SkPaint& paint, 88452c748b1691f02f90b27c35bc05074fcef709e66bungeman@google.com const char text[], size_t byteLength, 88552c748b1691f02f90b27c35bc05074fcef709e66bungeman@google.com SkScalar x, SkScalar y); 8864b226023832011bc3bcdd1e5092ff0645ad0bdeereed@google.com 8878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /* These maintain a cache of the clip bounds in local coordinates, 8888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com (converted to 2s-compliment if floats are slow). 8898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 8908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com mutable SkRectCompareType fLocalBoundsCompareType; 8918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com mutable bool fLocalBoundsCompareTypeDirty; 8928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 893ba09de4c4be66cc07790f23b0f3a925f47340e3ereed@android.com mutable SkRectCompareType fLocalBoundsCompareTypeBW; 894ba09de4c4be66cc07790f23b0f3a925f47340e3ereed@android.com mutable bool fLocalBoundsCompareTypeDirtyBW; 895ba09de4c4be66cc07790f23b0f3a925f47340e3ereed@android.com 896ba09de4c4be66cc07790f23b0f3a925f47340e3ereed@android.com /* Get the local clip bounds with an anti-aliased edge. 897ba09de4c4be66cc07790f23b0f3a925f47340e3ereed@android.com */ 8988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkRectCompareType& getLocalClipBoundsCompareType() const { 899ba09de4c4be66cc07790f23b0f3a925f47340e3ereed@android.com return getLocalClipBoundsCompareType(kAA_EdgeType); 900ba09de4c4be66cc07790f23b0f3a925f47340e3ereed@android.com } 901ba09de4c4be66cc07790f23b0f3a925f47340e3ereed@android.com 902ba09de4c4be66cc07790f23b0f3a925f47340e3ereed@android.com const SkRectCompareType& getLocalClipBoundsCompareType(EdgeType et) const { 903ba09de4c4be66cc07790f23b0f3a925f47340e3ereed@android.com if (et == kAA_EdgeType) { 904ba09de4c4be66cc07790f23b0f3a925f47340e3ereed@android.com if (fLocalBoundsCompareTypeDirty) { 905ba09de4c4be66cc07790f23b0f3a925f47340e3ereed@android.com this->computeLocalClipBoundsCompareType(et); 906ba09de4c4be66cc07790f23b0f3a925f47340e3ereed@android.com fLocalBoundsCompareTypeDirty = false; 907ba09de4c4be66cc07790f23b0f3a925f47340e3ereed@android.com } 908ba09de4c4be66cc07790f23b0f3a925f47340e3ereed@android.com return fLocalBoundsCompareType; 909ba09de4c4be66cc07790f23b0f3a925f47340e3ereed@android.com } else { 910ba09de4c4be66cc07790f23b0f3a925f47340e3ereed@android.com if (fLocalBoundsCompareTypeDirtyBW) { 911ba09de4c4be66cc07790f23b0f3a925f47340e3ereed@android.com this->computeLocalClipBoundsCompareType(et); 912ba09de4c4be66cc07790f23b0f3a925f47340e3ereed@android.com fLocalBoundsCompareTypeDirtyBW = false; 913ba09de4c4be66cc07790f23b0f3a925f47340e3ereed@android.com } 914ba09de4c4be66cc07790f23b0f3a925f47340e3ereed@android.com return fLocalBoundsCompareTypeBW; 9158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 9168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 917ba09de4c4be66cc07790f23b0f3a925f47340e3ereed@android.com void computeLocalClipBoundsCompareType(EdgeType et) const; 918f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com 919f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com SkMatrix fExternalMatrix, fExternalInverse; 920f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com bool fUseExternalMatrix; 9215c3d1471e4908706cd053a5e2ea9ded3a6c2eaebreed@google.com 9225c3d1471e4908706cd053a5e2ea9ded3a6c2eaebreed@google.com class AutoValidateClip : ::SkNoncopyable { 9235c3d1471e4908706cd053a5e2ea9ded3a6c2eaebreed@google.com public: 9245c3d1471e4908706cd053a5e2ea9ded3a6c2eaebreed@google.com explicit AutoValidateClip(SkCanvas* canvas) : fCanvas(canvas) { 9255c3d1471e4908706cd053a5e2ea9ded3a6c2eaebreed@google.com fCanvas->validateClip(); 9265c3d1471e4908706cd053a5e2ea9ded3a6c2eaebreed@google.com } 9275c3d1471e4908706cd053a5e2ea9ded3a6c2eaebreed@google.com ~AutoValidateClip() { fCanvas->validateClip(); } 9285c3d1471e4908706cd053a5e2ea9ded3a6c2eaebreed@google.com 9295c3d1471e4908706cd053a5e2ea9ded3a6c2eaebreed@google.com private: 9305c3d1471e4908706cd053a5e2ea9ded3a6c2eaebreed@google.com const SkCanvas* fCanvas; 9315c3d1471e4908706cd053a5e2ea9ded3a6c2eaebreed@google.com }; 9325c3d1471e4908706cd053a5e2ea9ded3a6c2eaebreed@google.com 9335c3d1471e4908706cd053a5e2ea9ded3a6c2eaebreed@google.com#ifdef SK_DEBUG 9345c3d1471e4908706cd053a5e2ea9ded3a6c2eaebreed@google.com void validateClip() const; 9355c3d1471e4908706cd053a5e2ea9ded3a6c2eaebreed@google.com#else 9365c3d1471e4908706cd053a5e2ea9ded3a6c2eaebreed@google.com void validateClip() const {} 9375c3d1471e4908706cd053a5e2ea9ded3a6c2eaebreed@google.com#endif 9388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}; 9398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 9408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/** Stack helper class to automatically call restoreToCount() on the canvas 9418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com when this object goes out of scope. Use this to guarantee that the canvas 9428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com is restored to a known state. 9438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com*/ 9448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkAutoCanvasRestore : SkNoncopyable { 9458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic: 9468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkAutoCanvasRestore(SkCanvas* canvas, bool doSave) : fCanvas(canvas) { 9478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkASSERT(canvas); 9488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com fSaveCount = canvas->getSaveCount(); 9498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com if (doSave) { 9508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com canvas->save(); 9518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 9528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 9538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com ~SkAutoCanvasRestore() { 9548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com fCanvas->restoreToCount(fSaveCount); 9558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 9568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 9578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprivate: 9588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkCanvas* fCanvas; 9598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com int fSaveCount; 9608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}; 9618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 9628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif 963