180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru/*
380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Copyright 2006 The Android Open Source Project
480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru *
580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Use of this source code is governed by a BSD-style license that can be
680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * found in the LICENSE file.
780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */
880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
1080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifndef SkCanvas_DEFINED
1180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#define SkCanvas_DEFINED
1280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
1380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkTypes.h"
1480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkBitmap.h"
1580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkDeque.h"
1680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkClipStack.h"
1780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkPaint.h"
1880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkRefCnt.h"
1980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkPath.h"
2080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkRegion.h"
2180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkXfermode.h"
2280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
2380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkBounder;
240a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenbergerclass SkBaseDevice;
2580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkDraw;
2680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkDrawFilter;
2780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkMetaData;
2880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkPicture;
29363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenbergerclass SkRRect;
3080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkSurface_Base;
31910f694aefb0b671dd8522a9afe9b6be645701c1Derek Sollenbergerclass GrContext;
3280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
3380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru/** \class SkCanvas
3480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
3580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    A Canvas encapsulates all of the state about drawing into a device (bitmap).
3680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    This includes a reference to the device itself, and a stack of matrix/clip
3780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    values. For any given draw call (e.g. drawRect), the geometry of the object
3880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    being drawn is transformed by the concatenation of all the matrices in the
3980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    stack. The transformed geometry is clipped by the intersection of all of
4080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    the clips in the stack.
4180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
4280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    While the Canvas holds the state of the drawing device, the state (style)
4380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    of the object being drawn is held by the Paint, which is provided as a
4480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    parameter to each of the draw() methods. The Paint holds attributes such as
4580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    color, typeface, textSize, strokeWidth, shader (e.g. gradients, patterns),
4680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    etc.
4780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru*/
4880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SK_API SkCanvas : public SkRefCnt {
4980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querupublic:
5080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SK_DECLARE_INST_COUNT(SkCanvas)
5180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
5280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkCanvas();
5380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
5480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Construct a canvas with the specified device to draw into.
5580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
5680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param device   Specifies a device for the canvas to draw into.
5780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
580a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger    explicit SkCanvas(SkBaseDevice* device);
5980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
600a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger    /** Construct a canvas with the specified bitmap to draw into.
6180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param bitmap   Specifies a bitmap for the canvas to draw into. Its
6280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                        structure are copied to the canvas.
6380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
6480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    explicit SkCanvas(const SkBitmap& bitmap);
6580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual ~SkCanvas();
6680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
6780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkMetaData& getMetaData();
6880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
6980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    ///////////////////////////////////////////////////////////////////////////
7080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
7180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /**
7280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  Trigger the immediate execution of all pending draw operations.
7380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     */
7480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void flush();
7580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
7680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /**
7780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  Return the width/height of the underlying device. The current drawable
7880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  area may be small (due to clipping or saveLayer). For a canvas with
7980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  no device, 0,0 will be returned.
8080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     */
8180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkISize getDeviceSize() const;
8280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
8380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Return the canvas' device object, which may be null. The device holds
8480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        the bitmap of the pixels that the canvas draws into. The reference count
8580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        of the returned device is not changed by this call.
8680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
870a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger    SkBaseDevice* getDevice() const;
8880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
8980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /**
9080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  saveLayer() can create another device (which is later drawn onto
9180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  the previous device). getTopDevice() returns the top-most device current
9280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  installed. Note that this can change on other calls like save/restore,
9380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  so do not access this device after subsequent canvas calls.
9480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  The reference count of the device is not changed.
9580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *
9680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     * @param updateMatrixClip If this is true, then before the device is
9780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *        returned, we ensure that its has been notified about the current
9880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *        matrix and clip. Note: this happens automatically when the device
9980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *        is drawn to, but is optional here, as there is a small perf hit
10080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *        sometimes.
10180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     */
1020a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger    SkBaseDevice* getTopDevice(bool updateMatrixClip = false) const;
10380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
10480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /**
10580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  Shortcut for getDevice()->createCompatibleDevice(...).
10680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  If getDevice() == NULL, this method does nothing, and returns NULL.
10780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     */
1080a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger    SkBaseDevice* createCompatibleDevice(SkBitmap::Config config,
1090a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger                                         int width, int height,
1100a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger                                         bool isOpaque);
11180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
112910f694aefb0b671dd8522a9afe9b6be645701c1Derek Sollenberger    /**
113910f694aefb0b671dd8522a9afe9b6be645701c1Derek Sollenberger     * Return the GPU context of the device that is associated with the canvas.
114910f694aefb0b671dd8522a9afe9b6be645701c1Derek Sollenberger     * For a canvas with non-GPU device, NULL is returned.
115910f694aefb0b671dd8522a9afe9b6be645701c1Derek Sollenberger     */
116910f694aefb0b671dd8522a9afe9b6be645701c1Derek Sollenberger    GrContext* getGrContext();
117910f694aefb0b671dd8522a9afe9b6be645701c1Derek Sollenberger
11880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    ///////////////////////////////////////////////////////////////////////////
11980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
12080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /**
12180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     * This enum can be used with read/writePixels to perform a pixel ops to or
12280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     * from an 8888 config other than Skia's native config (SkPMColor). There
12380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     * are three byte orders supported: native, BGRA, and RGBA. Each has a
12480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     * premultiplied and unpremultiplied variant.
12580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *
12680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     * Components of a 8888 pixel can be packed/unpacked from a 32bit word using
12780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     * either byte offsets or shift values. Byte offsets are endian-invariant
12880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     * while shifts are not. BGRA and RGBA configs are defined by byte
12980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     * orderings. The native config is defined by shift values (SK_A32_SHIFT,
13080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     * ..., SK_B32_SHIFT).
13180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     */
13280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    enum Config8888 {
13380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        /**
13480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru         * Skia's native order specified by:
13580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru         *      SK_A32_SHIFT, SK_R32_SHIFT, SK_G32_SHIFT, and SK_B32_SHIFT
13680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru         *
13780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru         * kNative_Premul_Config8888 is equivalent to SkPMColor
13880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru         * kNative_Unpremul_Config8888 has the same component order as SkPMColor
13980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru         * but is not premultiplied.
14080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru         */
14180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kNative_Premul_Config8888,
14280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kNative_Unpremul_Config8888,
14380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        /**
14480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru         * low byte to high byte: B, G, R, A.
14580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru         */
14680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kBGRA_Premul_Config8888,
14780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kBGRA_Unpremul_Config8888,
14880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        /**
14980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru         * low byte to high byte: R, G, B, A.
15080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru         */
15180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kRGBA_Premul_Config8888,
15280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kRGBA_Unpremul_Config8888
15380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    };
15480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
15580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /**
15680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  On success (returns true), copy the canvas pixels into the bitmap.
15780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  On failure, the bitmap parameter is left unchanged and false is
15880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  returned.
15980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *
16080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  The canvas' pixels are converted to the bitmap's config. The only
16180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  supported config is kARGB_8888_Config, though this is likely to be
16280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  relaxed in  the future. The meaning of config kARGB_8888_Config is
16380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  modified by the enum param config8888. The default value interprets
16480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  kARGB_8888_Config as SkPMColor
16580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *
16680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  If the bitmap has pixels already allocated, the canvas pixels will be
16780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  written there. If not, bitmap->allocPixels() will be called
16880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  automatically. If the bitmap is backed by a texture readPixels will
16980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  fail.
17080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *
17180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  The actual pixels written is the intersection of the canvas' bounds, and
17280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  the rectangle formed by the bitmap's width,height and the specified x,y.
17380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  If bitmap pixels extend outside of that intersection, they will not be
17480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  modified.
17580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *
17680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  Other failure conditions:
17780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *    * If the canvas is backed by a non-raster device (e.g. PDF) then
17880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *       readPixels will fail.
17980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *    * If bitmap is texture-backed then readPixels will fail. (This may be
18080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *       relaxed in the future.)
18180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *
18280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  Example that reads the entire canvas into a bitmap using the native
18380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  SkPMColor:
18480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *    SkISize size = canvas->getDeviceSize();
18580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *    bitmap->setConfig(SkBitmap::kARGB_8888_Config, size.fWidth,
18680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *                                                   size.fHeight);
18780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *    if (canvas->readPixels(bitmap, 0, 0)) {
18880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *       // use the pixels
18980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *    }
19080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     */
19180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    bool readPixels(SkBitmap* bitmap,
19280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                    int x, int y,
19380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                    Config8888 config8888 = kNative_Premul_Config8888);
19480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
19580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /**
19680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     * DEPRECATED: This will be removed as soon as webkit is no longer relying
19780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     * on it. The bitmap is resized to the intersection of srcRect and the
19880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     * canvas bounds. New pixels are always allocated on success. Bitmap is
19980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     * unmodified on failure.
20080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     */
20180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    bool readPixels(const SkIRect& srcRect, SkBitmap* bitmap);
20280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
20380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /**
20480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  Similar to draw sprite, this method will copy the pixels in bitmap onto
20580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  the canvas, with the top/left corner specified by (x, y). The canvas'
20680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  pixel values are completely replaced: there is no blending.
20780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *
20880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  Currently if bitmap is backed by a texture this is a no-op. This may be
20980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  relaxed in the future.
21080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *
21180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  If the bitmap has config kARGB_8888_Config then the config8888 param
21280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  will determines how the pixel valuess are intepreted. If the bitmap is
21380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  not kARGB_8888_Config then this parameter is ignored.
21480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *
21580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  Note: If you are recording drawing commands on this canvas to
21680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  SkPicture, writePixels() is ignored!
21780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     */
21880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void writePixels(const SkBitmap& bitmap,
21980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                     int x, int y,
22080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                     Config8888 config8888 = kNative_Premul_Config8888);
22180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
22280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    ///////////////////////////////////////////////////////////////////////////
22380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
22480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    enum SaveFlags {
22580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        /** save the matrix state, restoring it on restore() */
22680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kMatrix_SaveFlag            = 0x01,
22780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        /** save the clip state, restoring it on restore() */
22880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kClip_SaveFlag              = 0x02,
22980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        /** the layer needs to support per-pixel alpha */
23080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kHasAlphaLayer_SaveFlag     = 0x04,
23180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        /** the layer needs to support 8-bits per color component */
23280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kFullColorLayer_SaveFlag    = 0x08,
23380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        /** the layer should clip against the bounds argument */
23480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kClipToLayer_SaveFlag       = 0x10,
23580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
23680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        // helper masks for common choices
23780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kMatrixClip_SaveFlag        = 0x03,
23880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kARGB_NoClipLayer_SaveFlag  = 0x0F,
23980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kARGB_ClipLayer_SaveFlag    = 0x1F
24080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    };
24180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
24280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** This call saves the current matrix, clip, and drawFilter, and pushes a
24380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        copy onto a private stack. Subsequent calls to translate, scale,
24480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        rotate, skew, concat or clipRect, clipPath, and setDrawFilter all
24580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        operate on this copy.
24680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        When the balancing call to restore() is made, the previous matrix, clip,
24780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        and drawFilter are restored.
2480a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger        @param flags The flags govern what portion of the Matrix/Clip/drawFilter
2490a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger                     state the save (and matching restore) effect. For example,
2500a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger                     if only kMatrix is specified, then only the matrix state
2510a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger                     will be pushed and popped. Likewise for the clip if kClip
2520a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger                     is specified.  However, the drawFilter is always affected
2530a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger                     by calls to save/restore.
25480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @return The value to pass to restoreToCount() to balance this save()
25580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
25680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual int save(SaveFlags flags = kMatrixClip_SaveFlag);
25780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
25880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** This behaves the same as save(), but in addition it allocates an
25980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        offscreen bitmap. All drawing calls are directed there, and only when
26080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        the balancing call to restore() is made is that offscreen transfered to
26180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        the canvas (or the previous layer).
26280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param bounds (may be null) This rect, if non-null, is used as a hint to
26380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                      limit the size of the offscreen, and thus drawing may be
26480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                      clipped to it, though that clipping is not guaranteed to
26580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                      happen. If exact clipping is desired, use clipRect().
26680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param paint (may be null) This is copied, and is applied to the
26780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                     offscreen when restore() is called
26880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param flags  LayerFlags
26980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @return The value to pass to restoreToCount() to balance this save()
27080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
27180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual int saveLayer(const SkRect* bounds, const SkPaint* paint,
27280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                          SaveFlags flags = kARGB_ClipLayer_SaveFlag);
27380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
27480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** This behaves the same as save(), but in addition it allocates an
27580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        offscreen bitmap. All drawing calls are directed there, and only when
27680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        the balancing call to restore() is made is that offscreen transfered to
27780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        the canvas (or the previous layer).
27880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param bounds (may be null) This rect, if non-null, is used as a hint to
27980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                      limit the size of the offscreen, and thus drawing may be
28080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                      clipped to it, though that clipping is not guaranteed to
28180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                      happen. If exact clipping is desired, use clipRect().
28280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param alpha  This is applied to the offscreen when restore() is called.
28380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param flags  LayerFlags
28480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @return The value to pass to restoreToCount() to balance this save()
28580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
28680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    int saveLayerAlpha(const SkRect* bounds, U8CPU alpha,
28780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                       SaveFlags flags = kARGB_ClipLayer_SaveFlag);
28880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
28980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** This call balances a previous call to save(), and is used to remove all
29080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        modifications to the matrix/clip/drawFilter state since the last save
29180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        call.
29280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        It is an error to call restore() more times than save() was called.
29380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
29480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual void restore();
29580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
29680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Returns the number of matrix/clip states on the SkCanvas' private stack.
29780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        This will equal # save() calls - # restore() calls.
29880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
29980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    int getSaveCount() const;
30080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
30180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Efficient way to pop any calls to save() that happened after the save
30280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        count reached saveCount. It is an error for saveCount to be less than
30380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        getSaveCount()
30480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param saveCount    The number of save() levels to restore from
30580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
30680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void restoreToCount(int saveCount);
30780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
30880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Returns true if drawing is currently going to a layer (from saveLayer)
30980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  rather than to the root device.
31080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     */
31180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual bool isDrawingToLayer() const;
31280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
31380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Preconcat the current matrix with the specified translation
31480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param dx   The distance to translate in X
31580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param dy   The distance to translate in Y
31680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        returns true if the operation succeeded (e.g. did not overflow)
31780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
31880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual bool translate(SkScalar dx, SkScalar dy);
31980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
32080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Preconcat the current matrix with the specified scale.
32180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param sx   The amount to scale in X
32280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param sy   The amount to scale in Y
32380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        returns true if the operation succeeded (e.g. did not overflow)
32480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
32580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual bool scale(SkScalar sx, SkScalar sy);
32680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
32780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Preconcat the current matrix with the specified rotation.
32880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param degrees  The amount to rotate, in degrees
32980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        returns true if the operation succeeded (e.g. did not overflow)
33080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
33180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual bool rotate(SkScalar degrees);
33280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
33380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Preconcat the current matrix with the specified skew.
33480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param sx   The amount to skew in X
33580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param sy   The amount to skew in Y
33680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        returns true if the operation succeeded (e.g. did not overflow)
33780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
33880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual bool skew(SkScalar sx, SkScalar sy);
33980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
34080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Preconcat the current matrix with the specified matrix.
34180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param matrix   The matrix to preconcatenate with the current matrix
34280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @return true if the operation succeeded (e.g. did not overflow)
34380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
34480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual bool concat(const SkMatrix& matrix);
34580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
34680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Replace the current matrix with a copy of the specified matrix.
34780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param matrix The matrix that will be copied into the current matrix.
34880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
34980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual void setMatrix(const SkMatrix& matrix);
35080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
35180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Helper for setMatrix(identity). Sets the current matrix to identity.
35280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
35380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void resetMatrix();
35480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
355363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger    /**
356363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger     *  Modify the current clip with the specified rectangle.
357363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger     *  @param rect The rect to combine with the current clip
358363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger     *  @param op The region op to apply to the current clip
359363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger     *  @param doAntiAlias true if the clip should be antialiased
360363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger     *  @return true if the canvas' clip is non-empty
361363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger     */
36280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual bool clipRect(const SkRect& rect,
36380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                          SkRegion::Op op = SkRegion::kIntersect_Op,
36480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                          bool doAntiAlias = false);
36580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
366363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger    /**
367363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger     *  Modify the current clip with the specified SkRRect.
368363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger     *  @param rrect The rrect to combine with the current clip
369363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger     *  @param op The region op to apply to the current clip
370363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger     *  @param doAntiAlias true if the clip should be antialiased
371363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger     *  @return true if the canvas' clip is non-empty
372363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger     */
373363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger    virtual bool clipRRect(const SkRRect& rrect,
374363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger                           SkRegion::Op op = SkRegion::kIntersect_Op,
375363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger                           bool doAntiAlias = false);
376363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger
377363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger    /**
378363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger     *  Modify the current clip with the specified path.
379363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger     *  @param path The path to combine with the current clip
380363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger     *  @param op The region op to apply to the current clip
381363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger     *  @param doAntiAlias true if the clip should be antialiased
382363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger     *  @return true if the canvas' new clip is non-empty
383363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger     */
38480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual bool clipPath(const SkPath& path,
38580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                          SkRegion::Op op = SkRegion::kIntersect_Op,
38680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                          bool doAntiAlias = false);
38780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
388363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger    /** EXPERIMENTAL -- only used for testing
389363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger        Set to false to force clips to be hard, even if doAntiAlias=true is
390363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger        passed to clipRect or clipPath.
391363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger     */
392363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger    void setAllowSoftClip(bool allow) {
393363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger        fAllowSoftClip = allow;
394363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger    }
395363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger
3967839ce1af63bf12fe7b3caa866970bbbb3afb13dDerek Sollenberger    /** EXPERIMENTAL -- only used for testing
3977839ce1af63bf12fe7b3caa866970bbbb3afb13dDerek Sollenberger        Set to simplify clip stack using path ops.
3987839ce1af63bf12fe7b3caa866970bbbb3afb13dDerek Sollenberger     */
3997839ce1af63bf12fe7b3caa866970bbbb3afb13dDerek Sollenberger    void setAllowSimplifyClip(bool allow) {
4007839ce1af63bf12fe7b3caa866970bbbb3afb13dDerek Sollenberger        fAllowSimplifyClip = allow;
4017839ce1af63bf12fe7b3caa866970bbbb3afb13dDerek Sollenberger    }
4027839ce1af63bf12fe7b3caa866970bbbb3afb13dDerek Sollenberger
40380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Modify the current clip with the specified region. Note that unlike
40480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        clipRect() and clipPath() which transform their arguments by the current
40580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        matrix, clipRegion() assumes its argument is already in device
40680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        coordinates, and so no transformation is performed.
40780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param deviceRgn    The region to apply to the current clip
40880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param op The region op to apply to the current clip
40980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @return true if the canvas' new clip is non-empty
41080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
41180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual bool clipRegion(const SkRegion& deviceRgn,
41280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                            SkRegion::Op op = SkRegion::kIntersect_Op);
41380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
41480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Helper for clipRegion(rgn, kReplace_Op). Sets the current clip to the
41580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        specified region. This does not intersect or in any other way account
41680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        for the existing clip region.
41780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param deviceRgn The region to copy into the current clip.
41880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @return true if the new clip region is non-empty
41980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
42080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    bool setClipRegion(const SkRegion& deviceRgn) {
42180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        return this->clipRegion(deviceRgn, SkRegion::kReplace_Op);
42280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
42380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
42480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Return true if the specified rectangle, after being transformed by the
42580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        current matrix, would lie completely outside of the current clip. Call
42680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        this to check if an area you intend to draw into is clipped out (and
42780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        therefore you can skip making the draw calls).
42880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param rect the rect to compare with the current clip
42980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @return true if the rect (transformed by the canvas' matrix) does not
43080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                     intersect with the canvas' clip
43180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
43280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    bool quickReject(const SkRect& rect) const;
43380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
43480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Return true if the specified path, after being transformed by the
43580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        current matrix, would lie completely outside of the current clip. Call
43680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        this to check if an area you intend to draw into is clipped out (and
43780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        therefore you can skip making the draw calls). Note, for speed it may
43880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        return false even if the path itself might not intersect the clip
43980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        (i.e. the bounds of the path intersects, but the path does not).
44080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param path The path to compare with the current clip
44180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @return true if the path (transformed by the canvas' matrix) does not
44280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                     intersect with the canvas' clip
44380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
44480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    bool quickReject(const SkPath& path) const;
44580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
44680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Return true if the horizontal band specified by top and bottom is
44780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        completely clipped out. This is a conservative calculation, meaning
44880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        that it is possible that if the method returns false, the band may still
44980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        in fact be clipped out, but the converse is not true. If this method
45080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        returns true, then the band is guaranteed to be clipped out.
45180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param top  The top of the horizontal band to compare with the clip
45280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param bottom The bottom of the horizontal and to compare with the clip
45380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @return true if the horizontal band is completely clipped out (i.e. does
45480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                     not intersect the current clip)
45580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
45680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    bool quickRejectY(SkScalar top, SkScalar bottom) const {
457910f694aefb0b671dd8522a9afe9b6be645701c1Derek Sollenberger        SkASSERT(top <= bottom);
458910f694aefb0b671dd8522a9afe9b6be645701c1Derek Sollenberger        const SkRect& clipR = this->getLocalClipBounds();
45980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        // In the case where the clip is empty and we are provided with a
46080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        // negative top and positive bottom parameter then this test will return
46180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        // false even though it will be clipped. We have chosen to exclude that
46280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        // check as it is rare and would result double the comparisons.
463910f694aefb0b671dd8522a9afe9b6be645701c1Derek Sollenberger        return top >= clipR.fBottom || bottom <= clipR.fTop;
46480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
46580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
46680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Return the bounds of the current clip (in local coordinates) in the
46780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        bounds parameter, and return true if it is non-empty. This can be useful
46880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        in a way similar to quickReject, in that it tells you that drawing
46980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        outside of these bounds will be clipped out.
47080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
47180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    bool getClipBounds(SkRect* bounds) const;
47280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
47380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Return the bounds of the current clip, in device coordinates; returns
47480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        true if non-empty. Maybe faster than getting the clip explicitly and
47580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        then taking its bounds.
47680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
47780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    bool getClipDeviceBounds(SkIRect* bounds) const;
47880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
47980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
48080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Fill the entire canvas' bitmap (restricted to the current clip) with the
48180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        specified ARGB color, using the specified mode.
48280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param a    the alpha component (0..255) of the color to fill the canvas
48380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param r    the red component (0..255) of the color to fill the canvas
48480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param g    the green component (0..255) of the color to fill the canvas
48580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param b    the blue component (0..255) of the color to fill the canvas
48680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param mode the mode to apply the color in (defaults to SrcOver)
48780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
48880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void drawARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b,
48980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                  SkXfermode::Mode mode = SkXfermode::kSrcOver_Mode);
49080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
49180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Fill the entire canvas' bitmap (restricted to the current clip) with the
49280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        specified color and mode.
49380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param color    the color to draw with
49480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param mode the mode to apply the color in (defaults to SrcOver)
49580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
49680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void drawColor(SkColor color,
49780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                   SkXfermode::Mode mode = SkXfermode::kSrcOver_Mode);
49880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
49980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /**
50080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  This erases the entire drawing surface to the specified color,
50180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  irrespective of the clip. It does not blend with the previous pixels,
50280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  but always overwrites them.
50380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *
50480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  It is roughly equivalent to the following:
50580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *      canvas.save();
50680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *      canvas.clipRect(hugeRect, kReplace_Op);
50780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *      paint.setColor(color);
50880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *      paint.setXfermodeMode(kSrc_Mode);
50980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *      canvas.drawPaint(paint);
51080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *      canvas.restore();
51180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  though it is almost always much more efficient.
51280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     */
51380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual void clear(SkColor);
51480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
51580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /**
51680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  Fill the entire canvas' bitmap (restricted to the current clip) with the
51780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  specified paint.
51880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  @param paint    The paint used to fill the canvas
51980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     */
52080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual void drawPaint(const SkPaint& paint);
52180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
52280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    enum PointMode {
52380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        /** drawPoints draws each point separately */
52480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kPoints_PointMode,
52580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        /** drawPoints draws each pair of points as a line segment */
52680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kLines_PointMode,
52780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        /** drawPoints draws the array of points as a polygon */
52880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kPolygon_PointMode
52980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    };
53080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
53180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Draw a series of points, interpreted based on the PointMode mode. For
53280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        all modes, the count parameter is interpreted as the total number of
53380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        points. For kLine mode, count/2 line segments are drawn.
53480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        For kPoint mode, each point is drawn centered at its coordinate, and its
53580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        size is specified by the paint's stroke-width. It draws as a square,
53680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        unless the paint's cap-type is round, in which the points are drawn as
53780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        circles.
53880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        For kLine mode, each pair of points is drawn as a line segment,
53980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        respecting the paint's settings for cap/join/width.
54080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        For kPolygon mode, the entire array is drawn as a series of connected
54180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        line segments.
54280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        Note that, while similar, kLine and kPolygon modes draw slightly
54380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        differently than the equivalent path built with a series of moveto,
54480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        lineto calls, in that the path will draw all of its contours at once,
54580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        with no interactions if contours intersect each other (think XOR
54680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        xfermode). drawPoints always draws each element one at a time.
54780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param mode     PointMode specifying how to draw the array of points.
54880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param count    The number of points in the array
54980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param pts      Array of points to draw
55080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param paint    The paint used to draw the points
55180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
55280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual void drawPoints(PointMode mode, size_t count, const SkPoint pts[],
55380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                            const SkPaint& paint);
55480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
55580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Helper method for drawing a single point. See drawPoints() for a more
55680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        details.
55780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
55880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void drawPoint(SkScalar x, SkScalar y, const SkPaint& paint);
55980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
56080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Draws a single pixel in the specified color.
56180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param x        The X coordinate of which pixel to draw
56280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param y        The Y coordiante of which pixel to draw
56380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param color    The color to draw
56480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
56580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void drawPoint(SkScalar x, SkScalar y, SkColor color);
56680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
56780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Draw a line segment with the specified start and stop x,y coordinates,
56880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        using the specified paint. NOTE: since a line is always "framed", the
56980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        paint's Style is ignored.
57080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param x0    The x-coordinate of the start point of the line
57180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param y0    The y-coordinate of the start point of the line
57280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param x1    The x-coordinate of the end point of the line
57380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param y1    The y-coordinate of the end point of the line
57480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param paint The paint used to draw the line
57580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
57680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void drawLine(SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1,
57780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                  const SkPaint& paint);
57880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
57980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Draw the specified rectangle using the specified paint. The rectangle
58080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        will be filled or stroked based on the Style in the paint.
58180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param rect     The rect to be drawn
58280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param paint    The paint used to draw the rect
58380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
58480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual void drawRect(const SkRect& rect, const SkPaint& paint);
58580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
58680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Draw the specified rectangle using the specified paint. The rectangle
58780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        will be filled or framed based on the Style in the paint.
58880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param rect     The rect to be drawn
58980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param paint    The paint used to draw the rect
59080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
59180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void drawIRect(const SkIRect& rect, const SkPaint& paint)
59280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    {
59380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        SkRect r;
59480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        r.set(rect);    // promotes the ints to scalars
59580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        this->drawRect(r, paint);
59680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
59780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
59880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Draw the specified rectangle using the specified paint. The rectangle
59980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        will be filled or framed based on the Style in the paint.
60080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param left     The left side of the rectangle to be drawn
60180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param top      The top side of the rectangle to be drawn
60280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param right    The right side of the rectangle to be drawn
60380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param bottom   The bottom side of the rectangle to be drawn
60480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param paint    The paint used to draw the rect
60580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
60680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void drawRectCoords(SkScalar left, SkScalar top, SkScalar right,
60780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                        SkScalar bottom, const SkPaint& paint);
60880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
60980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Draw the specified oval using the specified paint. The oval will be
61080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        filled or framed based on the Style in the paint.
61180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param oval     The rectangle bounds of the oval to be drawn
61280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param paint    The paint used to draw the oval
61380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
614363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger    virtual void drawOval(const SkRect& oval, const SkPaint&);
615363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger
616363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger    /**
617363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger     *  Draw the specified RRect using the specified paint The rrect will be filled or stroked
618363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger     *  based on the Style in the paint.
619363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger     *
620363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger     *  @param rrect    The round-rect to draw
621363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger     *  @param paint    The paint used to draw the round-rect
622363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger     */
623363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger    virtual void drawRRect(const SkRRect& rrect, const SkPaint& paint);
62480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
62580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Draw the specified circle using the specified paint. If radius is <= 0,
62680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        then nothing will be drawn. The circle will be filled
62780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        or framed based on the Style in the paint.
62880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param cx       The x-coordinate of the center of the cirle to be drawn
62980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param cy       The y-coordinate of the center of the cirle to be drawn
63080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param radius   The radius of the cirle to be drawn
63180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param paint    The paint used to draw the circle
63280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
63380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void drawCircle(SkScalar cx, SkScalar cy, SkScalar radius,
63480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                    const SkPaint& paint);
63580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
63680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Draw the specified arc, which will be scaled to fit inside the
63780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        specified oval. If the sweep angle is >= 360, then the oval is drawn
63880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        completely. Note that this differs slightly from SkPath::arcTo, which
63980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        treats the sweep angle mod 360.
64080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param oval The bounds of oval used to define the shape of the arc
64180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param startAngle Starting angle (in degrees) where the arc begins
64280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param sweepAngle Sweep angle (in degrees) measured clockwise
64380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param useCenter true means include the center of the oval. For filling
64480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                         this will draw a wedge. False means just use the arc.
64580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param paint    The paint used to draw the arc
64680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
64780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void drawArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle,
64880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                 bool useCenter, const SkPaint& paint);
64980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
65080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Draw the specified round-rect using the specified paint. The round-rect
65180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        will be filled or framed based on the Style in the paint.
65280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param rect     The rectangular bounds of the roundRect to be drawn
65380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param rx       The x-radius of the oval used to round the corners
65480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param ry       The y-radius of the oval used to round the corners
65580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param paint    The paint used to draw the roundRect
65680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
65780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void drawRoundRect(const SkRect& rect, SkScalar rx, SkScalar ry,
65880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                       const SkPaint& paint);
65980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
66080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Draw the specified path using the specified paint. The path will be
66180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        filled or framed based on the Style in the paint.
66280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param path     The path to be drawn
66380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param paint    The paint used to draw the path
66480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
66580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual void drawPath(const SkPath& path, const SkPaint& paint);
66680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
66780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Draw the specified bitmap, with its top/left corner at (x,y), using the
66880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        specified paint, transformed by the current matrix. Note: if the paint
66980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        contains a maskfilter that generates a mask which extends beyond the
67080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        bitmap's original width/height, then the bitmap will be drawn as if it
67180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        were in a Shader with CLAMP mode. Thus the color outside of the original
67280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        width/height will be the edge color replicated.
673910f694aefb0b671dd8522a9afe9b6be645701c1Derek Sollenberger
674910f694aefb0b671dd8522a9afe9b6be645701c1Derek Sollenberger        If a shader is present on the paint it will be ignored, except in the
675910f694aefb0b671dd8522a9afe9b6be645701c1Derek Sollenberger        case where the bitmap is kA8_Config. In that case, the color is
676910f694aefb0b671dd8522a9afe9b6be645701c1Derek Sollenberger        generated by the shader.
677910f694aefb0b671dd8522a9afe9b6be645701c1Derek Sollenberger
67880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param bitmap   The bitmap to be drawn
67980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param left     The position of the left side of the bitmap being drawn
68080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param top      The position of the top side of the bitmap being drawn
68180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param paint    The paint used to draw the bitmap, or NULL
68280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
68380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
68480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                            const SkPaint* paint = NULL);
68580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
6860a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger    enum DrawBitmapRectFlags {
6870a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger        kNone_DrawBitmapRectFlag            = 0x0,
6880a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger        /**
6890a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger         *  When filtering is enabled, allow the color samples outside of
6900a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger         *  the src rect (but still in the src bitmap) to bleed into the
6910a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger         *  drawn portion
6920a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger         */
6930a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger        kBleed_DrawBitmapRectFlag           = 0x1,
6940a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger    };
6950a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger
69680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Draw the specified bitmap, with the specified matrix applied (before the
69780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        canvas' matrix is applied).
69880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param bitmap   The bitmap to be drawn
69980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param src      Optional: specify the subset of the bitmap to be drawn
70080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param dst      The destination rectangle where the scaled/translated
70180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                        image will be drawn
70280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param paint    The paint used to draw the bitmap, or NULL
70380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
70480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual void drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
70580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                                      const SkRect& dst,
7060a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger                                      const SkPaint* paint = NULL,
7070a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger                                      DrawBitmapRectFlags flags = kNone_DrawBitmapRectFlag);
70880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
70980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void drawBitmapRect(const SkBitmap& bitmap, const SkRect& dst,
7100a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger                        const SkPaint* paint = NULL) {
7110a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger        this->drawBitmapRectToRect(bitmap, NULL, dst, paint, kNone_DrawBitmapRectFlag);
71280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
71380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
71480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void drawBitmapRect(const SkBitmap& bitmap, const SkIRect* isrc,
7150a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger                        const SkRect& dst, const SkPaint* paint = NULL,
7160a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger                        DrawBitmapRectFlags flags = kNone_DrawBitmapRectFlag) {
71780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        SkRect realSrcStorage;
71880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        SkRect* realSrcPtr = NULL;
71980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        if (isrc) {
72080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            realSrcStorage.set(*isrc);
72180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            realSrcPtr = &realSrcStorage;
72280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        }
7230a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger        this->drawBitmapRectToRect(bitmap, realSrcPtr, dst, paint, flags);
72480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
72580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
72680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m,
72780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                                  const SkPaint* paint = NULL);
72880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
72980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /**
73080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  Draw the bitmap stretched differentially to fit into dst.
73180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  center is a rect within the bitmap, and logically divides the bitmap
73280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  into 9 sections (3x3). For example, if the middle pixel of a [5x5]
73380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  bitmap is the "center", then the center-rect should be [2, 2, 3, 3].
73480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *
73580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  If the dst is >= the bitmap size, then...
73658190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger     *  - The 4 corners are not stretched at all.
73758190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger     *  - The sides are stretched in only one axis.
73858190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger     *  - The center is stretched in both axes.
73980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     * Else, for each axis where dst < bitmap,
74080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  - The corners shrink proportionally
74180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  - The sides (along the shrink axis) and center are not drawn
74280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     */
74380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
74480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                                const SkRect& dst, const SkPaint* paint = NULL);
74580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
74680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Draw the specified bitmap, with its top/left corner at (x,y),
74780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        NOT transformed by the current matrix. Note: if the paint
74880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        contains a maskfilter that generates a mask which extends beyond the
74980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        bitmap's original width/height, then the bitmap will be drawn as if it
75080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        were in a Shader with CLAMP mode. Thus the color outside of the original
75180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        width/height will be the edge color replicated.
75280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param bitmap   The bitmap to be drawn
75380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param left     The position of the left side of the bitmap being drawn
75480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param top      The position of the top side of the bitmap being drawn
75580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param paint    The paint used to draw the bitmap, or NULL
75680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
75780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual void drawSprite(const SkBitmap& bitmap, int left, int top,
75880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                            const SkPaint* paint = NULL);
75980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
76080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Draw the text, with origin at (x,y), using the specified paint.
76180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        The origin is interpreted based on the Align setting in the paint.
76280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param text The text to be drawn
76380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param byteLength   The number of bytes to read from the text parameter
76480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param x        The x-coordinate of the origin of the text being drawn
76580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param y        The y-coordinate of the origin of the text being drawn
76680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param paint    The paint used for the text (e.g. color, size, style)
76780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
76880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual void drawText(const void* text, size_t byteLength, SkScalar x,
76980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                          SkScalar y, const SkPaint& paint);
77080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
77180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Draw the text, with each character/glyph origin specified by the pos[]
77280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        array. The origin is interpreted by the Align setting in the paint.
77380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param text The text to be drawn
77480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param byteLength   The number of bytes to read from the text parameter
77580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param pos      Array of positions, used to position each character
77680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param paint    The paint used for the text (e.g. color, size, style)
77780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        */
77880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual void drawPosText(const void* text, size_t byteLength,
77980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                             const SkPoint pos[], const SkPaint& paint);
78080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
78180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Draw the text, with each character/glyph origin specified by the x
78280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        coordinate taken from the xpos[] array, and the y from the constY param.
78380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        The origin is interpreted by the Align setting in the paint.
78480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param text The text to be drawn
78580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param byteLength   The number of bytes to read from the text parameter
78680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param xpos     Array of x-positions, used to position each character
78780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param constY   The shared Y coordinate for all of the positions
78880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param paint    The paint used for the text (e.g. color, size, style)
78980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        */
79080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual void drawPosTextH(const void* text, size_t byteLength,
79180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                              const SkScalar xpos[], SkScalar constY,
79280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                              const SkPaint& paint);
79380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
79480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Draw the text, with origin at (x,y), using the specified paint, along
79580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        the specified path. The paint's Align setting determins where along the
79680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        path to start the text.
79780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param text The text to be drawn
79880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param byteLength   The number of bytes to read from the text parameter
79980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param path         The path the text should follow for its baseline
80080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param hOffset      The distance along the path to add to the text's
80180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                            starting position
80280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param vOffset      The distance above(-) or below(+) the path to
80380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                            position the text
80480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param paint        The paint used for the text
80580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
80680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void drawTextOnPathHV(const void* text, size_t byteLength,
80780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                          const SkPath& path, SkScalar hOffset,
80880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                          SkScalar vOffset, const SkPaint& paint);
80980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
81080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Draw the text, with origin at (x,y), using the specified paint, along
81180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        the specified path. The paint's Align setting determins where along the
81280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        path to start the text.
81380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param text The text to be drawn
81480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param byteLength   The number of bytes to read from the text parameter
81580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param path         The path the text should follow for its baseline
81680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param matrix       (may be null) Applied to the text before it is
81780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                            mapped onto the path
81880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param paint        The paint used for the text
81980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        */
82080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual void drawTextOnPath(const void* text, size_t byteLength,
82180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                                const SkPath& path, const SkMatrix* matrix,
82280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                                const SkPaint& paint);
82380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
82480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Draw the picture into this canvas. This method effective brackets the
82580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        playback of the picture's draw calls with save/restore, so the state
826d686ac77c2c485c4a3302eda9c1de597a6f8c568Derek Sollenberger        of this canvas will be unchanged after this call.
82780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param picture The recorded drawing commands to playback into this
82880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                       canvas.
82980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
83080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual void drawPicture(SkPicture& picture);
83180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
83280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    enum VertexMode {
83380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kTriangles_VertexMode,
83480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kTriangleStrip_VertexMode,
83580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kTriangleFan_VertexMode
83680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    };
83780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
83880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Draw the array of vertices, interpreted as triangles (based on mode).
83980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param vmode How to interpret the array of vertices
84080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param vertexCount The number of points in the vertices array (and
84180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                    corresponding texs and colors arrays if non-null)
84280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param vertices Array of vertices for the mesh
84380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param texs May be null. If not null, specifies the coordinate
844e27eefc4844477cee5d32f51ab45ff62020cdb36Derek Sollenberger                    in _texture_ space (not uv space) for each vertex.
84580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param colors May be null. If not null, specifies a color for each
84680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                      vertex, to be interpolated across the triangle.
84780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param xmode Used if both texs and colors are present. In this
84880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                    case the colors are combined with the texture using mode,
84980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                    before being drawn using the paint. If mode is null, then
850d686ac77c2c485c4a3302eda9c1de597a6f8c568Derek Sollenberger                    kModulate_Mode is used.
85180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param indices If not null, array of indices to reference into the
85280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                    vertex (texs, colors) array.
85380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param indexCount number of entries in the indices array (if not null)
85480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param paint Specifies the shader/texture if present.
85580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
85680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual void drawVertices(VertexMode vmode, int vertexCount,
85780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                              const SkPoint vertices[], const SkPoint texs[],
85880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                              const SkColor colors[], SkXfermode* xmode,
85980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                              const uint16_t indices[], int indexCount,
86080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                              const SkPaint& paint);
86180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
86280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Send a blob of data to the canvas.
86380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        For canvases that draw, this call is effectively a no-op, as the data
86480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        is not parsed, but just ignored. However, this call exists for
86580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        subclasses like SkPicture's recording canvas, that can store the data
86680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        and then play it back later (via another call to drawData).
86780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     */
86858190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    virtual void drawData(const void* data, size_t length) {
86958190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger        // do nothing. Subclasses may do something with the data
87058190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    }
87158190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger
87258190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    /** Add comments. beginCommentGroup/endCommentGroup open/close a new group.
87358190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger        Each comment added via addComment is notionally attached to its
87458190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger        enclosing group. Top-level comments simply belong to no group.
87558190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger     */
87658190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    virtual void beginCommentGroup(const char* description) {
87758190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger        // do nothing. Subclasses may do something
87858190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    }
87958190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    virtual void addComment(const char* kywd, const char* value) {
88058190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger        // do nothing. Subclasses may do something
88158190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    }
88258190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    virtual void endCommentGroup() {
88358190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger        // do nothing. Subclasses may do something
88458190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    }
88558190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger
88680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
88780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    //////////////////////////////////////////////////////////////////////////
88880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
88980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Get the current bounder object.
89080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        The bounder's reference count is unchaged.
89180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @return the canva's bounder (or NULL).
89280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
89380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkBounder*  getBounder() const { return fBounder; }
89480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
89580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Set a new bounder (or NULL).
89680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        Pass NULL to clear any previous bounder.
89780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        As a convenience, the parameter passed is also returned.
89880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        If a previous bounder exists, its reference count is decremented.
89980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        If bounder is not NULL, its reference count is incremented.
90080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param bounder the new bounder (or NULL) to be installed in the canvas
90180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @return the set bounder object
90280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
90380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual SkBounder* setBounder(SkBounder* bounder);
90480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
90580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Get the current filter object. The filter's reference count is not
90680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        affected. The filter is saved/restored, just like the matrix and clip.
90780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @return the canvas' filter (or NULL).
90880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
90980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkDrawFilter* getDrawFilter() const;
91080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
91180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Set the new filter (or NULL). Pass NULL to clear any existing filter.
91280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        As a convenience, the parameter is returned. If an existing filter
91380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        exists, its refcnt is decrement. If the new filter is not null, its
91480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        refcnt is incremented. The filter is saved/restored, just like the
91580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        matrix and clip.
91680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param filter the new filter (or NULL)
91780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @return the new filter
91880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
91980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual SkDrawFilter* setDrawFilter(SkDrawFilter* filter);
92080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
92180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    //////////////////////////////////////////////////////////////////////////
92280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
92380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Return the current matrix on the canvas.
92480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        This does not account for the translate in any of the devices.
92580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @return The current matrix on the canvas.
92680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
92780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    const SkMatrix& getTotalMatrix() const;
92880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
92980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    enum ClipType {
93080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kEmpty_ClipType = 0,
93180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kRect_ClipType,
93280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kComplex_ClipType
93380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    };
93480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
93580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Returns a description of the total clip; may be cheaper than
93680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        getting the clip and querying it directly.
93780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
93880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    ClipType getClipType() const;
93980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
9400a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger    /** DEPRECATED -- need to move this guy to private/friend
9410a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger     *  Return the current device clip (concatenation of all clip calls).
94280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  This does not account for the translate in any of the devices.
94380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  @return the current device clip (concatenation of all clip calls).
94480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     */
94580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    const SkRegion& getTotalClip() const;
94680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
94780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Return the clip stack. The clip stack stores all the individual
94880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  clips organized by the save/restore frame in which they were
94980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  added.
95080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  @return the current clip stack ("list" of individual clip elements)
95180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     */
95280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    const SkClipStack* getClipStack() const {
95380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        return &fClipStack;
95480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
95580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
95680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    class ClipVisitor {
95780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    public:
95880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        virtual ~ClipVisitor();
95980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0;
96080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0;
96180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    };
96280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
96380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /**
96480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  Replays the clip operations, back to front, that have been applied to
96580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  the canvas, calling the appropriate method on the visitor for each
96680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  clip. All clips have already been transformed into device space.
96780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     */
96880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void replayClips(ClipVisitor*) const;
96980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
97080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    ///////////////////////////////////////////////////////////////////////////
97180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
97280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** After calling saveLayer(), there can be any number of devices that make
97380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        up the top-most drawing area. LayerIter can be used to iterate through
97480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        those devices. Note that the iterator is only valid until the next API
97580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        call made on the canvas. Ownership of all pointers in the iterator stays
97680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        with the canvas, so none of them should be modified or deleted.
97780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
97880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    class SK_API LayerIter /*: SkNoncopyable*/ {
97980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    public:
98080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        /** Initialize iterator with canvas, and set values for 1st device */
98180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        LayerIter(SkCanvas*, bool skipEmptyClips);
98280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        ~LayerIter();
98380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
98480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        /** Return true if the iterator is done */
98580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        bool done() const { return fDone; }
98680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        /** Cycle to the next device */
98780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        void next();
98880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
98980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        // These reflect the current device in the iterator
99080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
9910a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger        SkBaseDevice*   device() const;
99280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        const SkMatrix& matrix() const;
99380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        const SkRegion& clip() const;
99480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        const SkPaint&  paint() const;
99580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        int             x() const;
99680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        int             y() const;
99780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
99880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    private:
99980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        // used to embed the SkDrawIter object directly in our instance, w/o
100080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        // having to expose that class def to the public. There is an assert
100180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        // in our constructor to ensure that fStorage is large enough
100280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        // (though needs to be a compile-time-assert!). We use intptr_t to work
100380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        // safely with 32 and 64 bit machines (to ensure the storage is enough)
100480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        intptr_t          fStorage[32];
100580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        class SkDrawIter* fImpl;    // this points at fStorage
100680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        SkPaint           fDefaultPaint;
100780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        bool              fDone;
100880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    };
100980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
101080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruprotected:
101180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    // Returns the canvas to be used by DrawIter. Default implementation
101280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    // returns this. Subclasses that encapsulate an indirect canvas may
101380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    // need to overload this method. The impl must keep track of this, as it
101480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    // is not released or deleted by the caller.
101580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual SkCanvas* canvasForDrawIter();
101680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
101780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    // Clip rectangle bounds. Called internally by saveLayer.
101880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    // returns false if the entire rectangle is entirely clipped out
101980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    bool clipRectBounds(const SkRect* bounds, SaveFlags flags,
102080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                        SkIRect* intersection);
102180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
102258190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    // Called by child classes that override clipPath and clipRRect to only
102358190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    // track fast conservative clip bounds, rather than exact clips.
102458190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    bool updateClipConservativelyUsingBounds(const SkRect&, SkRegion::Op,
102558190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger                                             bool inverseFilled);
102658190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger
102780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    // notify our surface (if we have one) that we are about to draw, so it
102880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    // can perform copy-on-write or invalidate any cached images
102980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void predrawNotify();
103080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
10310a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger    /**
10320a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger     DEPRECATED -- need to remove when subclass stop relying on it.
1033363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger     Marked as 'protected' to avoid new clients using this before we can
1034363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger     completely remove it.
1035363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger
1036363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger     Specify a device for this canvas to draw into. If it is not null, its
1037363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger     reference count is incremented. If the canvas was already holding a
1038363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger     device, its reference count is decremented. The new device is returned.
1039363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger     */
10400a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger    virtual SkBaseDevice* setDevice(SkBaseDevice* device);
1041363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger
104280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruprivate:
104380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    class MCRec;
104480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
104580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkClipStack fClipStack;
104680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkDeque     fMCStack;
104780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    // points to top of stack
104880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    MCRec*      fMCRec;
104980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    // the first N recs that can fit here mean we won't call malloc
105080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    uint32_t    fMCRecStorage[32];
105180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
105280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkBounder*  fBounder;
105380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    int         fSaveLayerCount;    // number of successful saveLayer calls
105480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
105580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkMetaData* fMetaData;
105680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
105780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkSurface_Base*  fSurfaceBase;
105880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkSurface_Base* getSurfaceBase() const { return fSurfaceBase; }
105980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void setSurfaceBase(SkSurface_Base* sb) {
106080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        fSurfaceBase = sb;
106180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
106280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    friend class SkSurface_Base;
10637839ce1af63bf12fe7b3caa866970bbbb3afb13dDerek Sollenberger    friend class SkSurface_Gpu;
106480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
106580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    bool fDeviceCMDirty;            // cleared by updateDeviceCMCache()
106680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void updateDeviceCMCache();
106780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
106880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    friend class SkDrawIter;    // needs setupDrawForLayerDevice()
106980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    friend class AutoDrawLooper;
107080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
10710a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger    SkBaseDevice* createLayerDevice(SkBitmap::Config, int width, int height,
10720a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger                                    bool isOpaque);
107380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
10740a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger    SkBaseDevice* init(SkBaseDevice*);
107580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
107680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    // internal methods are not virtual, so they can safely be called by other
107780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    // canvas apis, without confusing subclasses (like SkPictureRecording)
107858190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    void internalDrawBitmap(const SkBitmap&, const SkMatrix& m, const SkPaint* paint);
107980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void internalDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src,
10800a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger                                const SkRect& dst, const SkPaint* paint,
10810a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger                                DrawBitmapRectFlags flags);
108280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void internalDrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
108380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                                const SkRect& dst, const SkPaint* paint);
108480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void internalDrawPaint(const SkPaint& paint);
108580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    int internalSaveLayer(const SkRect* bounds, const SkPaint* paint,
108680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                          SaveFlags, bool justForImageFilter);
10870a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger    void internalDrawDevice(SkBaseDevice*, int x, int y, const SkPaint*);
108880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
108980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    // shared by save() and saveLayer()
109080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    int internalSave(SaveFlags flags);
109180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void internalRestore();
109280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    static void DrawRect(const SkDraw& draw, const SkPaint& paint,
109380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                         const SkRect& r, SkScalar textSize);
109480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    static void DrawTextDecorations(const SkDraw& draw, const SkPaint& paint,
109580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                                    const char text[], size_t byteLength,
109680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                                    SkScalar x, SkScalar y);
109780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
109880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /*  These maintain a cache of the clip bounds in local coordinates,
109980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        (converted to 2s-compliment if floats are slow).
110080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     */
1101910f694aefb0b671dd8522a9afe9b6be645701c1Derek Sollenberger    mutable SkRect fCachedLocalClipBounds;
1102910f694aefb0b671dd8522a9afe9b6be645701c1Derek Sollenberger    mutable bool   fCachedLocalClipBoundsDirty;
1103363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger    bool fAllowSoftClip;
11047839ce1af63bf12fe7b3caa866970bbbb3afb13dDerek Sollenberger    bool fAllowSimplifyClip;
110580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
1106910f694aefb0b671dd8522a9afe9b6be645701c1Derek Sollenberger    const SkRect& getLocalClipBounds() const {
1107910f694aefb0b671dd8522a9afe9b6be645701c1Derek Sollenberger        if (fCachedLocalClipBoundsDirty) {
1108910f694aefb0b671dd8522a9afe9b6be645701c1Derek Sollenberger            if (!this->getClipBounds(&fCachedLocalClipBounds)) {
1109910f694aefb0b671dd8522a9afe9b6be645701c1Derek Sollenberger                fCachedLocalClipBounds.setEmpty();
1110910f694aefb0b671dd8522a9afe9b6be645701c1Derek Sollenberger            }
1111910f694aefb0b671dd8522a9afe9b6be645701c1Derek Sollenberger            fCachedLocalClipBoundsDirty = false;
111280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        }
1113910f694aefb0b671dd8522a9afe9b6be645701c1Derek Sollenberger        return fCachedLocalClipBounds;
111480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
11157839ce1af63bf12fe7b3caa866970bbbb3afb13dDerek Sollenberger
111680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    class AutoValidateClip : ::SkNoncopyable {
111780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    public:
111880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        explicit AutoValidateClip(SkCanvas* canvas) : fCanvas(canvas) {
111980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            fCanvas->validateClip();
112080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        }
112180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        ~AutoValidateClip() { fCanvas->validateClip(); }
112280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
112380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    private:
112480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        const SkCanvas* fCanvas;
112580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    };
112680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
112780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifdef SK_DEBUG
112880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void validateClip() const;
112980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#else
113080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void validateClip() const {}
113180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif
113280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
113380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    typedef SkRefCnt INHERITED;
113480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru};
113580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
113680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru/** Stack helper class to automatically call restoreToCount() on the canvas
113780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    when this object goes out of scope. Use this to guarantee that the canvas
113880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    is restored to a known state.
113980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru*/
114080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkAutoCanvasRestore : SkNoncopyable {
114180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querupublic:
11420a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger    SkAutoCanvasRestore(SkCanvas* canvas, bool doSave) : fCanvas(canvas), fSaveCount(0) {
11430a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger        if (fCanvas) {
11440a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger            fSaveCount = canvas->getSaveCount();
11450a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger            if (doSave) {
11460a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger                canvas->save();
11470a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger            }
114880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        }
114980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
115080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    ~SkAutoCanvasRestore() {
1151363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger        if (fCanvas) {
1152363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger            fCanvas->restoreToCount(fSaveCount);
1153363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger        }
1154363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger    }
1155363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger
1156363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger    /**
1157363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger     *  Perform the restore now, instead of waiting for the destructor. Will
1158363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger     *  only do this once.
1159363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger     */
1160363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger    void restore() {
1161363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger        if (fCanvas) {
1162363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger            fCanvas->restoreToCount(fSaveCount);
1163363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger            fCanvas = NULL;
1164363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger        }
116580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
116680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
116780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruprivate:
116880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkCanvas*   fCanvas;
116980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    int         fSaveCount;
117080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru};
1171910f694aefb0b671dd8522a9afe9b6be645701c1Derek Sollenberger#define SkAutoCanvasRestore(...) SK_REQUIRE_LOCAL_VAR(SkAutoCanvasRestore)
117280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
117358190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger/** Stack helper class to automatically open and close a comment block
117458190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger */
117558190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenbergerclass SkAutoCommentBlock : SkNoncopyable {
117658190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenbergerpublic:
117758190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    SkAutoCommentBlock(SkCanvas* canvas, const char* description) {
117858190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger        fCanvas = canvas;
117958190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger        if (NULL != fCanvas) {
118058190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger            fCanvas->beginCommentGroup(description);
118158190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger        }
118258190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    }
118358190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger
118458190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    ~SkAutoCommentBlock() {
118558190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger        if (NULL != fCanvas) {
118658190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger            fCanvas->endCommentGroup();
118758190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger        }
118858190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    }
118958190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger
119058190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenbergerprivate:
119158190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    SkCanvas* fCanvas;
119258190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger};
1193910f694aefb0b671dd8522a9afe9b6be645701c1Derek Sollenberger#define SkAutoCommentBlock(...) SK_REQUIRE_LOCAL_VAR(SkAutoCommentBlock)
119458190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger
119580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif
1196