SkCanvas.h revision 28361fad1054d59ed4e6a320c7a8b8782a1487c7
18a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/* 2ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Copyright 2006 The Android Open Source Project 38a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * 4ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Use of this source code is governed by a BSD-style license that can be 5ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * found in the LICENSE file. 68a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 78a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 88a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifndef SkCanvas_DEFINED 98a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define SkCanvas_DEFINED 108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkTypes.h" 128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkBitmap.h" 138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkDeque.h" 145c3d1471e4908706cd053a5e2ea9ded3a6c2eaebreed@google.com#include "SkClipStack.h" 158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkPaint.h" 168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkRefCnt.h" 178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkPath.h" 188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkRegion.h" 19845fdaca174f4675e9acc164b510e3a5ffa9053creed@android.com#include "SkXfermode.h" 208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 21b93ba45b58ad24e0e2cb75b842e24ff711c368b0reed@google.com// if not defined, we always assume ClipToLayer for saveLayer() 22b93ba45b58ad24e0e2cb75b842e24ff711c368b0reed@google.com//#define SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG 23b93ba45b58ad24e0e2cb75b842e24ff711c368b0reed@google.com 24b93ba45b58ad24e0e2cb75b842e24ff711c368b0reed@google.com 255c70cdca5efe541b70d010e91607bf8626ea49cacommit-bot@chromium.org//#define SK_SUPPORT_LEGACY_GETCLIPTYPE 265c70cdca5efe541b70d010e91607bf8626ea49cacommit-bot@chromium.org//#define SK_SUPPORT_LEGACY_GETTOTALCLIP 279c135db83d198e7d8200027c7d2cf60f38517ee3reed@google.com//#define SK_SUPPORT_LEGACY_GETTOPDEVICE 284cd9e2169e35cd67ee7358acea6541245e1d1744commit-bot@chromium.org 298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkBounder; 301f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.comclass SkBaseDevice; 318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkDraw; 328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkDrawFilter; 3374bb77ee4c747b8c70c5c613987c9f93df71df06mike@reedtribe.orgclass SkMetaData; 348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkPicture; 354ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.comclass SkRRect; 3676f10a3bd936af7dbe2b5873d5a7eedd73cdc5dareed@google.comclass SkSurface; 3797af1a64ae6bdddd346d8babfd9f188279dd6644reed@google.comclass SkSurface_Base; 38644629c1c7913a43ced172b98d56e0f471bc348bcommit-bot@chromium.orgclass GrContext; 399c135db83d198e7d8200027c7d2cf60f38517ee3reed@google.comclass GrRenderTarget; 408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/** \class SkCanvas 428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com A Canvas encapsulates all of the state about drawing into a device (bitmap). 448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com This includes a reference to the device itself, and a stack of matrix/clip 458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com values. For any given draw call (e.g. drawRect), the geometry of the object 468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com being drawn is transformed by the concatenation of all the matrices in the 478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com stack. The transformed geometry is clipped by the intersection of all of 488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com the clips in the stack. 498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com While the Canvas holds the state of the drawing device, the state (style) 518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com of the object being drawn is held by the Paint, which is provided as a 528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com parameter to each of the draw() methods. The Paint holds attributes such as 538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com color, typeface, textSize, strokeWidth, shader (e.g. gradients, patterns), 548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com etc. 558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com*/ 567ffb1b21abcc7bbed5a0fc711f6dd7b9dbb4f577ctguil@chromium.orgclass SK_API SkCanvas : public SkRefCnt { 578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic: 5815e9d3e66e161ce23df30bc13f8a0c87d196b463robertphillips@google.com SK_DECLARE_INST_COUNT(SkCanvas) 5915e9d3e66e161ce23df30bc13f8a0c87d196b463robertphillips@google.com 60e254310a55d55a710309714c48f7fbbe7a6126f7commit-bot@chromium.org /** 613107b6a85eee7914b37382f7145ab658e8c27667commit-bot@chromium.org * Attempt to allocate an offscreen raster canvas, matching the ImageInfo. 623107b6a85eee7914b37382f7145ab658e8c27667commit-bot@chromium.org * On success, return a new canvas that will draw into that offscreen. 633107b6a85eee7914b37382f7145ab658e8c27667commit-bot@chromium.org * 643107b6a85eee7914b37382f7145ab658e8c27667commit-bot@chromium.org * The caller can access the pixels after drawing into this canvas by 653107b6a85eee7914b37382f7145ab658e8c27667commit-bot@chromium.org * calling readPixels() or peekPixels(). 663107b6a85eee7914b37382f7145ab658e8c27667commit-bot@chromium.org * 673107b6a85eee7914b37382f7145ab658e8c27667commit-bot@chromium.org * If the requested ImageInfo is opaque (either the colortype is 683107b6a85eee7914b37382f7145ab658e8c27667commit-bot@chromium.org * intrinsically opaque like RGB_565, or the info's alphatype is kOpaque) 693107b6a85eee7914b37382f7145ab658e8c27667commit-bot@chromium.org * then the pixel memory may be uninitialized. Otherwise, the pixel memory 703107b6a85eee7914b37382f7145ab658e8c27667commit-bot@chromium.org * will be initialized to 0, which is interpreted as transparent. 713107b6a85eee7914b37382f7145ab658e8c27667commit-bot@chromium.org * 723107b6a85eee7914b37382f7145ab658e8c27667commit-bot@chromium.org * On failure, return NULL. This can fail for several reasons: 733107b6a85eee7914b37382f7145ab658e8c27667commit-bot@chromium.org * 1. the memory allocation failed (e.g. request is too large) 743107b6a85eee7914b37382f7145ab658e8c27667commit-bot@chromium.org * 2. invalid ImageInfo (e.g. negative dimensions) 753107b6a85eee7914b37382f7145ab658e8c27667commit-bot@chromium.org * 3. unsupported ImageInfo for a canvas 763107b6a85eee7914b37382f7145ab658e8c27667commit-bot@chromium.org * - kUnknown_SkColorType, kIndex_8_SkColorType 773107b6a85eee7914b37382f7145ab658e8c27667commit-bot@chromium.org * - kIgnore_SkAlphaType 783107b6a85eee7914b37382f7145ab658e8c27667commit-bot@chromium.org * - this list is not complete, so others may also be unsupported 793107b6a85eee7914b37382f7145ab658e8c27667commit-bot@chromium.org * 803107b6a85eee7914b37382f7145ab658e8c27667commit-bot@chromium.org * Note: it is valid to request a supported ImageInfo, but with zero 813107b6a85eee7914b37382f7145ab658e8c27667commit-bot@chromium.org * dimensions. 823107b6a85eee7914b37382f7145ab658e8c27667commit-bot@chromium.org */ 833107b6a85eee7914b37382f7145ab658e8c27667commit-bot@chromium.org static SkCanvas* NewRaster(const SkImageInfo&); 843107b6a85eee7914b37382f7145ab658e8c27667commit-bot@chromium.org 853107b6a85eee7914b37382f7145ab658e8c27667commit-bot@chromium.org static SkCanvas* NewRasterN32(int width, int height) { 863107b6a85eee7914b37382f7145ab658e8c27667commit-bot@chromium.org return NewRaster(SkImageInfo::MakeN32Premul(width, height)); 873107b6a85eee7914b37382f7145ab658e8c27667commit-bot@chromium.org } 883107b6a85eee7914b37382f7145ab658e8c27667commit-bot@chromium.org 893107b6a85eee7914b37382f7145ab658e8c27667commit-bot@chromium.org /** 9042b08932e81abd8ebf296bede1994d297811511dcommit-bot@chromium.org * Attempt to allocate raster canvas, matching the ImageInfo, that will draw directly into the 9142b08932e81abd8ebf296bede1994d297811511dcommit-bot@chromium.org * specified pixels. To access the pixels after drawing to them, the caller should call 9242b08932e81abd8ebf296bede1994d297811511dcommit-bot@chromium.org * flush() or call peekPixels(...). 9342b08932e81abd8ebf296bede1994d297811511dcommit-bot@chromium.org * 9442b08932e81abd8ebf296bede1994d297811511dcommit-bot@chromium.org * On failure, return NULL. This can fail for several reasons: 9542b08932e81abd8ebf296bede1994d297811511dcommit-bot@chromium.org * 1. invalid ImageInfo (e.g. negative dimensions) 9642b08932e81abd8ebf296bede1994d297811511dcommit-bot@chromium.org * 2. unsupported ImageInfo for a canvas 9742b08932e81abd8ebf296bede1994d297811511dcommit-bot@chromium.org * - kUnknown_SkColorType, kIndex_8_SkColorType 9842b08932e81abd8ebf296bede1994d297811511dcommit-bot@chromium.org * - kIgnore_SkAlphaType 9942b08932e81abd8ebf296bede1994d297811511dcommit-bot@chromium.org * - this list is not complete, so others may also be unsupported 10042b08932e81abd8ebf296bede1994d297811511dcommit-bot@chromium.org * 10142b08932e81abd8ebf296bede1994d297811511dcommit-bot@chromium.org * Note: it is valid to request a supported ImageInfo, but with zero 10242b08932e81abd8ebf296bede1994d297811511dcommit-bot@chromium.org * dimensions. 10342b08932e81abd8ebf296bede1994d297811511dcommit-bot@chromium.org */ 10442b08932e81abd8ebf296bede1994d297811511dcommit-bot@chromium.org static SkCanvas* NewRasterDirect(const SkImageInfo&, void*, size_t); 10542b08932e81abd8ebf296bede1994d297811511dcommit-bot@chromium.org 10642b08932e81abd8ebf296bede1994d297811511dcommit-bot@chromium.org static SkCanvas* NewRasterDirectN32(int width, int height, SkPMColor* pixels, size_t rowBytes) { 10742b08932e81abd8ebf296bede1994d297811511dcommit-bot@chromium.org return NewRasterDirect(SkImageInfo::MakeN32Premul(width, height), pixels, rowBytes); 10842b08932e81abd8ebf296bede1994d297811511dcommit-bot@chromium.org } 10942b08932e81abd8ebf296bede1994d297811511dcommit-bot@chromium.org 11042b08932e81abd8ebf296bede1994d297811511dcommit-bot@chromium.org /** 111e254310a55d55a710309714c48f7fbbe7a6126f7commit-bot@chromium.org * Creates an empty canvas with no backing device/pixels, and zero 112e254310a55d55a710309714c48f7fbbe7a6126f7commit-bot@chromium.org * dimensions. 113e254310a55d55a710309714c48f7fbbe7a6126f7commit-bot@chromium.org */ 114cde92111d50a96b6d0f3e166fbac7c9bc6eca349reed@google.com SkCanvas(); 1158d84fac294682647694b0d2d8a87ac2bd19b6aabvandebo@chromium.org 116e254310a55d55a710309714c48f7fbbe7a6126f7commit-bot@chromium.org /** 117e254310a55d55a710309714c48f7fbbe7a6126f7commit-bot@chromium.org * Creates a canvas of the specified dimensions, but explicitly not backed 118e254310a55d55a710309714c48f7fbbe7a6126f7commit-bot@chromium.org * by any device/pixels. Typically this use used by subclasses who handle 119e254310a55d55a710309714c48f7fbbe7a6126f7commit-bot@chromium.org * the draw calls in some other way. 120e254310a55d55a710309714c48f7fbbe7a6126f7commit-bot@chromium.org */ 121e254310a55d55a710309714c48f7fbbe7a6126f7commit-bot@chromium.org SkCanvas(int width, int height); 122e254310a55d55a710309714c48f7fbbe7a6126f7commit-bot@chromium.org 1236dc745506e6d6cc0936fed4de24443dc1ecb5a34reed@google.com /** Construct a canvas with the specified device to draw into. 124e97f0856a8044866b12527819d14cdfbcdfd96f2bsalomon@google.com 1258d84fac294682647694b0d2d8a87ac2bd19b6aabvandebo@chromium.org @param device Specifies a device for the canvas to draw into. 1268d84fac294682647694b0d2d8a87ac2bd19b6aabvandebo@chromium.org */ 1271f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com explicit SkCanvas(SkBaseDevice* device); 1288d84fac294682647694b0d2d8a87ac2bd19b6aabvandebo@chromium.org 1294469938e92d779dff05e745559e67907bbf21e78reed@google.com /** Construct a canvas with the specified bitmap to draw into. 1308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param bitmap Specifies a bitmap for the canvas to draw into. Its 1318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com structure are copied to the canvas. 1328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 1338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com explicit SkCanvas(const SkBitmap& bitmap); 1348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual ~SkCanvas(); 1358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 13674bb77ee4c747b8c70c5c613987c9f93df71df06mike@reedtribe.org SkMetaData& getMetaData(); 13774bb77ee4c747b8c70c5c613987c9f93df71df06mike@reedtribe.org 138c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org /** 139c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org * Return ImageInfo for this canvas. If the canvas is not backed by pixels 140c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org * (cpu or gpu), then the info's ColorType will be kUnknown_SkColorType. 141c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org */ 142c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org SkImageInfo imageInfo() const; 143c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org 1448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /////////////////////////////////////////////////////////////////////////// 1458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 146210ce003a5ec039dda80de0569fb47ca4efc4dc7reed@google.com /** 147bf6c1e4aff4d233f6502157fb73459cf69d0ab37junov@chromium.org * Trigger the immediate execution of all pending draw operations. 148bf6c1e4aff4d233f6502157fb73459cf69d0ab37junov@chromium.org */ 149bf6c1e4aff4d233f6502157fb73459cf69d0ab37junov@chromium.org void flush(); 150bf6c1e4aff4d233f6502157fb73459cf69d0ab37junov@chromium.org 151bf6c1e4aff4d233f6502157fb73459cf69d0ab37junov@chromium.org /** 1524ebe3821888d550d8a8b89341ec251ba942f0225bsalomon@google.com * Gets the size of the base or root layer in global canvas coordinates. The 1534ebe3821888d550d8a8b89341ec251ba942f0225bsalomon@google.com * origin of the base layer is always (0,0). The current drawable area may be 1544ebe3821888d550d8a8b89341ec251ba942f0225bsalomon@google.com * smaller (due to clipping or saveLayer). 155210ce003a5ec039dda80de0569fb47ca4efc4dc7reed@google.com */ 1564ebe3821888d550d8a8b89341ec251ba942f0225bsalomon@google.com SkISize getBaseLayerSize() const; 1574ebe3821888d550d8a8b89341ec251ba942f0225bsalomon@google.com 1584ebe3821888d550d8a8b89341ec251ba942f0225bsalomon@google.com /** 1594ebe3821888d550d8a8b89341ec251ba942f0225bsalomon@google.com * DEPRECATED: call getBaseLayerSize 1604ebe3821888d550d8a8b89341ec251ba942f0225bsalomon@google.com */ 1614ebe3821888d550d8a8b89341ec251ba942f0225bsalomon@google.com SkISize getDeviceSize() const { return this->getBaseLayerSize(); } 162210ce003a5ec039dda80de0569fb47ca4efc4dc7reed@google.com 163c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org /** 164c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org * DEPRECATED. 165c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org * Return the canvas' device object, which may be null. The device holds 166c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org * the bitmap of the pixels that the canvas draws into. The reference count 167c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org * of the returned device is not changed by this call. 168c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org */ 1691f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com SkBaseDevice* getDevice() const; 1708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1719266fed56a46a4edc710a52c7be8d46fd7c2bc7areed@google.com /** 1729266fed56a46a4edc710a52c7be8d46fd7c2bc7areed@google.com * saveLayer() can create another device (which is later drawn onto 1739266fed56a46a4edc710a52c7be8d46fd7c2bc7areed@google.com * the previous device). getTopDevice() returns the top-most device current 1749266fed56a46a4edc710a52c7be8d46fd7c2bc7areed@google.com * installed. Note that this can change on other calls like save/restore, 1759266fed56a46a4edc710a52c7be8d46fd7c2bc7areed@google.com * so do not access this device after subsequent canvas calls. 1769266fed56a46a4edc710a52c7be8d46fd7c2bc7areed@google.com * The reference count of the device is not changed. 1770b53d59a24f667350b4282f88470713902409030reed@google.com * 1780b53d59a24f667350b4282f88470713902409030reed@google.com * @param updateMatrixClip If this is true, then before the device is 1790b53d59a24f667350b4282f88470713902409030reed@google.com * returned, we ensure that its has been notified about the current 1800b53d59a24f667350b4282f88470713902409030reed@google.com * matrix and clip. Note: this happens automatically when the device 1810b53d59a24f667350b4282f88470713902409030reed@google.com * is drawn to, but is optional here, as there is a small perf hit 1820b53d59a24f667350b4282f88470713902409030reed@google.com * sometimes. 1839266fed56a46a4edc710a52c7be8d46fd7c2bc7areed@google.com */ 1849c135db83d198e7d8200027c7d2cf60f38517ee3reed@google.com#ifndef SK_SUPPORT_LEGACY_GETTOPDEVICE 1859c135db83d198e7d8200027c7d2cf60f38517ee3reed@google.comprivate: 1869c135db83d198e7d8200027c7d2cf60f38517ee3reed@google.com#endif 1871f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com SkBaseDevice* getTopDevice(bool updateMatrixClip = false) const; 1889c135db83d198e7d8200027c7d2cf60f38517ee3reed@google.compublic: 1899266fed56a46a4edc710a52c7be8d46fd7c2bc7areed@google.com 19076f10a3bd936af7dbe2b5873d5a7eedd73cdc5dareed@google.com /** 19176f10a3bd936af7dbe2b5873d5a7eedd73cdc5dareed@google.com * Create a new surface matching the specified info, one that attempts to 19276f10a3bd936af7dbe2b5873d5a7eedd73cdc5dareed@google.com * be maximally compatible when used with this canvas. 19376f10a3bd936af7dbe2b5873d5a7eedd73cdc5dareed@google.com */ 19476f10a3bd936af7dbe2b5873d5a7eedd73cdc5dareed@google.com SkSurface* newSurface(const SkImageInfo&); 195e97f0856a8044866b12527819d14cdfbcdfd96f2bsalomon@google.com 196644629c1c7913a43ced172b98d56e0f471bc348bcommit-bot@chromium.org /** 197644629c1c7913a43ced172b98d56e0f471bc348bcommit-bot@chromium.org * Return the GPU context of the device that is associated with the canvas. 198644629c1c7913a43ced172b98d56e0f471bc348bcommit-bot@chromium.org * For a canvas with non-GPU device, NULL is returned. 199644629c1c7913a43ced172b98d56e0f471bc348bcommit-bot@chromium.org */ 200644629c1c7913a43ced172b98d56e0f471bc348bcommit-bot@chromium.org GrContext* getGrContext(); 201644629c1c7913a43ced172b98d56e0f471bc348bcommit-bot@chromium.org 2024b226023832011bc3bcdd1e5092ff0645ad0bdeereed@google.com /////////////////////////////////////////////////////////////////////////// 2034b226023832011bc3bcdd1e5092ff0645ad0bdeereed@google.com 204daba14b7d4fc96b915c45d82713b22729c0d0f37bsalomon@google.com /** 2059c135db83d198e7d8200027c7d2cf60f38517ee3reed@google.com * If the canvas has writable pixels in its top layer (and is not recording to a picture 2069c135db83d198e7d8200027c7d2cf60f38517ee3reed@google.com * or other non-raster target) and has direct access to its pixels (i.e. they are in 2079c135db83d198e7d8200027c7d2cf60f38517ee3reed@google.com * local RAM) return the address of those pixels, and if not null, 2089c135db83d198e7d8200027c7d2cf60f38517ee3reed@google.com * return the ImageInfo and rowBytes. The returned address is only valid 2099c135db83d198e7d8200027c7d2cf60f38517ee3reed@google.com * while the canvas object is in scope and unchanged. Any API calls made on 2109c135db83d198e7d8200027c7d2cf60f38517ee3reed@google.com * canvas (or its parent surface if any) will invalidate the 2119c135db83d198e7d8200027c7d2cf60f38517ee3reed@google.com * returned address (and associated information). 2129c135db83d198e7d8200027c7d2cf60f38517ee3reed@google.com * 2139c135db83d198e7d8200027c7d2cf60f38517ee3reed@google.com * On failure, returns NULL and the info and rowBytes parameters are 2149c135db83d198e7d8200027c7d2cf60f38517ee3reed@google.com * ignored. 2159c135db83d198e7d8200027c7d2cf60f38517ee3reed@google.com */ 2169c135db83d198e7d8200027c7d2cf60f38517ee3reed@google.com void* accessTopLayerPixels(SkImageInfo* info, size_t* rowBytes); 2179c135db83d198e7d8200027c7d2cf60f38517ee3reed@google.com 2189c135db83d198e7d8200027c7d2cf60f38517ee3reed@google.com /** 2199c135db83d198e7d8200027c7d2cf60f38517ee3reed@google.com * If the canvas has readable pixels in its base layer (and is not recording to a picture 2209c135db83d198e7d8200027c7d2cf60f38517ee3reed@google.com * or other non-raster target) and has direct access to its pixels (i.e. they are in 221c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org * local RAM) return the const-address of those pixels, and if not null, 222c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org * return the ImageInfo and rowBytes. The returned address is only valid 223c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org * while the canvas object is in scope and unchanged. Any API calls made on 224c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org * canvas (or its parent surface if any) will invalidate the 225c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org * returned address (and associated information). 226c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org * 227c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org * On failure, returns NULL and the info and rowBytes parameters are 228c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org * ignored. 229c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org */ 230c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org const void* peekPixels(SkImageInfo* info, size_t* rowBytes); 231c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org 232a713f9c6f6a06d216d53e268b9c691941053dabfcommit-bot@chromium.org /** 233a713f9c6f6a06d216d53e268b9c691941053dabfcommit-bot@chromium.org * Copy the pixels from the base-layer into the specified buffer (pixels + rowBytes), 234a713f9c6f6a06d216d53e268b9c691941053dabfcommit-bot@chromium.org * converting them into the requested format (SkImageInfo). The base-layer pixels are read 235a713f9c6f6a06d216d53e268b9c691941053dabfcommit-bot@chromium.org * starting at the specified (x,y) location in the coordinate system of the base-layer. 236a713f9c6f6a06d216d53e268b9c691941053dabfcommit-bot@chromium.org * 237a713f9c6f6a06d216d53e268b9c691941053dabfcommit-bot@chromium.org * The specified ImageInfo and (x,y) offset specifies a source rectangle 238a713f9c6f6a06d216d53e268b9c691941053dabfcommit-bot@chromium.org * 239a713f9c6f6a06d216d53e268b9c691941053dabfcommit-bot@chromium.org * srcR(x, y, info.width(), info.height()); 240a713f9c6f6a06d216d53e268b9c691941053dabfcommit-bot@chromium.org * 241a713f9c6f6a06d216d53e268b9c691941053dabfcommit-bot@chromium.org * SrcR is intersected with the bounds of the base-layer. If this intersection is not empty, 242a713f9c6f6a06d216d53e268b9c691941053dabfcommit-bot@chromium.org * then we have two sets of pixels (of equal size), the "src" specified by base-layer at (x,y) 243a713f9c6f6a06d216d53e268b9c691941053dabfcommit-bot@chromium.org * and the "dst" by info+pixels+rowBytes. Replace the dst pixels with the corresponding src 244a713f9c6f6a06d216d53e268b9c691941053dabfcommit-bot@chromium.org * pixels, performing any colortype/alphatype transformations needed (in the case where the 245a713f9c6f6a06d216d53e268b9c691941053dabfcommit-bot@chromium.org * src and dst have different colortypes or alphatypes). 246a713f9c6f6a06d216d53e268b9c691941053dabfcommit-bot@chromium.org * 247a713f9c6f6a06d216d53e268b9c691941053dabfcommit-bot@chromium.org * This call can fail, returning false, for several reasons: 248a713f9c6f6a06d216d53e268b9c691941053dabfcommit-bot@chromium.org * - If the requested colortype/alphatype cannot be converted from the base-layer's types. 249a713f9c6f6a06d216d53e268b9c691941053dabfcommit-bot@chromium.org * - If this canvas is not backed by pixels (e.g. picture or PDF) 250a713f9c6f6a06d216d53e268b9c691941053dabfcommit-bot@chromium.org */ 251a713f9c6f6a06d216d53e268b9c691941053dabfcommit-bot@chromium.org bool readPixels(const SkImageInfo&, void* pixels, size_t rowBytes, int x, int y); 252a713f9c6f6a06d216d53e268b9c691941053dabfcommit-bot@chromium.org 253a713f9c6f6a06d216d53e268b9c691941053dabfcommit-bot@chromium.org /** 254a713f9c6f6a06d216d53e268b9c691941053dabfcommit-bot@chromium.org * Helper for calling readPixels(info, ...). This call will check if bitmap has been allocated. 255a713f9c6f6a06d216d53e268b9c691941053dabfcommit-bot@chromium.org * If not, it will attempt to call allocPixels(). If this fails, it will return false. If not, 256a713f9c6f6a06d216d53e268b9c691941053dabfcommit-bot@chromium.org * it calls through to readPixels(info, ...) and returns its result. 257a713f9c6f6a06d216d53e268b9c691941053dabfcommit-bot@chromium.org */ 258a713f9c6f6a06d216d53e268b9c691941053dabfcommit-bot@chromium.org bool readPixels(SkBitmap* bitmap, int x, int y); 259c69809745e6496564639e42ef998ad39adf7dfb8bsalomon@google.com 2604b226023832011bc3bcdd1e5092ff0645ad0bdeereed@google.com /** 261a713f9c6f6a06d216d53e268b9c691941053dabfcommit-bot@chromium.org * Helper for allocating pixels and then calling readPixels(info, ...). The bitmap is resized 262a713f9c6f6a06d216d53e268b9c691941053dabfcommit-bot@chromium.org * to the intersection of srcRect and the base-layer bounds. On success, pixels will be 263a713f9c6f6a06d216d53e268b9c691941053dabfcommit-bot@chromium.org * allocated in bitmap and true returned. On failure, false is returned and bitmap will be 264a713f9c6f6a06d216d53e268b9c691941053dabfcommit-bot@chromium.org * set to empty. 26551df9e3fe3c1aec370854b2718df16fc02faa1b2reed@google.com */ 26651df9e3fe3c1aec370854b2718df16fc02faa1b2reed@google.com bool readPixels(const SkIRect& srcRect, SkBitmap* bitmap); 26751df9e3fe3c1aec370854b2718df16fc02faa1b2reed@google.com 2684cd9e2169e35cd67ee7358acea6541245e1d1744commit-bot@chromium.org /** 2694cd9e2169e35cd67ee7358acea6541245e1d1744commit-bot@chromium.org * This method affects the pixels in the base-layer, and operates in pixel coordinates, 2704cd9e2169e35cd67ee7358acea6541245e1d1744commit-bot@chromium.org * ignoring the matrix and clip. 2714cd9e2169e35cd67ee7358acea6541245e1d1744commit-bot@chromium.org * 2724cd9e2169e35cd67ee7358acea6541245e1d1744commit-bot@chromium.org * The specified ImageInfo and (x,y) offset specifies a rectangle: target. 2734cd9e2169e35cd67ee7358acea6541245e1d1744commit-bot@chromium.org * 2744cd9e2169e35cd67ee7358acea6541245e1d1744commit-bot@chromium.org * target.setXYWH(x, y, info.width(), info.height()); 2754cd9e2169e35cd67ee7358acea6541245e1d1744commit-bot@chromium.org * 2764cd9e2169e35cd67ee7358acea6541245e1d1744commit-bot@chromium.org * Target is intersected with the bounds of the base-layer. If this intersection is not empty, 2774cd9e2169e35cd67ee7358acea6541245e1d1744commit-bot@chromium.org * then we have two sets of pixels (of equal size), the "src" specified by info+pixels+rowBytes 2784cd9e2169e35cd67ee7358acea6541245e1d1744commit-bot@chromium.org * and the "dst" by the canvas' backend. Replace the dst pixels with the corresponding src 2794cd9e2169e35cd67ee7358acea6541245e1d1744commit-bot@chromium.org * pixels, performing any colortype/alphatype transformations needed (in the case where the 2804cd9e2169e35cd67ee7358acea6541245e1d1744commit-bot@chromium.org * src and dst have different colortypes or alphatypes). 2814cd9e2169e35cd67ee7358acea6541245e1d1744commit-bot@chromium.org * 2824cd9e2169e35cd67ee7358acea6541245e1d1744commit-bot@chromium.org * This call can fail, returning false, for several reasons: 2834cd9e2169e35cd67ee7358acea6541245e1d1744commit-bot@chromium.org * - If the src colortype/alphatype cannot be converted to the canvas' types 2844cd9e2169e35cd67ee7358acea6541245e1d1744commit-bot@chromium.org * - If this canvas is not backed by pixels (e.g. picture or PDF) 2854cd9e2169e35cd67ee7358acea6541245e1d1744commit-bot@chromium.org */ 2864cd9e2169e35cd67ee7358acea6541245e1d1744commit-bot@chromium.org bool writePixels(const SkImageInfo&, const void* pixels, size_t rowBytes, int x, int y); 2874cd9e2169e35cd67ee7358acea6541245e1d1744commit-bot@chromium.org 2884cd9e2169e35cd67ee7358acea6541245e1d1744commit-bot@chromium.org /** 2894cd9e2169e35cd67ee7358acea6541245e1d1744commit-bot@chromium.org * Helper for calling writePixels(info, ...) by passing its pixels and rowbytes. If the bitmap 2904cd9e2169e35cd67ee7358acea6541245e1d1744commit-bot@chromium.org * is just wrapping a texture, returns false and does nothing. 2914cd9e2169e35cd67ee7358acea6541245e1d1744commit-bot@chromium.org */ 2924cd9e2169e35cd67ee7358acea6541245e1d1744commit-bot@chromium.org bool writePixels(const SkBitmap& bitmap, int x, int y); 2934b226023832011bc3bcdd1e5092ff0645ad0bdeereed@google.com 2948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /////////////////////////////////////////////////////////////////////////// 2958d84fac294682647694b0d2d8a87ac2bd19b6aabvandebo@chromium.org 2968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com enum SaveFlags { 2978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** save the matrix state, restoring it on restore() */ 2988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kMatrix_SaveFlag = 0x01, 2998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** save the clip state, restoring it on restore() */ 3008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kClip_SaveFlag = 0x02, 3018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** the layer needs to support per-pixel alpha */ 3028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kHasAlphaLayer_SaveFlag = 0x04, 3038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** the layer needs to support 8-bits per color component */ 3048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kFullColorLayer_SaveFlag = 0x08, 305b93ba45b58ad24e0e2cb75b842e24ff711c368b0reed@google.com /** 306b93ba45b58ad24e0e2cb75b842e24ff711c368b0reed@google.com * the layer should clip against the bounds argument 307b93ba45b58ad24e0e2cb75b842e24ff711c368b0reed@google.com * 308b93ba45b58ad24e0e2cb75b842e24ff711c368b0reed@google.com * if SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG is undefined, this is treated as always on. 309b93ba45b58ad24e0e2cb75b842e24ff711c368b0reed@google.com */ 3108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kClipToLayer_SaveFlag = 0x10, 3118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com // helper masks for common choices 3138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kMatrixClip_SaveFlag = 0x03, 314b93ba45b58ad24e0e2cb75b842e24ff711c368b0reed@google.com#ifdef SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG 3158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kARGB_NoClipLayer_SaveFlag = 0x0F, 316b93ba45b58ad24e0e2cb75b842e24ff711c368b0reed@google.com#endif 3178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kARGB_ClipLayer_SaveFlag = 0x1F 3188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com }; 3198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 320dc3381fc8194a6192af39539c6ac9787b20209d3reed@android.com /** This call saves the current matrix, clip, and drawFilter, and pushes a 3218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com copy onto a private stack. Subsequent calls to translate, scale, 322dc3381fc8194a6192af39539c6ac9787b20209d3reed@android.com rotate, skew, concat or clipRect, clipPath, and setDrawFilter all 323dc3381fc8194a6192af39539c6ac9787b20209d3reed@android.com operate on this copy. 324dc3381fc8194a6192af39539c6ac9787b20209d3reed@android.com When the balancing call to restore() is made, the previous matrix, clip, 325dc3381fc8194a6192af39539c6ac9787b20209d3reed@android.com and drawFilter are restored. 326d4236574cfe4ec333d20e7a30f37e084168bb050djsollen@google.com @param flags The flags govern what portion of the Matrix/Clip/drawFilter 327d4236574cfe4ec333d20e7a30f37e084168bb050djsollen@google.com state the save (and matching restore) effect. For example, 328d4236574cfe4ec333d20e7a30f37e084168bb050djsollen@google.com if only kMatrix is specified, then only the matrix state 329d4236574cfe4ec333d20e7a30f37e084168bb050djsollen@google.com will be pushed and popped. Likewise for the clip if kClip 330d4236574cfe4ec333d20e7a30f37e084168bb050djsollen@google.com is specified. However, the drawFilter is always affected 331d4236574cfe4ec333d20e7a30f37e084168bb050djsollen@google.com by calls to save/restore. 3328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return The value to pass to restoreToCount() to balance this save() 3338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 334e54a23fcfa42b2fc9d320650de72bcb2d9566b2dcommit-bot@chromium.org int save(SaveFlags flags = kMatrixClip_SaveFlag); 3358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** This behaves the same as save(), but in addition it allocates an 3378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com offscreen bitmap. All drawing calls are directed there, and only when 3388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com the balancing call to restore() is made is that offscreen transfered to 339dc3381fc8194a6192af39539c6ac9787b20209d3reed@android.com the canvas (or the previous layer). 340ad164b2025cba65131ca68221a6ea7640d7b1de8reed@android.com @param bounds (may be null) This rect, if non-null, is used as a hint to 341ad164b2025cba65131ca68221a6ea7640d7b1de8reed@android.com limit the size of the offscreen, and thus drawing may be 342ad164b2025cba65131ca68221a6ea7640d7b1de8reed@android.com clipped to it, though that clipping is not guaranteed to 343ad164b2025cba65131ca68221a6ea7640d7b1de8reed@android.com happen. If exact clipping is desired, use clipRect(). 3448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param paint (may be null) This is copied, and is applied to the 3458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com offscreen when restore() is called 3468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param flags LayerFlags 3478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return The value to pass to restoreToCount() to balance this save() 3488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 349e54a23fcfa42b2fc9d320650de72bcb2d9566b2dcommit-bot@chromium.org int saveLayer(const SkRect* bounds, const SkPaint* paint, 350e54a23fcfa42b2fc9d320650de72bcb2d9566b2dcommit-bot@chromium.org SaveFlags flags = kARGB_ClipLayer_SaveFlag); 3518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** This behaves the same as save(), but in addition it allocates an 3538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com offscreen bitmap. All drawing calls are directed there, and only when 3548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com the balancing call to restore() is made is that offscreen transfered to 355dc3381fc8194a6192af39539c6ac9787b20209d3reed@android.com the canvas (or the previous layer). 35640408614655c4057d93842c9b0f09aa6dfff9e02reed@android.com @param bounds (may be null) This rect, if non-null, is used as a hint to 35740408614655c4057d93842c9b0f09aa6dfff9e02reed@android.com limit the size of the offscreen, and thus drawing may be 35840408614655c4057d93842c9b0f09aa6dfff9e02reed@android.com clipped to it, though that clipping is not guaranteed to 35940408614655c4057d93842c9b0f09aa6dfff9e02reed@android.com happen. If exact clipping is desired, use clipRect(). 3608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param alpha This is applied to the offscreen when restore() is called. 3618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param flags LayerFlags 3628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return The value to pass to restoreToCount() to balance this save() 3638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 3648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com int saveLayerAlpha(const SkRect* bounds, U8CPU alpha, 3658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SaveFlags flags = kARGB_ClipLayer_SaveFlag); 3668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** This call balances a previous call to save(), and is used to remove all 368dc3381fc8194a6192af39539c6ac9787b20209d3reed@android.com modifications to the matrix/clip/drawFilter state since the last save 369dc3381fc8194a6192af39539c6ac9787b20209d3reed@android.com call. 370dc3381fc8194a6192af39539c6ac9787b20209d3reed@android.com It is an error to call restore() more times than save() was called. 3718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 372e54a23fcfa42b2fc9d320650de72bcb2d9566b2dcommit-bot@chromium.org void restore(); 3738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Returns the number of matrix/clip states on the SkCanvas' private stack. 375ea7d08e3bbc45a0a573c1ac06afa4452f8d7000acommit-bot@chromium.org This will equal # save() calls - # restore() calls + 1. The save count on 376ea7d08e3bbc45a0a573c1ac06afa4452f8d7000acommit-bot@chromium.org a new canvas is 1. 3778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 378a907ac3e3e3458fbb5d673c3feafb31fd7647b38junov@chromium.org int getSaveCount() const; 3798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Efficient way to pop any calls to save() that happened after the save 381ea7d08e3bbc45a0a573c1ac06afa4452f8d7000acommit-bot@chromium.org count reached saveCount. It is an error for saveCount to be greater than 382ea7d08e3bbc45a0a573c1ac06afa4452f8d7000acommit-bot@chromium.org getSaveCount(). To pop all the way back to the initial matrix/clip context 383ea7d08e3bbc45a0a573c1ac06afa4452f8d7000acommit-bot@chromium.org pass saveCount == 1. 3848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param saveCount The number of save() levels to restore from 3858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 3868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void restoreToCount(int saveCount); 3878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3887c2029367cea5479fa3b74fb0ca2b0297b42b709reed@google.com /** Returns true if drawing is currently going to a layer (from saveLayer) 3897c2029367cea5479fa3b74fb0ca2b0297b42b709reed@google.com * rather than to the root device. 3907c2029367cea5479fa3b74fb0ca2b0297b42b709reed@google.com */ 3918f9ecbd3466d4330886b4c23b06e75b468c795adjunov@chromium.org virtual bool isDrawingToLayer() const; 3927c2029367cea5479fa3b74fb0ca2b0297b42b709reed@google.com 3938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Preconcat the current matrix with the specified translation 3948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param dx The distance to translate in X 3958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param dy The distance to translate in Y 3968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 39792362383a4de7b0d819c88fa8b74242bb2507602commit-bot@chromium.org void translate(SkScalar dx, SkScalar dy); 3988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Preconcat the current matrix with the specified scale. 4008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param sx The amount to scale in X 4018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param sy The amount to scale in Y 4028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 40392362383a4de7b0d819c88fa8b74242bb2507602commit-bot@chromium.org void scale(SkScalar sx, SkScalar sy); 4048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Preconcat the current matrix with the specified rotation. 4068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param degrees The amount to rotate, in degrees 4078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 40892362383a4de7b0d819c88fa8b74242bb2507602commit-bot@chromium.org void rotate(SkScalar degrees); 4098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Preconcat the current matrix with the specified skew. 4118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param sx The amount to skew in X 4128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param sy The amount to skew in Y 4138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 41492362383a4de7b0d819c88fa8b74242bb2507602commit-bot@chromium.org void skew(SkScalar sx, SkScalar sy); 4158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Preconcat the current matrix with the specified matrix. 4178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param matrix The matrix to preconcatenate with the current matrix 4188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 41992362383a4de7b0d819c88fa8b74242bb2507602commit-bot@chromium.org void concat(const SkMatrix& matrix); 4204b226023832011bc3bcdd1e5092ff0645ad0bdeereed@google.com 4218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Replace the current matrix with a copy of the specified matrix. 4228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param matrix The matrix that will be copied into the current matrix. 4238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 42444c48d062f7996b5b46917e1b312a32ad101f326commit-bot@chromium.org void setMatrix(const SkMatrix& matrix); 4254b226023832011bc3bcdd1e5092ff0645ad0bdeereed@google.com 4268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Helper for setMatrix(identity). Sets the current matrix to identity. 4278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 4288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void resetMatrix(); 4298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4304ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com /** 4314ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com * Modify the current clip with the specified rectangle. 4324ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com * @param rect The rect to combine with the current clip 4334ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com * @param op The region op to apply to the current clip 4344ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com * @param doAntiAlias true if the clip should be antialiased 4354ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com */ 436759cf4846804be137229393e04925752423de2d0commit-bot@chromium.org void clipRect(const SkRect& rect, 437759cf4846804be137229393e04925752423de2d0commit-bot@chromium.org SkRegion::Op op = SkRegion::kIntersect_Op, 438759cf4846804be137229393e04925752423de2d0commit-bot@chromium.org bool doAntiAlias = false); 4398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4404ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com /** 4414ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com * Modify the current clip with the specified SkRRect. 4424ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com * @param rrect The rrect to combine with the current clip 4434ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com * @param op The region op to apply to the current clip 4444ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com * @param doAntiAlias true if the clip should be antialiased 4454ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com */ 446759cf4846804be137229393e04925752423de2d0commit-bot@chromium.org void clipRRect(const SkRRect& rrect, 447759cf4846804be137229393e04925752423de2d0commit-bot@chromium.org SkRegion::Op op = SkRegion::kIntersect_Op, 448759cf4846804be137229393e04925752423de2d0commit-bot@chromium.org bool doAntiAlias = false); 4494ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com 4504ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com /** 4514ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com * Modify the current clip with the specified path. 4524ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com * @param path The path to combine with the current clip 4534ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com * @param op The region op to apply to the current clip 4544ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com * @param doAntiAlias true if the clip should be antialiased 4554ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com */ 456759cf4846804be137229393e04925752423de2d0commit-bot@chromium.org void clipPath(const SkPath& path, 457759cf4846804be137229393e04925752423de2d0commit-bot@chromium.org SkRegion::Op op = SkRegion::kIntersect_Op, 458759cf4846804be137229393e04925752423de2d0commit-bot@chromium.org bool doAntiAlias = false); 4598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4608f0a7b8e7334187a5d7d5ab7fde5a3c3009555f5caryclark@google.com /** EXPERIMENTAL -- only used for testing 4618f0a7b8e7334187a5d7d5ab7fde5a3c3009555f5caryclark@google.com Set to false to force clips to be hard, even if doAntiAlias=true is 4628f0a7b8e7334187a5d7d5ab7fde5a3c3009555f5caryclark@google.com passed to clipRect or clipPath. 4638f0a7b8e7334187a5d7d5ab7fde5a3c3009555f5caryclark@google.com */ 4648f0a7b8e7334187a5d7d5ab7fde5a3c3009555f5caryclark@google.com void setAllowSoftClip(bool allow) { 4658f0a7b8e7334187a5d7d5ab7fde5a3c3009555f5caryclark@google.com fAllowSoftClip = allow; 4668f0a7b8e7334187a5d7d5ab7fde5a3c3009555f5caryclark@google.com } 4678f0a7b8e7334187a5d7d5ab7fde5a3c3009555f5caryclark@google.com 46845a75fb4d0ca5daa0ac5e634238970306e3b5838caryclark@google.com /** EXPERIMENTAL -- only used for testing 46945a75fb4d0ca5daa0ac5e634238970306e3b5838caryclark@google.com Set to simplify clip stack using path ops. 47045a75fb4d0ca5daa0ac5e634238970306e3b5838caryclark@google.com */ 47145a75fb4d0ca5daa0ac5e634238970306e3b5838caryclark@google.com void setAllowSimplifyClip(bool allow) { 47245a75fb4d0ca5daa0ac5e634238970306e3b5838caryclark@google.com fAllowSimplifyClip = allow; 47345a75fb4d0ca5daa0ac5e634238970306e3b5838caryclark@google.com } 47445a75fb4d0ca5daa0ac5e634238970306e3b5838caryclark@google.com 4758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Modify the current clip with the specified region. Note that unlike 4768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com clipRect() and clipPath() which transform their arguments by the current 4778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com matrix, clipRegion() assumes its argument is already in device 4788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com coordinates, and so no transformation is performed. 4798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param deviceRgn The region to apply to the current clip 4808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param op The region op to apply to the current clip 4818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 482759cf4846804be137229393e04925752423de2d0commit-bot@chromium.org void clipRegion(const SkRegion& deviceRgn, 483759cf4846804be137229393e04925752423de2d0commit-bot@chromium.org SkRegion::Op op = SkRegion::kIntersect_Op); 4848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Helper for clipRegion(rgn, kReplace_Op). Sets the current clip to the 4868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com specified region. This does not intersect or in any other way account 4878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com for the existing clip region. 4888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param deviceRgn The region to copy into the current clip. 4898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 4908f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com void setClipRegion(const SkRegion& deviceRgn) { 4918f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com this->clipRegion(deviceRgn, SkRegion::kReplace_Op); 4928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 4938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Return true if the specified rectangle, after being transformed by the 4958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com current matrix, would lie completely outside of the current clip. Call 4968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com this to check if an area you intend to draw into is clipped out (and 4978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com therefore you can skip making the draw calls). 4988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param rect the rect to compare with the current clip 4998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return true if the rect (transformed by the canvas' matrix) does not 5008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com intersect with the canvas' clip 5018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 5023b3e895df6f8ee0f33010367c215944cd16a8334reed@google.com bool quickReject(const SkRect& rect) const; 5038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 5048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Return true if the specified path, after being transformed by the 5058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com current matrix, would lie completely outside of the current clip. Call 5068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com this to check if an area you intend to draw into is clipped out (and 5078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com therefore you can skip making the draw calls). Note, for speed it may 5088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com return false even if the path itself might not intersect the clip 5098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com (i.e. the bounds of the path intersects, but the path does not). 5108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param path The path to compare with the current clip 5118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return true if the path (transformed by the canvas' matrix) does not 5128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com intersect with the canvas' clip 5138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 5143b3e895df6f8ee0f33010367c215944cd16a8334reed@google.com bool quickReject(const SkPath& path) const; 5158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 5168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Return true if the horizontal band specified by top and bottom is 5178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com completely clipped out. This is a conservative calculation, meaning 5188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com that it is possible that if the method returns false, the band may still 5198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com in fact be clipped out, but the converse is not true. If this method 5208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com returns true, then the band is guaranteed to be clipped out. 5218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param top The top of the horizontal band to compare with the clip 5228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param bottom The bottom of the horizontal and to compare with the clip 5238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return true if the horizontal band is completely clipped out (i.e. does 5248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com not intersect the current clip) 5258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 5263b3e895df6f8ee0f33010367c215944cd16a8334reed@google.com bool quickRejectY(SkScalar top, SkScalar bottom) const { 527c0784dbd408596aff13a5d97448f7a9e5d3cf7d9reed@google.com SkASSERT(top <= bottom); 5289836bc3fdddd51ed050102d03916cc5c7928dcc6commit-bot@chromium.org 5299836bc3fdddd51ed050102d03916cc5c7928dcc6commit-bot@chromium.org#ifndef SK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT 5309836bc3fdddd51ed050102d03916cc5c7928dcc6commit-bot@chromium.org // TODO: add a hasPerspective method similar to getLocalClipBounds. This 5319836bc3fdddd51ed050102d03916cc5c7928dcc6commit-bot@chromium.org // would cache the SkMatrix::hasPerspective result. Alternatively, have 5329836bc3fdddd51ed050102d03916cc5c7928dcc6commit-bot@chromium.org // the MC stack just set a hasPerspective boolean as it is updated. 5339836bc3fdddd51ed050102d03916cc5c7928dcc6commit-bot@chromium.org if (this->getTotalMatrix().hasPerspective()) { 534a3b532743dbb1d54a4c17a2574083ef93c949d50skia.committer@gmail.com // TODO: consider implementing some half-plane test between the 5359836bc3fdddd51ed050102d03916cc5c7928dcc6commit-bot@chromium.org // two Y planes and the device-bounds (i.e., project the top and 5369836bc3fdddd51ed050102d03916cc5c7928dcc6commit-bot@chromium.org // bottom Y planes and then determine if the clip bounds is completely 5379836bc3fdddd51ed050102d03916cc5c7928dcc6commit-bot@chromium.org // outside either one). 5389836bc3fdddd51ed050102d03916cc5c7928dcc6commit-bot@chromium.org return false; 5399836bc3fdddd51ed050102d03916cc5c7928dcc6commit-bot@chromium.org } 5409836bc3fdddd51ed050102d03916cc5c7928dcc6commit-bot@chromium.org#endif 5419836bc3fdddd51ed050102d03916cc5c7928dcc6commit-bot@chromium.org 542c0784dbd408596aff13a5d97448f7a9e5d3cf7d9reed@google.com const SkRect& clipR = this->getLocalClipBounds(); 54392d2a299d2738e4369508ea1296981a2f1f8aadbdjsollen@google.com // In the case where the clip is empty and we are provided with a 54492d2a299d2738e4369508ea1296981a2f1f8aadbdjsollen@google.com // negative top and positive bottom parameter then this test will return 54592d2a299d2738e4369508ea1296981a2f1f8aadbdjsollen@google.com // false even though it will be clipped. We have chosen to exclude that 54692d2a299d2738e4369508ea1296981a2f1f8aadbdjsollen@google.com // check as it is rare and would result double the comparisons. 547c0784dbd408596aff13a5d97448f7a9e5d3cf7d9reed@google.com return top >= clipR.fBottom || bottom <= clipR.fTop; 54892d2a299d2738e4369508ea1296981a2f1f8aadbdjsollen@google.com } 5498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 5508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Return the bounds of the current clip (in local coordinates) in the 5518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bounds parameter, and return true if it is non-empty. This can be useful 5528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com in a way similar to quickReject, in that it tells you that drawing 5538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com outside of these bounds will be clipped out. 5548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 5558f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com virtual bool getClipBounds(SkRect* bounds) const; 5568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 557bcb671c82a7341253864cda3a5c46d396402d7fbtomhudson@google.com /** Return the bounds of the current clip, in device coordinates; returns 558bcb671c82a7341253864cda3a5c46d396402d7fbtomhudson@google.com true if non-empty. Maybe faster than getting the clip explicitly and 559bcb671c82a7341253864cda3a5c46d396402d7fbtomhudson@google.com then taking its bounds. 560bcb671c82a7341253864cda3a5c46d396402d7fbtomhudson@google.com */ 5618f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com virtual bool getClipDeviceBounds(SkIRect* bounds) const; 56274b461961607fa57a150a9282c410ef0cab38764vandebo@chromium.org 563bcb671c82a7341253864cda3a5c46d396402d7fbtomhudson@google.com 5648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Fill the entire canvas' bitmap (restricted to the current clip) with the 565845fdaca174f4675e9acc164b510e3a5ffa9053creed@android.com specified ARGB color, using the specified mode. 5668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param a the alpha component (0..255) of the color to fill the canvas 5678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param r the red component (0..255) of the color to fill the canvas 5688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param g the green component (0..255) of the color to fill the canvas 5698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param b the blue component (0..255) of the color to fill the canvas 5708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param mode the mode to apply the color in (defaults to SrcOver) 5718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 5728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void drawARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b, 573845fdaca174f4675e9acc164b510e3a5ffa9053creed@android.com SkXfermode::Mode mode = SkXfermode::kSrcOver_Mode); 5748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 5758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Fill the entire canvas' bitmap (restricted to the current clip) with the 576845fdaca174f4675e9acc164b510e3a5ffa9053creed@android.com specified color and mode. 5778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param color the color to draw with 5788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param mode the mode to apply the color in (defaults to SrcOver) 5798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 5808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void drawColor(SkColor color, 581845fdaca174f4675e9acc164b510e3a5ffa9053creed@android.com SkXfermode::Mode mode = SkXfermode::kSrcOver_Mode); 5828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 5832a98181f048c11f21f52fbd99f803f5fd6118261reed@google.com /** 5842a98181f048c11f21f52fbd99f803f5fd6118261reed@google.com * This erases the entire drawing surface to the specified color, 5852a98181f048c11f21f52fbd99f803f5fd6118261reed@google.com * irrespective of the clip. It does not blend with the previous pixels, 5862a98181f048c11f21f52fbd99f803f5fd6118261reed@google.com * but always overwrites them. 5872a98181f048c11f21f52fbd99f803f5fd6118261reed@google.com * 5882a98181f048c11f21f52fbd99f803f5fd6118261reed@google.com * It is roughly equivalent to the following: 5892a98181f048c11f21f52fbd99f803f5fd6118261reed@google.com * canvas.save(); 5902a98181f048c11f21f52fbd99f803f5fd6118261reed@google.com * canvas.clipRect(hugeRect, kReplace_Op); 5912a98181f048c11f21f52fbd99f803f5fd6118261reed@google.com * paint.setColor(color); 5922a98181f048c11f21f52fbd99f803f5fd6118261reed@google.com * paint.setXfermodeMode(kSrc_Mode); 5932a98181f048c11f21f52fbd99f803f5fd6118261reed@google.com * canvas.drawPaint(paint); 5942a98181f048c11f21f52fbd99f803f5fd6118261reed@google.com * canvas.restore(); 5952a98181f048c11f21f52fbd99f803f5fd6118261reed@google.com * though it is almost always much more efficient. 5962a98181f048c11f21f52fbd99f803f5fd6118261reed@google.com */ 5972a98181f048c11f21f52fbd99f803f5fd6118261reed@google.com virtual void clear(SkColor); 5982a98181f048c11f21f52fbd99f803f5fd6118261reed@google.com 5992a98181f048c11f21f52fbd99f803f5fd6118261reed@google.com /** 60028361fad1054d59ed4e6a320c7a8b8782a1487c7commit-bot@chromium.org * This makes the contents of the canvas undefined. Subsequent calls that 60128361fad1054d59ed4e6a320c7a8b8782a1487c7commit-bot@chromium.org * require reading the canvas contents will produce undefined results. Examples 60228361fad1054d59ed4e6a320c7a8b8782a1487c7commit-bot@chromium.org * include blending and readPixels. The actual implementation is backend- 60328361fad1054d59ed4e6a320c7a8b8782a1487c7commit-bot@chromium.org * dependent and one legal implementation is to do nothing. Like clear(), this 60428361fad1054d59ed4e6a320c7a8b8782a1487c7commit-bot@chromium.org * ignores the clip. 60528361fad1054d59ed4e6a320c7a8b8782a1487c7commit-bot@chromium.org * 60628361fad1054d59ed4e6a320c7a8b8782a1487c7commit-bot@chromium.org * This function should only be called if the caller intends to subsequently 60728361fad1054d59ed4e6a320c7a8b8782a1487c7commit-bot@chromium.org * draw to the canvas. The canvas may do real work at discard() time in order 60828361fad1054d59ed4e6a320c7a8b8782a1487c7commit-bot@chromium.org * to optimize performance on subsequent draws. Thus, if you call this and then 60928361fad1054d59ed4e6a320c7a8b8782a1487c7commit-bot@chromium.org * never draw to the canvas subsequently you may pay a perfomance penalty. 61028361fad1054d59ed4e6a320c7a8b8782a1487c7commit-bot@chromium.org */ 61128361fad1054d59ed4e6a320c7a8b8782a1487c7commit-bot@chromium.org void discard() { this->onDiscard(); } 61228361fad1054d59ed4e6a320c7a8b8782a1487c7commit-bot@chromium.org 61328361fad1054d59ed4e6a320c7a8b8782a1487c7commit-bot@chromium.org /** 6142a98181f048c11f21f52fbd99f803f5fd6118261reed@google.com * Fill the entire canvas' bitmap (restricted to the current clip) with the 6152a98181f048c11f21f52fbd99f803f5fd6118261reed@google.com * specified paint. 6162a98181f048c11f21f52fbd99f803f5fd6118261reed@google.com * @param paint The paint used to fill the canvas 6172a98181f048c11f21f52fbd99f803f5fd6118261reed@google.com */ 6188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void drawPaint(const SkPaint& paint); 6198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 6208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com enum PointMode { 6218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** drawPoints draws each point separately */ 6228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kPoints_PointMode, 6238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** drawPoints draws each pair of points as a line segment */ 6248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kLines_PointMode, 6258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** drawPoints draws the array of points as a polygon */ 6268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kPolygon_PointMode 6278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com }; 6288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 6298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Draw a series of points, interpreted based on the PointMode mode. For 6308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com all modes, the count parameter is interpreted as the total number of 6318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com points. For kLine mode, count/2 line segments are drawn. 6328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com For kPoint mode, each point is drawn centered at its coordinate, and its 6338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com size is specified by the paint's stroke-width. It draws as a square, 6348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com unless the paint's cap-type is round, in which the points are drawn as 6358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com circles. 6368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com For kLine mode, each pair of points is drawn as a line segment, 6378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com respecting the paint's settings for cap/join/width. 6388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com For kPolygon mode, the entire array is drawn as a series of connected 6398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com line segments. 6408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com Note that, while similar, kLine and kPolygon modes draw slightly 6418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com differently than the equivalent path built with a series of moveto, 6428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com lineto calls, in that the path will draw all of its contours at once, 6438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com with no interactions if contours intersect each other (think XOR 6448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com xfermode). drawPoints always draws each element one at a time. 6458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param mode PointMode specifying how to draw the array of points. 6468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param count The number of points in the array 6478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param pts Array of points to draw 6488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param paint The paint used to draw the points 6498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 6508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void drawPoints(PointMode mode, size_t count, const SkPoint pts[], 6518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPaint& paint); 6528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 6538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Helper method for drawing a single point. See drawPoints() for a more 6548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com details. 6558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 6568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void drawPoint(SkScalar x, SkScalar y, const SkPaint& paint); 6574b226023832011bc3bcdd1e5092ff0645ad0bdeereed@google.com 6588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Draws a single pixel in the specified color. 6598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param x The X coordinate of which pixel to draw 6608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param y The Y coordiante of which pixel to draw 6618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param color The color to draw 6628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 6638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void drawPoint(SkScalar x, SkScalar y, SkColor color); 6648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 6658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Draw a line segment with the specified start and stop x,y coordinates, 6668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com using the specified paint. NOTE: since a line is always "framed", the 6678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com paint's Style is ignored. 6688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param x0 The x-coordinate of the start point of the line 6698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param y0 The y-coordinate of the start point of the line 6708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param x1 The x-coordinate of the end point of the line 6718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param y1 The y-coordinate of the end point of the line 6728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param paint The paint used to draw the line 6738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 6748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void drawLine(SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1, 6758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPaint& paint); 6768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 6778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Draw the specified rectangle using the specified paint. The rectangle 6788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com will be filled or stroked based on the Style in the paint. 6798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param rect The rect to be drawn 6808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param paint The paint used to draw the rect 6818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 6827ce564cccb246ec56427085872b2e1458fe74bd1bsalomon@google.com virtual void drawRect(const SkRect& rect, const SkPaint& paint); 6838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 6848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Draw the specified rectangle using the specified paint. The rectangle 6858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com will be filled or framed based on the Style in the paint. 6868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param rect The rect to be drawn 6878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param paint The paint used to draw the rect 6888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 68987001ed1f6f1d498874f7f4ba39abcf608ae8bf5reed@google.com void drawIRect(const SkIRect& rect, const SkPaint& paint) { 6908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkRect r; 6918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com r.set(rect); // promotes the ints to scalars 6928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com this->drawRect(r, paint); 6938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 6944b226023832011bc3bcdd1e5092ff0645ad0bdeereed@google.com 6958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Draw the specified rectangle using the specified paint. The rectangle 6968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com will be filled or framed based on the Style in the paint. 6978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param left The left side of the rectangle to be drawn 6988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param top The top side of the rectangle to be drawn 6998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param right The right side of the rectangle to be drawn 7008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param bottom The bottom side of the rectangle to be drawn 7018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param paint The paint used to draw the rect 7028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 7038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void drawRectCoords(SkScalar left, SkScalar top, SkScalar right, 7048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkScalar bottom, const SkPaint& paint); 7058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 7068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Draw the specified oval using the specified paint. The oval will be 7078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com filled or framed based on the Style in the paint. 7088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param oval The rectangle bounds of the oval to be drawn 7098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param paint The paint used to draw the oval 7108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 7114ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com virtual void drawOval(const SkRect& oval, const SkPaint&); 7124ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com 7134ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com /** 7144ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com * Draw the specified RRect using the specified paint The rrect will be filled or stroked 7154ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com * based on the Style in the paint. 7164ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com * 7174ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com * @param rrect The round-rect to draw 7184ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com * @param paint The paint used to draw the round-rect 7194ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com */ 7204ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com virtual void drawRRect(const SkRRect& rrect, const SkPaint& paint); 7218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 722ed9806f5c972513d4141c9d1b5a04ab78b3af4cbcommit-bot@chromium.org /** 723ed9806f5c972513d4141c9d1b5a04ab78b3af4cbcommit-bot@chromium.org * Draw the annulus formed by the outer and inner rrects. The results 724ed9806f5c972513d4141c9d1b5a04ab78b3af4cbcommit-bot@chromium.org * are undefined if the outer does not contain the inner. 725ed9806f5c972513d4141c9d1b5a04ab78b3af4cbcommit-bot@chromium.org */ 726ed9806f5c972513d4141c9d1b5a04ab78b3af4cbcommit-bot@chromium.org void drawDRRect(const SkRRect& outer, const SkRRect& inner, const SkPaint&); 727ed9806f5c972513d4141c9d1b5a04ab78b3af4cbcommit-bot@chromium.org 7288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Draw the specified circle using the specified paint. If radius is <= 0, 7298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com then nothing will be drawn. The circle will be filled 7308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com or framed based on the Style in the paint. 7318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param cx The x-coordinate of the center of the cirle to be drawn 7328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param cy The y-coordinate of the center of the cirle to be drawn 7338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param radius The radius of the cirle to be drawn 7348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param paint The paint used to draw the circle 7358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 7368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void drawCircle(SkScalar cx, SkScalar cy, SkScalar radius, 7378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPaint& paint); 7388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 7398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Draw the specified arc, which will be scaled to fit inside the 7408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com specified oval. If the sweep angle is >= 360, then the oval is drawn 7418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com completely. Note that this differs slightly from SkPath::arcTo, which 7428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com treats the sweep angle mod 360. 7438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param oval The bounds of oval used to define the shape of the arc 7448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param startAngle Starting angle (in degrees) where the arc begins 7458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param sweepAngle Sweep angle (in degrees) measured clockwise 7468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param useCenter true means include the center of the oval. For filling 7478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com this will draw a wedge. False means just use the arc. 7488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param paint The paint used to draw the arc 7498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 7508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void drawArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle, 7518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool useCenter, const SkPaint& paint); 7528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 7538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Draw the specified round-rect using the specified paint. The round-rect 7548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com will be filled or framed based on the Style in the paint. 7558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param rect The rectangular bounds of the roundRect to be drawn 7568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param rx The x-radius of the oval used to round the corners 7578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param ry The y-radius of the oval used to round the corners 7588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param paint The paint used to draw the roundRect 7598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 7608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void drawRoundRect(const SkRect& rect, SkScalar rx, SkScalar ry, 7618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPaint& paint); 7628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 7638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Draw the specified path using the specified paint. The path will be 7648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com filled or framed based on the Style in the paint. 7658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param path The path to be drawn 7668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param paint The paint used to draw the path 7678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 7687ce564cccb246ec56427085872b2e1458fe74bd1bsalomon@google.com virtual void drawPath(const SkPath& path, const SkPaint& paint); 7698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 7708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Draw the specified bitmap, with its top/left corner at (x,y), using the 7718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com specified paint, transformed by the current matrix. Note: if the paint 7728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com contains a maskfilter that generates a mask which extends beyond the 7738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bitmap's original width/height, then the bitmap will be drawn as if it 7748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com were in a Shader with CLAMP mode. Thus the color outside of the original 7758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com width/height will be the edge color replicated. 77691246b9fc7740547d4b1b3f144684483c8e968cdcommit-bot@chromium.org 77791246b9fc7740547d4b1b3f144684483c8e968cdcommit-bot@chromium.org If a shader is present on the paint it will be ignored, except in the 778f20fc24a7def23093a1abd2fc8de4a1302aeb9f8reed@google.com case where the bitmap is kAlpha_8_SkColorType. In that case, the color is 77991246b9fc7740547d4b1b3f144684483c8e968cdcommit-bot@chromium.org generated by the shader. 78091246b9fc7740547d4b1b3f144684483c8e968cdcommit-bot@chromium.org 7818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param bitmap The bitmap to be drawn 7828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param left The position of the left side of the bitmap being drawn 7838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param top The position of the top side of the bitmap being drawn 7848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param paint The paint used to draw the bitmap, or NULL 7858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 7868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top, 7878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPaint* paint = NULL); 7888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 789eed779d866e1e239bfb9ebc6a225b7345a41adf9commit-bot@chromium.org enum DrawBitmapRectFlags { 79031acc11977815402e4ef2681350f8559285bec97robertphillips@google.com kNone_DrawBitmapRectFlag = 0x0, 7917475811143e190e172bf83d13c4bdba85704b604skia.committer@gmail.com /** 792eed779d866e1e239bfb9ebc6a225b7345a41adf9commit-bot@chromium.org * When filtering is enabled, allow the color samples outside of 7937475811143e190e172bf83d13c4bdba85704b604skia.committer@gmail.com * the src rect (but still in the src bitmap) to bleed into the 794eed779d866e1e239bfb9ebc6a225b7345a41adf9commit-bot@chromium.org * drawn portion 795eed779d866e1e239bfb9ebc6a225b7345a41adf9commit-bot@chromium.org */ 79631acc11977815402e4ef2681350f8559285bec97robertphillips@google.com kBleed_DrawBitmapRectFlag = 0x1, 797eed779d866e1e239bfb9ebc6a225b7345a41adf9commit-bot@chromium.org }; 798eed779d866e1e239bfb9ebc6a225b7345a41adf9commit-bot@chromium.org 7998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Draw the specified bitmap, with the specified matrix applied (before the 8008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com canvas' matrix is applied). 8018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param bitmap The bitmap to be drawn 8028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param src Optional: specify the subset of the bitmap to be drawn 8038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param dst The destination rectangle where the scaled/translated 8048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com image will be drawn 8058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param paint The paint used to draw the bitmap, or NULL 8068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 8077112173c3c4cd1b1e7da8cdf971d71f01dd91299reed@google.com virtual void drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src, 8087112173c3c4cd1b1e7da8cdf971d71f01dd91299reed@google.com const SkRect& dst, 809eed779d866e1e239bfb9ebc6a225b7345a41adf9commit-bot@chromium.org const SkPaint* paint = NULL, 81031acc11977815402e4ef2681350f8559285bec97robertphillips@google.com DrawBitmapRectFlags flags = kNone_DrawBitmapRectFlag); 8117112173c3c4cd1b1e7da8cdf971d71f01dd91299reed@google.com 8127112173c3c4cd1b1e7da8cdf971d71f01dd91299reed@google.com void drawBitmapRect(const SkBitmap& bitmap, const SkRect& dst, 813eed779d866e1e239bfb9ebc6a225b7345a41adf9commit-bot@chromium.org const SkPaint* paint = NULL) { 81431acc11977815402e4ef2681350f8559285bec97robertphillips@google.com this->drawBitmapRectToRect(bitmap, NULL, dst, paint, kNone_DrawBitmapRectFlag); 8157112173c3c4cd1b1e7da8cdf971d71f01dd91299reed@google.com } 8168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 8177112173c3c4cd1b1e7da8cdf971d71f01dd91299reed@google.com void drawBitmapRect(const SkBitmap& bitmap, const SkIRect* isrc, 818eed779d866e1e239bfb9ebc6a225b7345a41adf9commit-bot@chromium.org const SkRect& dst, const SkPaint* paint = NULL, 81931acc11977815402e4ef2681350f8559285bec97robertphillips@google.com DrawBitmapRectFlags flags = kNone_DrawBitmapRectFlag) { 8207112173c3c4cd1b1e7da8cdf971d71f01dd91299reed@google.com SkRect realSrcStorage; 8217112173c3c4cd1b1e7da8cdf971d71f01dd91299reed@google.com SkRect* realSrcPtr = NULL; 8227112173c3c4cd1b1e7da8cdf971d71f01dd91299reed@google.com if (isrc) { 8237112173c3c4cd1b1e7da8cdf971d71f01dd91299reed@google.com realSrcStorage.set(*isrc); 8247112173c3c4cd1b1e7da8cdf971d71f01dd91299reed@google.com realSrcPtr = &realSrcStorage; 8257112173c3c4cd1b1e7da8cdf971d71f01dd91299reed@google.com } 826eed779d866e1e239bfb9ebc6a225b7345a41adf9commit-bot@chromium.org this->drawBitmapRectToRect(bitmap, realSrcPtr, dst, paint, flags); 8277112173c3c4cd1b1e7da8cdf971d71f01dd91299reed@google.com } 828c1ad0226087e10b1f300b5a45e3d6fdb23b8d1b8skia.committer@gmail.com 8298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m, 8308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPaint* paint = NULL); 8314b226023832011bc3bcdd1e5092ff0645ad0bdeereed@google.com 832f0b5e1190af9807a027c0adba2f1380663c8e910reed@google.com /** 833f0b5e1190af9807a027c0adba2f1380663c8e910reed@google.com * Draw the bitmap stretched differentially to fit into dst. 834f0b5e1190af9807a027c0adba2f1380663c8e910reed@google.com * center is a rect within the bitmap, and logically divides the bitmap 835f0b5e1190af9807a027c0adba2f1380663c8e910reed@google.com * into 9 sections (3x3). For example, if the middle pixel of a [5x5] 836f0b5e1190af9807a027c0adba2f1380663c8e910reed@google.com * bitmap is the "center", then the center-rect should be [2, 2, 3, 3]. 837f0b5e1190af9807a027c0adba2f1380663c8e910reed@google.com * 838f0b5e1190af9807a027c0adba2f1380663c8e910reed@google.com * If the dst is >= the bitmap size, then... 8399bf380ce7f848dfb5886dd52b82746521454b739robertphillips@google.com * - The 4 corners are not stretched at all. 8409bf380ce7f848dfb5886dd52b82746521454b739robertphillips@google.com * - The sides are stretched in only one axis. 8419bf380ce7f848dfb5886dd52b82746521454b739robertphillips@google.com * - The center is stretched in both axes. 842f0b5e1190af9807a027c0adba2f1380663c8e910reed@google.com * Else, for each axis where dst < bitmap, 843f0b5e1190af9807a027c0adba2f1380663c8e910reed@google.com * - The corners shrink proportionally 844f0b5e1190af9807a027c0adba2f1380663c8e910reed@google.com * - The sides (along the shrink axis) and center are not drawn 845f0b5e1190af9807a027c0adba2f1380663c8e910reed@google.com */ 846f0b5e1190af9807a027c0adba2f1380663c8e910reed@google.com virtual void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, 847f0b5e1190af9807a027c0adba2f1380663c8e910reed@google.com const SkRect& dst, const SkPaint* paint = NULL); 848f0b5e1190af9807a027c0adba2f1380663c8e910reed@google.com 8498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Draw the specified bitmap, with its top/left corner at (x,y), 8508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com NOT transformed by the current matrix. Note: if the paint 8518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com contains a maskfilter that generates a mask which extends beyond the 8528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bitmap's original width/height, then the bitmap will be drawn as if it 8538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com were in a Shader with CLAMP mode. Thus the color outside of the original 8548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com width/height will be the edge color replicated. 8558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param bitmap The bitmap to be drawn 8568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param left The position of the left side of the bitmap being drawn 8578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param top The position of the top side of the bitmap being drawn 8588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param paint The paint used to draw the bitmap, or NULL 8598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 8608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void drawSprite(const SkBitmap& bitmap, int left, int top, 8618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPaint* paint = NULL); 8628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 8638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Draw the text, with origin at (x,y), using the specified paint. 8648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com The origin is interpreted based on the Align setting in the paint. 8658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param text The text to be drawn 8668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param byteLength The number of bytes to read from the text parameter 8678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param x The x-coordinate of the origin of the text being drawn 8688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param y The y-coordinate of the origin of the text being drawn 8698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param paint The paint used for the text (e.g. color, size, style) 8708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 8718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void drawText(const void* text, size_t byteLength, SkScalar x, 8728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkScalar y, const SkPaint& paint); 8738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 8748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Draw the text, with each character/glyph origin specified by the pos[] 8754b226023832011bc3bcdd1e5092ff0645ad0bdeereed@google.com array. The origin is interpreted by the Align setting in the paint. 8768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param text The text to be drawn 8778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param byteLength The number of bytes to read from the text parameter 8788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param pos Array of positions, used to position each character 8798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param paint The paint used for the text (e.g. color, size, style) 8808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 8818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void drawPosText(const void* text, size_t byteLength, 8828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPoint pos[], const SkPaint& paint); 8834b226023832011bc3bcdd1e5092ff0645ad0bdeereed@google.com 8848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Draw the text, with each character/glyph origin specified by the x 8858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com coordinate taken from the xpos[] array, and the y from the constY param. 8864b226023832011bc3bcdd1e5092ff0645ad0bdeereed@google.com The origin is interpreted by the Align setting in the paint. 8878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param text The text to be drawn 8888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param byteLength The number of bytes to read from the text parameter 8898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param xpos Array of x-positions, used to position each character 8908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param constY The shared Y coordinate for all of the positions 8918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param paint The paint used for the text (e.g. color, size, style) 8928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 8938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void drawPosTextH(const void* text, size_t byteLength, 8948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkScalar xpos[], SkScalar constY, 8958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPaint& paint); 8964b226023832011bc3bcdd1e5092ff0645ad0bdeereed@google.com 8978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Draw the text, with origin at (x,y), using the specified paint, along 8988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com the specified path. The paint's Align setting determins where along the 8998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com path to start the text. 9008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param text The text to be drawn 9018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param byteLength The number of bytes to read from the text parameter 9028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param path The path the text should follow for its baseline 9038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param hOffset The distance along the path to add to the text's 9048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com starting position 9058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param vOffset The distance above(-) or below(+) the path to 9068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com position the text 9078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param paint The paint used for the text 9088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 9098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void drawTextOnPathHV(const void* text, size_t byteLength, 9108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPath& path, SkScalar hOffset, 9118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkScalar vOffset, const SkPaint& paint); 9128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 9138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Draw the text, with origin at (x,y), using the specified paint, along 9148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com the specified path. The paint's Align setting determins where along the 9158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com path to start the text. 9168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param text The text to be drawn 9178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param byteLength The number of bytes to read from the text parameter 9188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param path The path the text should follow for its baseline 9198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param matrix (may be null) Applied to the text before it is 9208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com mapped onto the path 9218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param paint The paint used for the text 9228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 9238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void drawTextOnPath(const void* text, size_t byteLength, 9248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPath& path, const SkMatrix* matrix, 9258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPaint& paint); 9268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 927145d1c0fdcef63991d7f910cc067a653a8aa2c4ccommit-bot@chromium.org /** PRIVATE / EXPERIMENTAL -- do not call 928145d1c0fdcef63991d7f910cc067a653a8aa2c4ccommit-bot@chromium.org Perform back-end analysis/optimization of a picture. This may attach 929145d1c0fdcef63991d7f910cc067a653a8aa2c4ccommit-bot@chromium.org optimization data to the picture which can be used by a later 930145d1c0fdcef63991d7f910cc067a653a8aa2c4ccommit-bot@chromium.org drawPicture call. 931145d1c0fdcef63991d7f910cc067a653a8aa2c4ccommit-bot@chromium.org @param picture The recorded drawing commands to analyze/optimize 932145d1c0fdcef63991d7f910cc067a653a8aa2c4ccommit-bot@chromium.org */ 933145d1c0fdcef63991d7f910cc067a653a8aa2c4ccommit-bot@chromium.org void EXPERIMENTAL_optimize(SkPicture* picture); 934145d1c0fdcef63991d7f910cc067a653a8aa2c4ccommit-bot@chromium.org 9358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Draw the picture into this canvas. This method effective brackets the 9368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com playback of the picture's draw calls with save/restore, so the state 937a44de9617a0a51014bacc4151287995ededcdf62djsollen@google.com of this canvas will be unchanged after this call. 9388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param picture The recorded drawing commands to playback into this 9398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com canvas. 9408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 9418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void drawPicture(SkPicture& picture); 9424b226023832011bc3bcdd1e5092ff0645ad0bdeereed@google.com 9438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com enum VertexMode { 9448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kTriangles_VertexMode, 9458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kTriangleStrip_VertexMode, 9468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kTriangleFan_VertexMode 9478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com }; 9484b226023832011bc3bcdd1e5092ff0645ad0bdeereed@google.com 9498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Draw the array of vertices, interpreted as triangles (based on mode). 9508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param vmode How to interpret the array of vertices 9518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param vertexCount The number of points in the vertices array (and 9528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com corresponding texs and colors arrays if non-null) 9538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param vertices Array of vertices for the mesh 9548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param texs May be null. If not null, specifies the coordinate 955631a59b9393208ed3546e81ca843f2f7da06ca64robertphillips@google.com in _texture_ space (not uv space) for each vertex. 9568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param colors May be null. If not null, specifies a color for each 9578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com vertex, to be interpolated across the triangle. 9588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param xmode Used if both texs and colors are present. In this 9598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com case the colors are combined with the texture using mode, 9608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com before being drawn using the paint. If mode is null, then 9618d3cd7a170c810e3816bf00220cbef51e7b16795reed@google.com kModulate_Mode is used. 9628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param indices If not null, array of indices to reference into the 9638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com vertex (texs, colors) array. 9648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param indexCount number of entries in the indices array (if not null) 9654b226023832011bc3bcdd1e5092ff0645ad0bdeereed@google.com @param paint Specifies the shader/texture if present. 9668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 9678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void drawVertices(VertexMode vmode, int vertexCount, 9688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPoint vertices[], const SkPoint texs[], 9698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkColor colors[], SkXfermode* xmode, 9708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const uint16_t indices[], int indexCount, 9718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPaint& paint); 9728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 973cb60844b34766aad4151df5e87c144d4a57e9abereed@android.com /** Send a blob of data to the canvas. 974cb60844b34766aad4151df5e87c144d4a57e9abereed@android.com For canvases that draw, this call is effectively a no-op, as the data 975cb60844b34766aad4151df5e87c144d4a57e9abereed@android.com is not parsed, but just ignored. However, this call exists for 976cb60844b34766aad4151df5e87c144d4a57e9abereed@android.com subclasses like SkPicture's recording canvas, that can store the data 977cb60844b34766aad4151df5e87c144d4a57e9abereed@android.com and then play it back later (via another call to drawData). 978cb60844b34766aad4151df5e87c144d4a57e9abereed@android.com */ 9790a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com virtual void drawData(const void* data, size_t length) { 9800a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com // do nothing. Subclasses may do something with the data 9810a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com } 9820a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com 983a5d3e77420621c912383c3b22e542d9413d68278skia.committer@gmail.com /** Add comments. beginCommentGroup/endCommentGroup open/close a new group. 984a5d3e77420621c912383c3b22e542d9413d68278skia.committer@gmail.com Each comment added via addComment is notionally attached to its 9850a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com enclosing group. Top-level comments simply belong to no group. 9860a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com */ 9870a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com virtual void beginCommentGroup(const char* description) { 9880a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com // do nothing. Subclasses may do something 9890a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com } 9900a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com virtual void addComment(const char* kywd, const char* value) { 9910a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com // do nothing. Subclasses may do something 9920a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com } 9930a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com virtual void endCommentGroup() { 9940a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com // do nothing. Subclasses may do something 9950a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com } 9960a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com 997210ae2a42613b9048e8e8c4096c5bf4fe2ddf838commit-bot@chromium.org /** 998210ae2a42613b9048e8e8c4096c5bf4fe2ddf838commit-bot@chromium.org * With this call the client asserts that subsequent draw operations (up to the 999210ae2a42613b9048e8e8c4096c5bf4fe2ddf838commit-bot@chromium.org * matching popCull()) are fully contained within the given bounding box. The assertion 1000210ae2a42613b9048e8e8c4096c5bf4fe2ddf838commit-bot@chromium.org * is not enforced, but the information might be used to quick-reject command blocks, 1001210ae2a42613b9048e8e8c4096c5bf4fe2ddf838commit-bot@chromium.org * so an incorrect bounding box may result in incomplete rendering. 1002210ae2a42613b9048e8e8c4096c5bf4fe2ddf838commit-bot@chromium.org */ 1003520cf8b33e788268432c6314c52dfcef22e776aecommit-bot@chromium.org void pushCull(const SkRect& cullRect); 1004cb60844b34766aad4151df5e87c144d4a57e9abereed@android.com 1005210ae2a42613b9048e8e8c4096c5bf4fe2ddf838commit-bot@chromium.org /** 1006210ae2a42613b9048e8e8c4096c5bf4fe2ddf838commit-bot@chromium.org * Terminates the current culling block, and restores the previous one (if any). 1007210ae2a42613b9048e8e8c4096c5bf4fe2ddf838commit-bot@chromium.org */ 1008520cf8b33e788268432c6314c52dfcef22e776aecommit-bot@chromium.org void popCull(); 1009520cf8b33e788268432c6314c52dfcef22e776aecommit-bot@chromium.org 10108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com ////////////////////////////////////////////////////////////////////////// 10114b226023832011bc3bcdd1e5092ff0645ad0bdeereed@google.com 10128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Get the current bounder object. 10138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com The bounder's reference count is unchaged. 10148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the canva's bounder (or NULL). 10158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 10168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkBounder* getBounder() const { return fBounder; } 10178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 10188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Set a new bounder (or NULL). 10198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com Pass NULL to clear any previous bounder. 10208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com As a convenience, the parameter passed is also returned. 10218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com If a previous bounder exists, its reference count is decremented. 10228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com If bounder is not NULL, its reference count is incremented. 10238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param bounder the new bounder (or NULL) to be installed in the canvas 10248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the set bounder object 10258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 10268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual SkBounder* setBounder(SkBounder* bounder); 10274b226023832011bc3bcdd1e5092ff0645ad0bdeereed@google.com 10288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Get the current filter object. The filter's reference count is not 1029dc3381fc8194a6192af39539c6ac9787b20209d3reed@android.com affected. The filter is saved/restored, just like the matrix and clip. 10308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the canvas' filter (or NULL). 10318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 10328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkDrawFilter* getDrawFilter() const; 10334b226023832011bc3bcdd1e5092ff0645ad0bdeereed@google.com 10348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Set the new filter (or NULL). Pass NULL to clear any existing filter. 10358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com As a convenience, the parameter is returned. If an existing filter 10368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com exists, its refcnt is decrement. If the new filter is not null, its 1037dc3381fc8194a6192af39539c6ac9787b20209d3reed@android.com refcnt is incremented. The filter is saved/restored, just like the 1038dc3381fc8194a6192af39539c6ac9787b20209d3reed@android.com matrix and clip. 10398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param filter the new filter (or NULL) 10408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the new filter 10418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 10428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual SkDrawFilter* setDrawFilter(SkDrawFilter* filter); 10438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 10448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com ////////////////////////////////////////////////////////////////////////// 10458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1046754de5f65b466f721d952a379194cc94de376f42reed@google.com /** 1047754de5f65b466f721d952a379194cc94de376f42reed@google.com * Return true if the current clip is empty (i.e. nothing will draw). 1048754de5f65b466f721d952a379194cc94de376f42reed@google.com * Note: this is not always a free call, so it should not be used 1049754de5f65b466f721d952a379194cc94de376f42reed@google.com * more often than necessary. However, once the canvas has computed this 1050754de5f65b466f721d952a379194cc94de376f42reed@google.com * result, subsequent calls will be cheap (until the clip state changes, 1051754de5f65b466f721d952a379194cc94de376f42reed@google.com * which can happen on any clip..() or restore() call. 1052754de5f65b466f721d952a379194cc94de376f42reed@google.com */ 10538f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com virtual bool isClipEmpty() const; 1054754de5f65b466f721d952a379194cc94de376f42reed@google.com 10555c70cdca5efe541b70d010e91607bf8626ea49cacommit-bot@chromium.org /** 10565c70cdca5efe541b70d010e91607bf8626ea49cacommit-bot@chromium.org * Returns true if the current clip is just a (non-empty) rectangle. 10575c70cdca5efe541b70d010e91607bf8626ea49cacommit-bot@chromium.org * Returns false if the clip is empty, or if it is complex. 10585c70cdca5efe541b70d010e91607bf8626ea49cacommit-bot@chromium.org */ 10595c70cdca5efe541b70d010e91607bf8626ea49cacommit-bot@chromium.org virtual bool isClipRect() const; 10605c70cdca5efe541b70d010e91607bf8626ea49cacommit-bot@chromium.org 10618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Return the current matrix on the canvas. 10628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com This does not account for the translate in any of the devices. 10638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return The current matrix on the canvas. 10648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 1065a907ac3e3e3458fbb5d673c3feafb31fd7647b38junov@chromium.org const SkMatrix& getTotalMatrix() const; 10668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 10675c70cdca5efe541b70d010e91607bf8626ea49cacommit-bot@chromium.org#ifdef SK_SUPPORT_LEGACY_GETCLIPTYPE 1068bcb671c82a7341253864cda3a5c46d396402d7fbtomhudson@google.com enum ClipType { 1069bcb671c82a7341253864cda3a5c46d396402d7fbtomhudson@google.com kEmpty_ClipType = 0, 1070bcb671c82a7341253864cda3a5c46d396402d7fbtomhudson@google.com kRect_ClipType, 1071bcb671c82a7341253864cda3a5c46d396402d7fbtomhudson@google.com kComplex_ClipType 1072bcb671c82a7341253864cda3a5c46d396402d7fbtomhudson@google.com }; 1073bcb671c82a7341253864cda3a5c46d396402d7fbtomhudson@google.com /** Returns a description of the total clip; may be cheaper than 1074bcb671c82a7341253864cda3a5c46d396402d7fbtomhudson@google.com getting the clip and querying it directly. 1075bcb671c82a7341253864cda3a5c46d396402d7fbtomhudson@google.com */ 10768f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com virtual ClipType getClipType() const; 10775c70cdca5efe541b70d010e91607bf8626ea49cacommit-bot@chromium.org#endif 1078bcb671c82a7341253864cda3a5c46d396402d7fbtomhudson@google.com 10795c70cdca5efe541b70d010e91607bf8626ea49cacommit-bot@chromium.org#ifdef SK_SUPPORT_LEGACY_GETTOTALCLIP 10804469938e92d779dff05e745559e67907bbf21e78reed@google.com /** DEPRECATED -- need to move this guy to private/friend 10814469938e92d779dff05e745559e67907bbf21e78reed@google.com * Return the current device clip (concatenation of all clip calls). 1082a707f6087455834fab5525a0c656cc5b6df2ff29reed@google.com * This does not account for the translate in any of the devices. 1083a707f6087455834fab5525a0c656cc5b6df2ff29reed@google.com * @return the current device clip (concatenation of all clip calls). 10845e2457ef2eba0c3f2e4c8fc89be7f36659e4f3b1reed@google.com */ 1085a707f6087455834fab5525a0c656cc5b6df2ff29reed@google.com const SkRegion& getTotalClip() const; 10865c70cdca5efe541b70d010e91607bf8626ea49cacommit-bot@chromium.org#endif 10875e2457ef2eba0c3f2e4c8fc89be7f36659e4f3b1reed@google.com 108840a1ae4df28810aa5aa5cf2627d8387b2dfb867arobertphillips@google.com /** Return the clip stack. The clip stack stores all the individual 108940a1ae4df28810aa5aa5cf2627d8387b2dfb867arobertphillips@google.com * clips organized by the save/restore frame in which they were 109040a1ae4df28810aa5aa5cf2627d8387b2dfb867arobertphillips@google.com * added. 109140a1ae4df28810aa5aa5cf2627d8387b2dfb867arobertphillips@google.com * @return the current clip stack ("list" of individual clip elements) 109240a1ae4df28810aa5aa5cf2627d8387b2dfb867arobertphillips@google.com */ 109340a1ae4df28810aa5aa5cf2627d8387b2dfb867arobertphillips@google.com const SkClipStack* getClipStack() const { 109440a1ae4df28810aa5aa5cf2627d8387b2dfb867arobertphillips@google.com return &fClipStack; 109540a1ae4df28810aa5aa5cf2627d8387b2dfb867arobertphillips@google.com } 109640a1ae4df28810aa5aa5cf2627d8387b2dfb867arobertphillips@google.com 109790c07ea1d0aa6b7f20252c43fe23ee5ddc1d23cbreed@google.com class ClipVisitor { 109890c07ea1d0aa6b7f20252c43fe23ee5ddc1d23cbreed@google.com public: 109920a550c6ea947f0ab239da1d4ecba209d76a98fdjustinlin@google.com virtual ~ClipVisitor(); 110090c07ea1d0aa6b7f20252c43fe23ee5ddc1d23cbreed@google.com virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; 1101e5b2af955b7d06815ddd405659ad62a2a8355ca3commit-bot@chromium.org virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; 110290c07ea1d0aa6b7f20252c43fe23ee5ddc1d23cbreed@google.com virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; 110390c07ea1d0aa6b7f20252c43fe23ee5ddc1d23cbreed@google.com }; 110490c07ea1d0aa6b7f20252c43fe23ee5ddc1d23cbreed@google.com 11055e2457ef2eba0c3f2e4c8fc89be7f36659e4f3b1reed@google.com /** 110690c07ea1d0aa6b7f20252c43fe23ee5ddc1d23cbreed@google.com * Replays the clip operations, back to front, that have been applied to 110790c07ea1d0aa6b7f20252c43fe23ee5ddc1d23cbreed@google.com * the canvas, calling the appropriate method on the visitor for each 110890c07ea1d0aa6b7f20252c43fe23ee5ddc1d23cbreed@google.com * clip. All clips have already been transformed into device space. 11097d7ca79c3e6e6be7b7849b0d9a7fe26effb89c38reed@google.com */ 111090c07ea1d0aa6b7f20252c43fe23ee5ddc1d23cbreed@google.com void replayClips(ClipVisitor*) const; 11118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 11128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /////////////////////////////////////////////////////////////////////////// 11138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 11148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** After calling saveLayer(), there can be any number of devices that make 11158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com up the top-most drawing area. LayerIter can be used to iterate through 11168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com those devices. Note that the iterator is only valid until the next API 11178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com call made on the canvas. Ownership of all pointers in the iterator stays 11188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com with the canvas, so none of them should be modified or deleted. 11198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 11207ffb1b21abcc7bbed5a0fc711f6dd7b9dbb4f577ctguil@chromium.org class SK_API LayerIter /*: SkNoncopyable*/ { 11218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com public: 11228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Initialize iterator with canvas, and set values for 1st device */ 11238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com LayerIter(SkCanvas*, bool skipEmptyClips); 11248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com ~LayerIter(); 11254b226023832011bc3bcdd1e5092ff0645ad0bdeereed@google.com 11268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Return true if the iterator is done */ 11278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool done() const { return fDone; } 11288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Cycle to the next device */ 11298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void next(); 11304b226023832011bc3bcdd1e5092ff0645ad0bdeereed@google.com 11318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com // These reflect the current device in the iterator 11328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 11331f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com SkBaseDevice* device() const; 11348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkMatrix& matrix() const; 11358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkRegion& clip() const; 11368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPaint& paint() const; 11378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com int x() const; 11388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com int y() const; 11394b226023832011bc3bcdd1e5092ff0645ad0bdeereed@google.com 11408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com private: 11418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com // used to embed the SkDrawIter object directly in our instance, w/o 11428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com // having to expose that class def to the public. There is an assert 11438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com // in our constructor to ensure that fStorage is large enough 11448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com // (though needs to be a compile-time-assert!). We use intptr_t to work 11458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com // safely with 32 and 64 bit machines (to ensure the storage is enough) 1146f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com intptr_t fStorage[32]; 11478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com class SkDrawIter* fImpl; // this points at fStorage 11488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkPaint fDefaultPaint; 11498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool fDone; 11508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com }; 11518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 11525c70cdca5efe541b70d010e91607bf8626ea49cacommit-bot@chromium.org // don't call 11535c70cdca5efe541b70d010e91607bf8626ea49cacommit-bot@chromium.org const SkRegion& internal_private_getTotalClip() const; 11545c70cdca5efe541b70d010e91607bf8626ea49cacommit-bot@chromium.org // don't call 11555c70cdca5efe541b70d010e91607bf8626ea49cacommit-bot@chromium.org void internal_private_getTotalClipAsPath(SkPath*) const; 11569c135db83d198e7d8200027c7d2cf60f38517ee3reed@google.com // don't call 11579c135db83d198e7d8200027c7d2cf60f38517ee3reed@google.com GrRenderTarget* internal_private_accessTopLayerRenderTarget(); 11585c70cdca5efe541b70d010e91607bf8626ea49cacommit-bot@chromium.org 11598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprotected: 116076f10a3bd936af7dbe2b5873d5a7eedd73cdc5dareed@google.com // default impl defers to getDevice()->newSurface(info) 116176f10a3bd936af7dbe2b5873d5a7eedd73cdc5dareed@google.com virtual SkSurface* onNewSurface(const SkImageInfo&); 116276f10a3bd936af7dbe2b5873d5a7eedd73cdc5dareed@google.com 1163c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org // default impl defers to its device 1164c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org virtual const void* onPeekPixels(SkImageInfo*, size_t* rowBytes); 11659c135db83d198e7d8200027c7d2cf60f38517ee3reed@google.com virtual void* onAccessTopLayerPixels(SkImageInfo*, size_t* rowBytes); 1166c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org 1167e54a23fcfa42b2fc9d320650de72bcb2d9566b2dcommit-bot@chromium.org // Subclass save/restore notifiers. 1168e54a23fcfa42b2fc9d320650de72bcb2d9566b2dcommit-bot@chromium.org // Overriders should call the corresponding INHERITED method up the inheritance chain. 1169e54a23fcfa42b2fc9d320650de72bcb2d9566b2dcommit-bot@chromium.org // willSaveLayer()'s return value may suppress full layer allocation. 1170e54a23fcfa42b2fc9d320650de72bcb2d9566b2dcommit-bot@chromium.org enum SaveLayerStrategy { 1171e54a23fcfa42b2fc9d320650de72bcb2d9566b2dcommit-bot@chromium.org kFullLayer_SaveLayerStrategy, 1172e54a23fcfa42b2fc9d320650de72bcb2d9566b2dcommit-bot@chromium.org kNoLayer_SaveLayerStrategy 1173e54a23fcfa42b2fc9d320650de72bcb2d9566b2dcommit-bot@chromium.org }; 1174e54a23fcfa42b2fc9d320650de72bcb2d9566b2dcommit-bot@chromium.org virtual void willSave(SaveFlags); 1175e54a23fcfa42b2fc9d320650de72bcb2d9566b2dcommit-bot@chromium.org virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveFlags); 1176e54a23fcfa42b2fc9d320650de72bcb2d9566b2dcommit-bot@chromium.org virtual void willRestore(); 1177e54a23fcfa42b2fc9d320650de72bcb2d9566b2dcommit-bot@chromium.org 117844c48d062f7996b5b46917e1b312a32ad101f326commit-bot@chromium.org virtual void didConcat(const SkMatrix&); 117944c48d062f7996b5b46917e1b312a32ad101f326commit-bot@chromium.org virtual void didSetMatrix(const SkMatrix&); 118044c48d062f7996b5b46917e1b312a32ad101f326commit-bot@chromium.org 1181ed9806f5c972513d4141c9d1b5a04ab78b3af4cbcommit-bot@chromium.org virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&); 1182ed9806f5c972513d4141c9d1b5a04ab78b3af4cbcommit-bot@chromium.org 11838f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com enum ClipEdgeStyle { 11848f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com kHard_ClipEdgeStyle, 11858f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com kSoft_ClipEdgeStyle 11868f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com }; 11878f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com 11888f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com virtual void onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edgeStyle); 11898f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com virtual void onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle edgeStyle); 11908f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com virtual void onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle); 11918f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com virtual void onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op); 11928f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com 119328361fad1054d59ed4e6a320c7a8b8782a1487c7commit-bot@chromium.org virtual void onDiscard(); 119428361fad1054d59ed4e6a320c7a8b8782a1487c7commit-bot@chromium.org 119574b461961607fa57a150a9282c410ef0cab38764vandebo@chromium.org // Returns the canvas to be used by DrawIter. Default implementation 11964370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com // returns this. Subclasses that encapsulate an indirect canvas may 11974370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com // need to overload this method. The impl must keep track of this, as it 11984370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com // is not released or deleted by the caller. 11994370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com virtual SkCanvas* canvasForDrawIter(); 12004370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com 1201a907ac3e3e3458fbb5d673c3feafb31fd7647b38junov@chromium.org // Clip rectangle bounds. Called internally by saveLayer. 1202a907ac3e3e3458fbb5d673c3feafb31fd7647b38junov@chromium.org // returns false if the entire rectangle is entirely clipped out 1203c4b12f19a46946e1c02f3525e0ea4902b09feac5senorblanco@chromium.org // If non-NULL, The imageFilter parameter will be used to expand the clip 1204c4b12f19a46946e1c02f3525e0ea4902b09feac5senorblanco@chromium.org // and offscreen bounds for any margin required by the filter DAG. 1205a907ac3e3e3458fbb5d673c3feafb31fd7647b38junov@chromium.org bool clipRectBounds(const SkRect* bounds, SaveFlags flags, 1206c4b12f19a46946e1c02f3525e0ea4902b09feac5senorblanco@chromium.org SkIRect* intersection, 1207c4b12f19a46946e1c02f3525e0ea4902b09feac5senorblanco@chromium.org const SkImageFilter* imageFilter = NULL); 1208a907ac3e3e3458fbb5d673c3feafb31fd7647b38junov@chromium.org 1209ed8d6bb2be0ed6a20841573682afaa46dea15175junov@chromium.org // Called by child classes that override clipPath and clipRRect to only 1210ed8d6bb2be0ed6a20841573682afaa46dea15175junov@chromium.org // track fast conservative clip bounds, rather than exact clips. 1211759cf4846804be137229393e04925752423de2d0commit-bot@chromium.org void updateClipConservativelyUsingBounds(const SkRect&, SkRegion::Op, 1212ed8d6bb2be0ed6a20841573682afaa46dea15175junov@chromium.org bool inverseFilled); 1213ed8d6bb2be0ed6a20841573682afaa46dea15175junov@chromium.org 121497af1a64ae6bdddd346d8babfd9f188279dd6644reed@google.com // notify our surface (if we have one) that we are about to draw, so it 121597af1a64ae6bdddd346d8babfd9f188279dd6644reed@google.com // can perform copy-on-write or invalidate any cached images 121697af1a64ae6bdddd346d8babfd9f188279dd6644reed@google.com void predrawNotify(); 121797af1a64ae6bdddd346d8babfd9f188279dd6644reed@google.com 1218210ae2a42613b9048e8e8c4096c5bf4fe2ddf838commit-bot@chromium.org virtual void onPushCull(const SkRect& cullRect); 1219210ae2a42613b9048e8e8c4096c5bf4fe2ddf838commit-bot@chromium.org virtual void onPopCull(); 1220210ae2a42613b9048e8e8c4096c5bf4fe2ddf838commit-bot@chromium.org 12218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprivate: 12228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com class MCRec; 12238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 12245c3d1471e4908706cd053a5e2ea9ded3a6c2eaebreed@google.com SkClipStack fClipStack; 12258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkDeque fMCStack; 12268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com // points to top of stack 12278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com MCRec* fMCRec; 12288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com // the first N recs that can fit here mean we won't call malloc 12298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com uint32_t fMCRecStorage[32]; 12308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 12318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkBounder* fBounder; 1232b0a7ace7cb2a7559bbc254a7c93698bc71bbd245junov@chromium.org int fSaveLayerCount; // number of successful saveLayer calls 1233210ae2a42613b9048e8e8c4096c5bf4fe2ddf838commit-bot@chromium.org int fCullCount; // number of active culls 12348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 123574bb77ee4c747b8c70c5c613987c9f93df71df06mike@reedtribe.org SkMetaData* fMetaData; 123674bb77ee4c747b8c70c5c613987c9f93df71df06mike@reedtribe.org 123797af1a64ae6bdddd346d8babfd9f188279dd6644reed@google.com SkSurface_Base* fSurfaceBase; 123897af1a64ae6bdddd346d8babfd9f188279dd6644reed@google.com SkSurface_Base* getSurfaceBase() const { return fSurfaceBase; } 123997af1a64ae6bdddd346d8babfd9f188279dd6644reed@google.com void setSurfaceBase(SkSurface_Base* sb) { 124097af1a64ae6bdddd346d8babfd9f188279dd6644reed@google.com fSurfaceBase = sb; 124197af1a64ae6bdddd346d8babfd9f188279dd6644reed@google.com } 124297af1a64ae6bdddd346d8babfd9f188279dd6644reed@google.com friend class SkSurface_Base; 124345c3db827d5bcb7c08bf49eff035be667332ec05junov@chromium.org friend class SkSurface_Gpu; 1244fc84359aa920567e72742877a1249f52d076ad35skia.committer@gmail.com 12458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool fDeviceCMDirty; // cleared by updateDeviceCMCache() 12468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void updateDeviceCMCache(); 12478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 12489c135db83d198e7d8200027c7d2cf60f38517ee3reed@google.com friend class SkDrawIter; // needs setupDrawForLayerDevice() 12498926b169f6a0dfa4c2129a98ec2aee205f0c8527reed@google.com friend class AutoDrawLooper; 12509c135db83d198e7d8200027c7d2cf60f38517ee3reed@google.com friend class SkLua; // needs top layer size and offset 12519c135db83d198e7d8200027c7d2cf60f38517ee3reed@google.com friend class SkDeferredDevice; // needs getTopDevice() 12528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 125315a140599942f70e47380e3f700a825c7cece3b4commit-bot@chromium.org SkBaseDevice* createLayerDevice(const SkImageInfo&); 1254e97f0856a8044866b12527819d14cdfbcdfd96f2bsalomon@google.com 12551f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com SkBaseDevice* init(SkBaseDevice*); 1256f0b5e1190af9807a027c0adba2f1380663c8e910reed@google.com 1257403f8d7a052269583175e945689824838e5e0ef4commit-bot@chromium.org /** 1258403f8d7a052269583175e945689824838e5e0ef4commit-bot@chromium.org * DEPRECATED 1259403f8d7a052269583175e945689824838e5e0ef4commit-bot@chromium.org * 1260403f8d7a052269583175e945689824838e5e0ef4commit-bot@chromium.org * Specify a device for this canvas to draw into. If it is not null, its 1261403f8d7a052269583175e945689824838e5e0ef4commit-bot@chromium.org * reference count is incremented. If the canvas was already holding a 1262403f8d7a052269583175e945689824838e5e0ef4commit-bot@chromium.org * device, its reference count is decremented. The new device is returned. 1263403f8d7a052269583175e945689824838e5e0ef4commit-bot@chromium.org */ 1264403f8d7a052269583175e945689824838e5e0ef4commit-bot@chromium.org SkBaseDevice* setRootDevice(SkBaseDevice* device); 126531acdeabce094e9d42f0d6db8eebcf788aaba11askia.committer@gmail.com 12664ebe3821888d550d8a8b89341ec251ba942f0225bsalomon@google.com /** 12674ebe3821888d550d8a8b89341ec251ba942f0225bsalomon@google.com * Gets the size/origin of the top level layer in global canvas coordinates. We don't want this 12684ebe3821888d550d8a8b89341ec251ba942f0225bsalomon@google.com * to be public because it exposes decisions about layer sizes that are internal to the canvas. 12694ebe3821888d550d8a8b89341ec251ba942f0225bsalomon@google.com */ 12704ebe3821888d550d8a8b89341ec251ba942f0225bsalomon@google.com SkISize getTopLayerSize() const; 12714ebe3821888d550d8a8b89341ec251ba942f0225bsalomon@google.com SkIPoint getTopLayerOrigin() const; 1272403f8d7a052269583175e945689824838e5e0ef4commit-bot@chromium.org 1273f0b5e1190af9807a027c0adba2f1380663c8e910reed@google.com // internal methods are not virtual, so they can safely be called by other 1274f0b5e1190af9807a027c0adba2f1380663c8e910reed@google.com // canvas apis, without confusing subclasses (like SkPictureRecording) 12759bf380ce7f848dfb5886dd52b82746521454b739robertphillips@google.com void internalDrawBitmap(const SkBitmap&, const SkMatrix& m, const SkPaint* paint); 12767112173c3c4cd1b1e7da8cdf971d71f01dd91299reed@google.com void internalDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, 1277eed779d866e1e239bfb9ebc6a225b7345a41adf9commit-bot@chromium.org const SkRect& dst, const SkPaint* paint, 1278eed779d866e1e239bfb9ebc6a225b7345a41adf9commit-bot@chromium.org DrawBitmapRectFlags flags); 1279f0b5e1190af9807a027c0adba2f1380663c8e910reed@google.com void internalDrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, 1280f0b5e1190af9807a027c0adba2f1380663c8e910reed@google.com const SkRect& dst, const SkPaint* paint); 1281fa6ac938e64fe11b442d05fe8a90ddac2d1951f9bsalomon@google.com void internalDrawPaint(const SkPaint& paint); 12828926b169f6a0dfa4c2129a98ec2aee205f0c8527reed@google.com int internalSaveLayer(const SkRect* bounds, const SkPaint* paint, 1283e54a23fcfa42b2fc9d320650de72bcb2d9566b2dcommit-bot@chromium.org SaveFlags, bool justForImageFilter, SaveLayerStrategy strategy); 12841f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com void internalDrawDevice(SkBaseDevice*, int x, int y, const SkPaint*); 1285fa6ac938e64fe11b442d05fe8a90ddac2d1951f9bsalomon@google.com 12868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com // shared by save() and saveLayer() 12878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com int internalSave(SaveFlags flags); 12888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void internalRestore(); 128952c748b1691f02f90b27c35bc05074fcef709e66bungeman@google.com static void DrawRect(const SkDraw& draw, const SkPaint& paint, 129052c748b1691f02f90b27c35bc05074fcef709e66bungeman@google.com const SkRect& r, SkScalar textSize); 129152c748b1691f02f90b27c35bc05074fcef709e66bungeman@google.com static void DrawTextDecorations(const SkDraw& draw, const SkPaint& paint, 129252c748b1691f02f90b27c35bc05074fcef709e66bungeman@google.com const char text[], size_t byteLength, 129352c748b1691f02f90b27c35bc05074fcef709e66bungeman@google.com SkScalar x, SkScalar y); 12944b226023832011bc3bcdd1e5092ff0645ad0bdeereed@google.com 12958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /* These maintain a cache of the clip bounds in local coordinates, 12968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com (converted to 2s-compliment if floats are slow). 12978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 1298c0784dbd408596aff13a5d97448f7a9e5d3cf7d9reed@google.com mutable SkRect fCachedLocalClipBounds; 1299c0784dbd408596aff13a5d97448f7a9e5d3cf7d9reed@google.com mutable bool fCachedLocalClipBoundsDirty; 13008f0a7b8e7334187a5d7d5ab7fde5a3c3009555f5caryclark@google.com bool fAllowSoftClip; 130145a75fb4d0ca5daa0ac5e634238970306e3b5838caryclark@google.com bool fAllowSimplifyClip; 13028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1303c0784dbd408596aff13a5d97448f7a9e5d3cf7d9reed@google.com const SkRect& getLocalClipBounds() const { 1304c0784dbd408596aff13a5d97448f7a9e5d3cf7d9reed@google.com if (fCachedLocalClipBoundsDirty) { 1305c0784dbd408596aff13a5d97448f7a9e5d3cf7d9reed@google.com if (!this->getClipBounds(&fCachedLocalClipBounds)) { 1306c0784dbd408596aff13a5d97448f7a9e5d3cf7d9reed@google.com fCachedLocalClipBounds.setEmpty(); 1307c0784dbd408596aff13a5d97448f7a9e5d3cf7d9reed@google.com } 1308c0784dbd408596aff13a5d97448f7a9e5d3cf7d9reed@google.com fCachedLocalClipBoundsDirty = false; 13098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 1310c0784dbd408596aff13a5d97448f7a9e5d3cf7d9reed@google.com return fCachedLocalClipBounds; 13118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 131245a75fb4d0ca5daa0ac5e634238970306e3b5838caryclark@google.com 13135c3d1471e4908706cd053a5e2ea9ded3a6c2eaebreed@google.com class AutoValidateClip : ::SkNoncopyable { 13145c3d1471e4908706cd053a5e2ea9ded3a6c2eaebreed@google.com public: 13155c3d1471e4908706cd053a5e2ea9ded3a6c2eaebreed@google.com explicit AutoValidateClip(SkCanvas* canvas) : fCanvas(canvas) { 13165c3d1471e4908706cd053a5e2ea9ded3a6c2eaebreed@google.com fCanvas->validateClip(); 13175c3d1471e4908706cd053a5e2ea9ded3a6c2eaebreed@google.com } 13185c3d1471e4908706cd053a5e2ea9ded3a6c2eaebreed@google.com ~AutoValidateClip() { fCanvas->validateClip(); } 13195c3d1471e4908706cd053a5e2ea9ded3a6c2eaebreed@google.com 13205c3d1471e4908706cd053a5e2ea9ded3a6c2eaebreed@google.com private: 13215c3d1471e4908706cd053a5e2ea9ded3a6c2eaebreed@google.com const SkCanvas* fCanvas; 13225c3d1471e4908706cd053a5e2ea9ded3a6c2eaebreed@google.com }; 13235c3d1471e4908706cd053a5e2ea9ded3a6c2eaebreed@google.com 13245c3d1471e4908706cd053a5e2ea9ded3a6c2eaebreed@google.com#ifdef SK_DEBUG 1325520cf8b33e788268432c6314c52dfcef22e776aecommit-bot@chromium.org // The cull stack rects are in device-space 1326520cf8b33e788268432c6314c52dfcef22e776aecommit-bot@chromium.org SkTDArray<SkIRect> fCullStack; 1327520cf8b33e788268432c6314c52dfcef22e776aecommit-bot@chromium.org void validateCull(const SkIRect&); 13285c3d1471e4908706cd053a5e2ea9ded3a6c2eaebreed@google.com void validateClip() const; 13295c3d1471e4908706cd053a5e2ea9ded3a6c2eaebreed@google.com#else 13305c3d1471e4908706cd053a5e2ea9ded3a6c2eaebreed@google.com void validateClip() const {} 13315c3d1471e4908706cd053a5e2ea9ded3a6c2eaebreed@google.com#endif 133215e9d3e66e161ce23df30bc13f8a0c87d196b463robertphillips@google.com 133315e9d3e66e161ce23df30bc13f8a0c87d196b463robertphillips@google.com typedef SkRefCnt INHERITED; 13348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}; 13358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 13368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/** Stack helper class to automatically call restoreToCount() on the canvas 13378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com when this object goes out of scope. Use this to guarantee that the canvas 13388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com is restored to a known state. 13398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com*/ 13408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkAutoCanvasRestore : SkNoncopyable { 13418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic: 13422887119a63e314704673b971e9bc9a3461313a2ccommit-bot@chromium.org SkAutoCanvasRestore(SkCanvas* canvas, bool doSave) : fCanvas(canvas), fSaveCount(0) { 13432887119a63e314704673b971e9bc9a3461313a2ccommit-bot@chromium.org if (fCanvas) { 13442887119a63e314704673b971e9bc9a3461313a2ccommit-bot@chromium.org fSaveCount = canvas->getSaveCount(); 13452887119a63e314704673b971e9bc9a3461313a2ccommit-bot@chromium.org if (doSave) { 13462887119a63e314704673b971e9bc9a3461313a2ccommit-bot@chromium.org canvas->save(); 13472887119a63e314704673b971e9bc9a3461313a2ccommit-bot@chromium.org } 13488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 13498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 13508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com ~SkAutoCanvasRestore() { 1351f6c9a5ba5cded8d4f663b13e71e6e1e572322b41reed@google.com if (fCanvas) { 1352f6c9a5ba5cded8d4f663b13e71e6e1e572322b41reed@google.com fCanvas->restoreToCount(fSaveCount); 1353f6c9a5ba5cded8d4f663b13e71e6e1e572322b41reed@google.com } 1354f6c9a5ba5cded8d4f663b13e71e6e1e572322b41reed@google.com } 1355f6c9a5ba5cded8d4f663b13e71e6e1e572322b41reed@google.com 1356f6c9a5ba5cded8d4f663b13e71e6e1e572322b41reed@google.com /** 1357f6c9a5ba5cded8d4f663b13e71e6e1e572322b41reed@google.com * Perform the restore now, instead of waiting for the destructor. Will 1358f6c9a5ba5cded8d4f663b13e71e6e1e572322b41reed@google.com * only do this once. 1359f6c9a5ba5cded8d4f663b13e71e6e1e572322b41reed@google.com */ 1360f6c9a5ba5cded8d4f663b13e71e6e1e572322b41reed@google.com void restore() { 1361f6c9a5ba5cded8d4f663b13e71e6e1e572322b41reed@google.com if (fCanvas) { 1362f6c9a5ba5cded8d4f663b13e71e6e1e572322b41reed@google.com fCanvas->restoreToCount(fSaveCount); 1363f6c9a5ba5cded8d4f663b13e71e6e1e572322b41reed@google.com fCanvas = NULL; 1364f6c9a5ba5cded8d4f663b13e71e6e1e572322b41reed@google.com } 13658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 13668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 13678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprivate: 13688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkCanvas* fCanvas; 13698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com int fSaveCount; 13708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}; 1371e61a86cfa00ea393ecc4a71fca94e1d476a37ecccommit-bot@chromium.org#define SkAutoCanvasRestore(...) SK_REQUIRE_LOCAL_VAR(SkAutoCanvasRestore) 13728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 13730a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com/** Stack helper class to automatically open and close a comment block 13740a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com */ 13750a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.comclass SkAutoCommentBlock : SkNoncopyable { 13760a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.compublic: 13770a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com SkAutoCommentBlock(SkCanvas* canvas, const char* description) { 13780a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com fCanvas = canvas; 13790a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com if (NULL != fCanvas) { 13800a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com fCanvas->beginCommentGroup(description); 13810a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com } 13820a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com } 13830a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com 13840a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com ~SkAutoCommentBlock() { 13850a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com if (NULL != fCanvas) { 13860a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com fCanvas->endCommentGroup(); 13870a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com } 13880a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com } 13890a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com 13900a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.comprivate: 13910a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com SkCanvas* fCanvas; 13920a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com}; 1393e61a86cfa00ea393ecc4a71fca94e1d476a37ecccommit-bot@chromium.org#define SkAutoCommentBlock(...) SK_REQUIRE_LOCAL_VAR(SkAutoCommentBlock) 13940a4805e33f8ddb445a2fd061462e715e1707f049robertphillips@google.com 1395c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org/** 1396c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org * If the caller wants read-only access to the pixels in a canvas, it can just 1397c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org * call canvas->peekPixels(), since that is the fastest way to "peek" at the 1398c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org * pixels on a raster-backed canvas. 1399c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org * 1400c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org * If the canvas has pixels, but they are not readily available to the CPU 1401c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org * (e.g. gpu-backed), then peekPixels() will fail, but readPixels() will 1402c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org * succeed (though be slower, since it will return a copy of the pixels). 1403c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org * 1404c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org * SkAutoROCanvasPixels encapsulates these two techniques, trying first to call 1405c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org * peekPixels() (for performance), but if that fails, calling readPixels() and 1406c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org * storing the copy locally. 1407c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org * 1408c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org * The caller must respect the restrictions associated with peekPixels(), since 1409c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org * that may have been called: The returned information is invalidated if... 1410c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org * - any API is called on the canvas (or its parent surface if present) 1411c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org * - the canvas goes out of scope 1412c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org */ 1413c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.orgclass SkAutoROCanvasPixels : SkNoncopyable { 1414c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.orgpublic: 1415c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org SkAutoROCanvasPixels(SkCanvas* canvas); 1416c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org 1417c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org // returns NULL on failure 1418c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org const void* addr() const { return fAddr; } 141902d6f546161e2c98d69066373cec3f54f3c46252skia.committer@gmail.com 1420c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org // undefined if addr() == NULL 1421c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org size_t rowBytes() const { return fRowBytes; } 142202d6f546161e2c98d69066373cec3f54f3c46252skia.committer@gmail.com 1423c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org // undefined if addr() == NULL 1424c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org const SkImageInfo& info() const { return fInfo; } 1425c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org 1426c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org // helper that, if returns true, installs the pixels into the bitmap. Note 1427c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org // that the bitmap may reference the address returned by peekPixels(), so 1428c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org // the caller must respect the restrictions associated with peekPixels(). 1429c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org bool asROBitmap(SkBitmap*) const; 1430c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org 1431c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.orgprivate: 1432c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org SkBitmap fBitmap; // used if peekPixels() fails 1433c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org const void* fAddr; // NULL on failure 1434c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org SkImageInfo fInfo; 1435c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org size_t fRowBytes; 1436c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org}; 1437c3bd8af6d5722e854feca70c40d92f4954c5b67bcommit-bot@chromium.org 14388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif 1439