14370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com/* 29ed02b9da25a76ee4c73c1ab19c18b899a223a17junov@chromium.org * Copyright 2012 Google Inc. 34370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com * 44370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com * Use of this source code is governed by a BSD-style license that can be 54370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com * found in the LICENSE file. 64370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com */ 74370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com 84370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com#ifndef SkDeferredCanvas_DEFINED 94370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com#define SkDeferredCanvas_DEFINED 104370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com 114370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com#include "SkCanvas.h" 124370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com#include "SkPixelRef.h" 134370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com 149c135db83d198e7d8200027c7d2cf60f38517ee3reed@google.comclass SkDeferredDevice; 1567d74228448cab0f1eca77fff444ddbe8c2eaef3junov@chromium.orgclass SkImage; 1667d74228448cab0f1eca77fff444ddbe8c2eaef3junov@chromium.orgclass SkSurface; 1777eec248cbd5a0c2f5f8595e62e3bff5ea363f17junov@chromium.org 184370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com/** \class SkDeferredCanvas 1977eec248cbd5a0c2f5f8595e62e3bff5ea363f17junov@chromium.org Subclass of SkCanvas that encapsulates an SkPicture or SkGPipe for deferred 2077eec248cbd5a0c2f5f8595e62e3bff5ea363f17junov@chromium.org drawing. The main difference between this class and SkPictureRecord (the 2177eec248cbd5a0c2f5f8595e62e3bff5ea363f17junov@chromium.org canvas provided by SkPicture) is that this is a full drop-in replacement 2277eec248cbd5a0c2f5f8595e62e3bff5ea363f17junov@chromium.org for SkCanvas, while SkPictureRecord only supports draw operations. 234370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com SkDeferredCanvas will transparently trigger the flushing of deferred 2474b461961607fa57a150a9282c410ef0cab38764vandebo@chromium.org draw operations when an attempt is made to access the pixel data. 254370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com*/ 264370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.comclass SK_API SkDeferredCanvas : public SkCanvas { 274370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.compublic: 28eddb02c82d6e35a05f84798b23aac48a446c1aa6commit-bot@chromium.org class SK_API NotificationClient; 294370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com 3066070a527c480d1cef5f7f7136f68d4f17b68f06junov@chromium.org /** Construct a canvas with the specified surface to draw into. 3166070a527c480d1cef5f7f7136f68d4f17b68f06junov@chromium.org This factory must be used for newImageSnapshot to work. 3266070a527c480d1cef5f7f7136f68d4f17b68f06junov@chromium.org @param surface Specifies a surface for the canvas to draw into. 3366070a527c480d1cef5f7f7136f68d4f17b68f06junov@chromium.org */ 3466070a527c480d1cef5f7f7136f68d4f17b68f06junov@chromium.org static SkDeferredCanvas* Create(SkSurface* surface); 3566070a527c480d1cef5f7f7136f68d4f17b68f06junov@chromium.org 3628183b4043a969df12592e8dd47cf95b80755284reed@google.com// static SkDeferredCanvas* Create(SkBaseDevice* device); 3767d74228448cab0f1eca77fff444ddbe8c2eaef3junov@chromium.org 384370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com virtual ~SkDeferredCanvas(); 394370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com 404370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com /** 417070f76b90b098b4713bc0d13dc129adea64d7efjunov@chromium.org * Specify the surface to be used by this canvas. Calling setSurface will 427070f76b90b098b4713bc0d13dc129adea64d7efjunov@chromium.org * release the previously set surface or device. Takes a reference on the 437070f76b90b098b4713bc0d13dc129adea64d7efjunov@chromium.org * surface. 447070f76b90b098b4713bc0d13dc129adea64d7efjunov@chromium.org * 457070f76b90b098b4713bc0d13dc129adea64d7efjunov@chromium.org * @param surface The surface that the canvas will raw into 467070f76b90b098b4713bc0d13dc129adea64d7efjunov@chromium.org * @return The surface argument, for convenience. 477070f76b90b098b4713bc0d13dc129adea64d7efjunov@chromium.org */ 487070f76b90b098b4713bc0d13dc129adea64d7efjunov@chromium.org SkSurface* setSurface(SkSurface* surface); 497070f76b90b098b4713bc0d13dc129adea64d7efjunov@chromium.org 507070f76b90b098b4713bc0d13dc129adea64d7efjunov@chromium.org /** 519ed02b9da25a76ee4c73c1ab19c18b899a223a17junov@chromium.org * Specify a NotificationClient to be used by this canvas. Calling 52fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com * setNotificationClient will release the previously set 5352805485581cff7e13134aa1465a2950f7bed007junov@chromium.org * NotificationClient, if any. SkDeferredCanvas does not take ownership 5452805485581cff7e13134aa1465a2950f7bed007junov@chromium.org * of the notification client. Therefore user code is resposible 5552805485581cff7e13134aa1465a2950f7bed007junov@chromium.org * for its destruction. The notification client must be unregistered 5652805485581cff7e13134aa1465a2950f7bed007junov@chromium.org * by calling setNotificationClient(NULL) if it is destroyed before 5752805485581cff7e13134aa1465a2950f7bed007junov@chromium.org * this canvas. 584370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com * Note: Must be called after the device is set with setDevice. 594370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com * 609ed02b9da25a76ee4c73c1ab19c18b899a223a17junov@chromium.org * @param notificationClient interface for dispatching notifications 619ed02b9da25a76ee4c73c1ab19c18b899a223a17junov@chromium.org * @return The notificationClient argument, for convenience. 624370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com */ 639ed02b9da25a76ee4c73c1ab19c18b899a223a17junov@chromium.org NotificationClient* setNotificationClient(NotificationClient* notificationClient); 644370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com 654370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com /** 664370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com * Enable or disable deferred drawing. When deferral is disabled, 674370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com * pending draw operations are immediately flushed and from then on, 684370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com * the SkDeferredCanvas behaves just like a regular SkCanvas. 694370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com * This method must not be called while the save/restore stack is in use. 704370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com * @param deferred true/false 714370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com */ 724370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com void setDeferredDrawing(bool deferred); 734370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com 74bfeddae9da240693441556b2f278827e213f75e8junov@chromium.org /** 75b10a6bd0a7df0ceeea0d53585c049450ec58b4b9junov@chromium.org * Returns true if deferred drawing is currenlty enabled. 76b10a6bd0a7df0ceeea0d53585c049450ec58b4b9junov@chromium.org */ 7788e29146c1efc5ff8eec06076c9dce12684f2c11junov@chromium.org bool isDeferredDrawing() const; 7888e29146c1efc5ff8eec06076c9dce12684f2c11junov@chromium.org 7988e29146c1efc5ff8eec06076c9dce12684f2c11junov@chromium.org /** 80fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com * Returns true if the canvas contains a fresh frame. A frame is 8188e29146c1efc5ff8eec06076c9dce12684f2c11junov@chromium.org * considered fresh when its content do not depend on the contents 8288e29146c1efc5ff8eec06076c9dce12684f2c11junov@chromium.org * of the previous frame. For example, if a canvas is cleared before 8388e29146c1efc5ff8eec06076c9dce12684f2c11junov@chromium.org * drawing each frame, the frames will all be considered fresh. 8488e29146c1efc5ff8eec06076c9dce12684f2c11junov@chromium.org * A frame is defined as the graphics image produced by as a result 8588e29146c1efc5ff8eec06076c9dce12684f2c11junov@chromium.org * of all the canvas draws operation executed between two successive 8688e29146c1efc5ff8eec06076c9dce12684f2c11junov@chromium.org * calls to isFreshFrame. The result of isFreshFrame is computed 8788e29146c1efc5ff8eec06076c9dce12684f2c11junov@chromium.org * conservatively, so it may report false negatives. 8888e29146c1efc5ff8eec06076c9dce12684f2c11junov@chromium.org */ 8988e29146c1efc5ff8eec06076c9dce12684f2c11junov@chromium.org bool isFreshFrame() const; 90b10a6bd0a7df0ceeea0d53585c049450ec58b4b9junov@chromium.org 91b10a6bd0a7df0ceeea0d53585c049450ec58b4b9junov@chromium.org /** 9249005bf8929dd8ca86431e13414d683b509cd538yunchao.he * Returns canvas's size. 9349005bf8929dd8ca86431e13414d683b509cd538yunchao.he */ 9449005bf8929dd8ca86431e13414d683b509cd538yunchao.he SkISize getCanvasSize() const; 9549005bf8929dd8ca86431e13414d683b509cd538yunchao.he 9649005bf8929dd8ca86431e13414d683b509cd538yunchao.he /** 97a38dfb6981379770221b16b5ec036b08f3005973junov@chromium.org * Returns true if the canvas has recorded draw commands that have 98a38dfb6981379770221b16b5ec036b08f3005973junov@chromium.org * not yet been played back. 99a38dfb6981379770221b16b5ec036b08f3005973junov@chromium.org */ 100a38dfb6981379770221b16b5ec036b08f3005973junov@chromium.org bool hasPendingCommands() const; 101a38dfb6981379770221b16b5ec036b08f3005973junov@chromium.org 102a38dfb6981379770221b16b5ec036b08f3005973junov@chromium.org /** 10367d74228448cab0f1eca77fff444ddbe8c2eaef3junov@chromium.org * Flushes pending draw commands, if any, and returns an image of the 10467d74228448cab0f1eca77fff444ddbe8c2eaef3junov@chromium.org * current state of the surface pixels up to this point. Subsequent 10567d74228448cab0f1eca77fff444ddbe8c2eaef3junov@chromium.org * changes to the surface (by drawing into its canvas) will not be 10667d74228448cab0f1eca77fff444ddbe8c2eaef3junov@chromium.org * reflected in this image. Will return NULL if the deferred canvas 10767d74228448cab0f1eca77fff444ddbe8c2eaef3junov@chromium.org * was not constructed from an SkSurface. 10867d74228448cab0f1eca77fff444ddbe8c2eaef3junov@chromium.org */ 1095ee449af7448c202cfc6e9a359d8f996392885b2junov@chromium.org SkImage* newImageSnapshot(); 11067d74228448cab0f1eca77fff444ddbe8c2eaef3junov@chromium.org 11167d74228448cab0f1eca77fff444ddbe8c2eaef3junov@chromium.org /** 112bfeddae9da240693441556b2f278827e213f75e8junov@chromium.org * Specify the maximum number of bytes to be allocated for the purpose 113bfeddae9da240693441556b2f278827e213f75e8junov@chromium.org * of recording draw commands to this canvas. The default limit, is 114bfeddae9da240693441556b2f278827e213f75e8junov@chromium.org * 64MB. 115bfeddae9da240693441556b2f278827e213f75e8junov@chromium.org * @param maxStorage The maximum number of bytes to be allocated. 116bfeddae9da240693441556b2f278827e213f75e8junov@chromium.org */ 117bfeddae9da240693441556b2f278827e213f75e8junov@chromium.org void setMaxRecordingStorage(size_t maxStorage); 118bfeddae9da240693441556b2f278827e213f75e8junov@chromium.org 1192e14ba8ceb41c68042ff133fecf0561a2c22efcajunov@chromium.org /** 1202e14ba8ceb41c68042ff133fecf0561a2c22efcajunov@chromium.org * Returns the number of bytes currently allocated for the purpose of 1212e14ba8ceb41c68042ff133fecf0561a2c22efcajunov@chromium.org * recording draw commands. 1222e14ba8ceb41c68042ff133fecf0561a2c22efcajunov@chromium.org */ 1232e14ba8ceb41c68042ff133fecf0561a2c22efcajunov@chromium.org size_t storageAllocatedForRecording() const; 1242e14ba8ceb41c68042ff133fecf0561a2c22efcajunov@chromium.org 1252e14ba8ceb41c68042ff133fecf0561a2c22efcajunov@chromium.org /** 1262e14ba8ceb41c68042ff133fecf0561a2c22efcajunov@chromium.org * Attempt to reduce the storage allocated for recording by evicting 1272e14ba8ceb41c68042ff133fecf0561a2c22efcajunov@chromium.org * cache resources. 1282e14ba8ceb41c68042ff133fecf0561a2c22efcajunov@chromium.org * @param bytesToFree minimum number of bytes that should be attempted to 1292e14ba8ceb41c68042ff133fecf0561a2c22efcajunov@chromium.org * be freed. 1302e14ba8ceb41c68042ff133fecf0561a2c22efcajunov@chromium.org * @return number of bytes actually freed. 1312e14ba8ceb41c68042ff133fecf0561a2c22efcajunov@chromium.org */ 1322e14ba8ceb41c68042ff133fecf0561a2c22efcajunov@chromium.org size_t freeMemoryIfPossible(size_t bytesToFree); 1332e14ba8ceb41c68042ff133fecf0561a2c22efcajunov@chromium.org 134fb10389403cf1cc771e103016207fde84c5f4825junov@chromium.org /** 1357775fd5779e632d6f5724e0e5d39ed347cf965b0sugoi@google.com * Specifies the maximum size (in bytes) allowed for a given image to be 1367775fd5779e632d6f5724e0e5d39ed347cf965b0sugoi@google.com * rendered using the deferred canvas. 1377775fd5779e632d6f5724e0e5d39ed347cf965b0sugoi@google.com */ 1387775fd5779e632d6f5724e0e5d39ed347cf965b0sugoi@google.com void setBitmapSizeThreshold(size_t sizeThreshold); 13952d9ac6c92ddf33b3b05eb77ba9509a7aa441657reed size_t getBitmapSizeThreshold() const { return fBitmapSizeThreshold; } 1407775fd5779e632d6f5724e0e5d39ed347cf965b0sugoi@google.com 1417775fd5779e632d6f5724e0e5d39ed347cf965b0sugoi@google.com /** 142fb10389403cf1cc771e103016207fde84c5f4825junov@chromium.org * Executes all pending commands without drawing 143fb10389403cf1cc771e103016207fde84c5f4825junov@chromium.org */ 144fb10389403cf1cc771e103016207fde84c5f4825junov@chromium.org void silentFlush(); 145fb10389403cf1cc771e103016207fde84c5f4825junov@chromium.org 1464370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com // Overrides of the SkCanvas interface 147a907ac3e3e3458fbb5d673c3feafb31fd7647b38junov@chromium.org virtual bool isDrawingToLayer() const SK_OVERRIDE; 1484370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com virtual void clear(SkColor) SK_OVERRIDE; 1494370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com virtual void drawPaint(const SkPaint& paint) SK_OVERRIDE; 1504370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com virtual void drawPoints(PointMode mode, size_t count, const SkPoint pts[], 1514370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com const SkPaint& paint) SK_OVERRIDE; 1524ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com virtual void drawOval(const SkRect&, const SkPaint& paint) SK_OVERRIDE; 1537ce564cccb246ec56427085872b2e1458fe74bd1bsalomon@google.com virtual void drawRect(const SkRect& rect, const SkPaint& paint) SK_OVERRIDE; 1544ed0fb768409bf97b79899c3990d8c15f5e9d784reed@google.com virtual void drawRRect(const SkRRect&, const SkPaint& paint) SK_OVERRIDE; 1557ce564cccb246ec56427085872b2e1458fe74bd1bsalomon@google.com virtual void drawPath(const SkPath& path, const SkPaint& paint) 1567ce564cccb246ec56427085872b2e1458fe74bd1bsalomon@google.com SK_OVERRIDE; 15774b461961607fa57a150a9282c410ef0cab38764vandebo@chromium.org virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left, 1584370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com SkScalar top, const SkPaint* paint) 1594370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com SK_OVERRIDE; 1607112173c3c4cd1b1e7da8cdf971d71f01dd91299reed@google.com virtual void drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src, 161eed779d866e1e239bfb9ebc6a225b7345a41adf9commit-bot@chromium.org const SkRect& dst, const SkPaint* paint, 162eed779d866e1e239bfb9ebc6a225b7345a41adf9commit-bot@chromium.org DrawBitmapRectFlags flags) SK_OVERRIDE; 1634370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com 1644370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m, 1654370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com const SkPaint* paint) SK_OVERRIDE; 1664370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com virtual void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, 1674370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com const SkRect& dst, const SkPaint* paint) 1684370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com SK_OVERRIDE; 1694370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com virtual void drawSprite(const SkBitmap& bitmap, int left, int top, 1704370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com const SkPaint* paint) SK_OVERRIDE; 1714370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com virtual void drawVertices(VertexMode vmode, int vertexCount, 1724370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com const SkPoint vertices[], const SkPoint texs[], 1734370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com const SkColor colors[], SkXfermode* xmode, 1744370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com const uint16_t indices[], int indexCount, 1754370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com const SkPaint& paint) SK_OVERRIDE; 1764370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com virtual SkDrawFilter* setDrawFilter(SkDrawFilter* filter) SK_OVERRIDE; 1774370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com 178ab5827354e2c23624acc3fc1fe4a83788bc99e96commit-bot@chromium.orgprotected: 1795f6102d07982043542343ff0a6c67b1319ac9fc7Florin Malita virtual void willSave() SK_OVERRIDE; 180e54a23fcfa42b2fc9d320650de72bcb2d9566b2dcommit-bot@chromium.org virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveFlags) SK_OVERRIDE; 181e54a23fcfa42b2fc9d320650de72bcb2d9566b2dcommit-bot@chromium.org virtual void willRestore() SK_OVERRIDE; 182e54a23fcfa42b2fc9d320650de72bcb2d9566b2dcommit-bot@chromium.org 18344c48d062f7996b5b46917e1b312a32ad101f326commit-bot@chromium.org virtual void didConcat(const SkMatrix&) SK_OVERRIDE; 18444c48d062f7996b5b46917e1b312a32ad101f326commit-bot@chromium.org virtual void didSetMatrix(const SkMatrix&) SK_OVERRIDE; 18544c48d062f7996b5b46917e1b312a32ad101f326commit-bot@chromium.org 186e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK_OVERRIDE; 187e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com virtual void onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y, 188e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com const SkPaint&) SK_OVERRIDE; 189e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com virtual void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[], 190e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com const SkPaint&) SK_OVERRIDE; 191e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com virtual void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[], 192e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com SkScalar constY, const SkPaint&) SK_OVERRIDE; 193e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com virtual void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path, 194e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com const SkMatrix* matrix, const SkPaint&) SK_OVERRIDE; 195b7425173f96e93b090787e2386ba5f022b6c2869fmalita virtual void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, 196b7425173f96e93b090787e2386ba5f022b6c2869fmalita const SkPaint& paint) SK_OVERRIDE; 197b3c9d1c33caf325aada244204215eb790c228c12dandov virtual void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4], 198b3c9d1c33caf325aada244204215eb790c228c12dandov const SkPoint texCoords[4], SkXfermode* xmode, 199b3c9d1c33caf325aada244204215eb790c228c12dandov const SkPaint& paint) SK_OVERRIDE; 200b3c9d1c33caf325aada244204215eb790c228c12dandov 2018f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE; 2028f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE; 2038f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE; 2048f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com virtual void onClipRegion(const SkRegion&, SkRegion::Op) SK_OVERRIDE; 2058f90a892c5130d4d26b5588e1ff151d01a40688arobertphillips@google.com 206d5fa1a455aad61f3e99081fe7a9b065cb3b115c6reed virtual void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) SK_OVERRIDE; 2079b14f26d0f3a974f3dd626c8354e1db1cfcd322frobertphillips 2084370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.compublic: 20952805485581cff7e13134aa1465a2950f7bed007junov@chromium.org class NotificationClient { 2104370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com public: 2115990397d08640a80a7ccb3955b9952b356be3f86robertphillips@google.com virtual ~NotificationClient() {} 2125990397d08640a80a7ccb3955b9952b356be3f86robertphillips@google.com 2139ed02b9da25a76ee4c73c1ab19c18b899a223a17junov@chromium.org /** 2149ed02b9da25a76ee4c73c1ab19c18b899a223a17junov@chromium.org * Called before executing one or several draw commands, which means 2159ed02b9da25a76ee4c73c1ab19c18b899a223a17junov@chromium.org * once per flush when deferred rendering is enabled. 2169ed02b9da25a76ee4c73c1ab19c18b899a223a17junov@chromium.org */ 2174370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com virtual void prepareForDraw() {} 2189ed02b9da25a76ee4c73c1ab19c18b899a223a17junov@chromium.org 2199ed02b9da25a76ee4c73c1ab19c18b899a223a17junov@chromium.org /** 2209ed02b9da25a76ee4c73c1ab19c18b899a223a17junov@chromium.org * Called after a recording a draw command if additional memory 2219ed02b9da25a76ee4c73c1ab19c18b899a223a17junov@chromium.org * had to be allocated for recording. 222fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com * @param newAllocatedStorage same value as would be returned by 2239ed02b9da25a76ee4c73c1ab19c18b899a223a17junov@chromium.org * storageAllocatedForRecording(), for convenience. 2249ed02b9da25a76ee4c73c1ab19c18b899a223a17junov@chromium.org */ 2259ed02b9da25a76ee4c73c1ab19c18b899a223a17junov@chromium.org virtual void storageAllocatedForRecordingChanged( 2269ed02b9da25a76ee4c73c1ab19c18b899a223a17junov@chromium.org size_t newAllocatedStorage) {} 2279ed02b9da25a76ee4c73c1ab19c18b899a223a17junov@chromium.org 2289ed02b9da25a76ee4c73c1ab19c18b899a223a17junov@chromium.org /** 2299ed02b9da25a76ee4c73c1ab19c18b899a223a17junov@chromium.org * Called after pending draw commands have been flushed 2309ed02b9da25a76ee4c73c1ab19c18b899a223a17junov@chromium.org */ 2319ed02b9da25a76ee4c73c1ab19c18b899a223a17junov@chromium.org virtual void flushedDrawCommands() {} 232fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com 23352a00cac514dfd9cedb85a9c3e92fdb3e32a03f7junov@google.com /** 23452a00cac514dfd9cedb85a9c3e92fdb3e32a03f7junov@google.com * Called after pending draw commands have been skipped, meaning 23552a00cac514dfd9cedb85a9c3e92fdb3e32a03f7junov@google.com * that they were optimized-out because the canvas is cleared 23652a00cac514dfd9cedb85a9c3e92fdb3e32a03f7junov@google.com * or completely overwritten by the command currently being recorded. 23752a00cac514dfd9cedb85a9c3e92fdb3e32a03f7junov@google.com */ 23852a00cac514dfd9cedb85a9c3e92fdb3e32a03f7junov@google.com virtual void skippedPendingDrawCommands() {} 2394370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com }; 2404370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com 24177eec248cbd5a0c2f5f8595e62e3bff5ea363f17junov@chromium.orgprotected: 2424370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com virtual SkCanvas* canvasForDrawIter(); 2439c135db83d198e7d8200027c7d2cf60f38517ee3reed@google.com SkDeferredDevice* getDeferredDevice() const; 2444370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com 2454370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.comprivate: 2469c135db83d198e7d8200027c7d2cf60f38517ee3reed@google.com SkDeferredCanvas(SkDeferredDevice*); 24766070a527c480d1cef5f7f7136f68d4f17b68f06junov@chromium.org 2489ed02b9da25a76ee4c73c1ab19c18b899a223a17junov@chromium.org void recordedDrawCommand(); 2495e5a095a94281167056da707b03930f135748d71junov@chromium.org SkCanvas* drawingCanvas() const; 25088e29146c1efc5ff8eec06076c9dce12684f2c11junov@chromium.org SkCanvas* immediateCanvas() const; 2514370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com bool isFullFrame(const SkRect*, const SkPaint*) const; 2524370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com void validate() const; 2534370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com void init(); 25452d9ac6c92ddf33b3b05eb77ba9509a7aa441657reed 25552d9ac6c92ddf33b3b05eb77ba9509a7aa441657reed size_t fBitmapSizeThreshold; 25652d9ac6c92ddf33b3b05eb77ba9509a7aa441657reed bool fDeferredDrawing; 2574370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com 25849005bf8929dd8ca86431e13414d683b509cd538yunchao.he mutable SkISize fCachedCanvasSize; 25949005bf8929dd8ca86431e13414d683b509cd538yunchao.he mutable bool fCachedCanvasSizeDirty; 26049005bf8929dd8ca86431e13414d683b509cd538yunchao.he 26188e29146c1efc5ff8eec06076c9dce12684f2c11junov@chromium.org friend class SkDeferredCanvasTester; // for unit testing 2624370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com typedef SkCanvas INHERITED; 2634370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com}; 2644370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com 2654370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com 2664370aedf7f55af74e9ebb4ad1c2e010c08236dfajunov@google.com#endif 267