SkDevice.h revision 76f10a3bd936af7dbe2b5873d5a7eedd73cdc5da
1ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com
28a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/*
3ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Copyright 2010 The Android Open Source Project
48a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com *
5ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Use of this source code is governed by a BSD-style license that can be
6ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * found in the LICENSE file.
78a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */
88a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
9ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com
108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifndef SkDevice_DEFINED
118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define SkDevice_DEFINED
128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkRefCnt.h"
148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkBitmap.h"
158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkCanvas.h"
168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkColor.h"
17532470f34dbe9fc0b8b71e3917eca8894feaf336bungeman@google.com#include "SkDeviceProperties.h"
188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1946799cd9f0bded51a189d77731b25af159ab4609reed@google.comclass SkClipStack;
208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkDraw;
218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comstruct SkIRect;
228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkMatrix;
23a7d948523dce6044fc02db90726e5f971a93628breed@google.comclass SkMetaData;
248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkRegion;
258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
26b8d00db075b5ea09e353508a26ef5ced50722a6ccommit-bot@chromium.orgclass GrRenderTarget;
27d9f826c0dbc38f3608797a02948adf9bc99d5d50bsalomon@google.com
281f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.comclass SK_API SkBaseDevice : public SkRefCnt {
298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic:
301f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com    SK_DECLARE_INST_COUNT(SkBaseDevice)
3115e9d3e66e161ce23df30bc13f8a0c87d196b463robertphillips@google.com
32af951c9bc4cbb6e60b430194fe5127ebe99c53fbreed@google.com    /**
331f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com     *  Construct a new device.
348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
351f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com    SkBaseDevice();
36af951c9bc4cbb6e60b430194fe5127ebe99c53fbreed@google.com
37af951c9bc4cbb6e60b430194fe5127ebe99c53fbreed@google.com    /**
381f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com     *  Construct a new device.
39532470f34dbe9fc0b8b71e3917eca8894feaf336bungeman@google.com    */
401f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com    SkBaseDevice(const SkDeviceProperties& deviceProperties);
419b051a375ba6d6b61cea98f35834cd032aaa5347robertphillips@google.com
421f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com    virtual ~SkBaseDevice();
438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
44ea4ac97dec2eb291139bd906939e0d2e05cdd7efmike@reedtribe.org    /**
452d54d06adc58f0a6372fb2a1b2eca832965b863creed@google.com     *  Creates a device that is of the same type as this device (e.g. SW-raster,
462d54d06adc58f0a6372fb2a1b2eca832965b863creed@google.com     *  GPU, or PDF). The backing store for this device is created automatically
472d54d06adc58f0a6372fb2a1b2eca832965b863creed@google.com     *  (e.g. offscreen pixels or FBO or whatever is appropriate).
48e97f0856a8044866b12527819d14cdfbcdfd96f2bsalomon@google.com     *
492d54d06adc58f0a6372fb2a1b2eca832965b863creed@google.com     *  @param width    width of the device to create
502d54d06adc58f0a6372fb2a1b2eca832965b863creed@google.com     *  @param height   height of the device to create
512d54d06adc58f0a6372fb2a1b2eca832965b863creed@google.com     *  @param isOpaque performance hint, set to true if you know that you will
522d54d06adc58f0a6372fb2a1b2eca832965b863creed@google.com     *                  draw into this device such that all of the pixels will
532d54d06adc58f0a6372fb2a1b2eca832965b863creed@google.com     *                  be opaque.
54e97f0856a8044866b12527819d14cdfbcdfd96f2bsalomon@google.com     */
551f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com    SkBaseDevice* createCompatibleDevice(SkBitmap::Config config,
561f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com                                         int width, int height,
571f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com                                         bool isOpaque);
58e97f0856a8044866b12527819d14cdfbcdfd96f2bsalomon@google.com
5988edf1e50794e6d8cd7cc671ffce4f5e329ef888bungeman@google.com    SkMetaData& getMetaData();
6088edf1e50794e6d8cd7cc671ffce4f5e329ef888bungeman@google.com
6135fc62b960db6739b19c59576085663796951e47vandebo@chromium.org    enum Capabilities {
62fdbd504950556ea1165ee9b1df1c0968252c7d7ereed@google.com        kVector_Capability = 0x1,  //!< mask indicating a vector representation
6335fc62b960db6739b19c59576085663796951e47vandebo@chromium.org    };
641f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com    virtual uint32_t getDeviceCapabilities() = 0;
6535fc62b960db6739b19c59576085663796951e47vandebo@chromium.org
668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Return the width of the device (in pixels).
678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
681f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com    virtual int width() const = 0;
698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Return the height of the device (in pixels).
708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
711f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com    virtual int height() const = 0;
726f8f292aa768869a9e85c314b124875f57504f2creed@google.com
73532470f34dbe9fc0b8b71e3917eca8894feaf336bungeman@google.com    /** Return the image properties of the device. */
74532470f34dbe9fc0b8b71e3917eca8894feaf336bungeman@google.com    virtual const SkDeviceProperties& getDeviceProperties() const {
75532470f34dbe9fc0b8b71e3917eca8894feaf336bungeman@google.com        //Currently, all the properties are leaky.
76532470f34dbe9fc0b8b71e3917eca8894feaf336bungeman@google.com        return fLeakyProperties;
77532470f34dbe9fc0b8b71e3917eca8894feaf336bungeman@google.com    }
78532470f34dbe9fc0b8b71e3917eca8894feaf336bungeman@google.com
79d51bfa0583c82c7b731b993e56159fbf815dd2e0reed@google.com    /**
80d51bfa0583c82c7b731b993e56159fbf815dd2e0reed@google.com     *  Return the bounds of the device in the coordinate space of the root
81d51bfa0583c82c7b731b993e56159fbf815dd2e0reed@google.com     *  canvas. The root device will have its top-left at 0,0, but other devices
82d51bfa0583c82c7b731b993e56159fbf815dd2e0reed@google.com     *  such as those associated with saveLayer may have a non-zero origin.
83d51bfa0583c82c7b731b993e56159fbf815dd2e0reed@google.com     */
84ec3ca87d331c4b7058a0fff376a05e84ae0619careed@google.com    void getGlobalBounds(SkIRect* bounds) const {
85ec3ca87d331c4b7058a0fff376a05e84ae0619careed@google.com        SkASSERT(bounds);
86ec3ca87d331c4b7058a0fff376a05e84ae0619careed@google.com        const SkIPoint& origin = this->getOrigin();
87ec3ca87d331c4b7058a0fff376a05e84ae0619careed@google.com        bounds->setXYWH(origin.x(), origin.y(), this->width(), this->height());
88ec3ca87d331c4b7058a0fff376a05e84ae0619careed@google.com    }
8973a5d53d96cb7a0b4214e273ed147d401e31ea16skia.committer@gmail.com
9088edf1e50794e6d8cd7cc671ffce4f5e329ef888bungeman@google.com
9107f81a57ba5720fd65563077114bd9e5ba840151robertphillips@google.com    /** Returns true if the device's bitmap's config treats every pixel as
928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        implicitly opaque.
938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
941f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com    virtual bool isOpaque() const = 0;
95772c4e6d09f5e0971a584d2035ee789483d6f47askia.committer@gmail.com
964469938e92d779dff05e745559e67907bbf21e78reed@google.com    /** Return the bitmap config of the device's pixels
971f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com     */
984469938e92d779dff05e745559e67907bbf21e78reed@google.com    SK_ATTR_DEPRECATED("want to hide configness of the device -- don't use")
991f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com    virtual SkBitmap::Config config() const = 0;
1008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Return the bitmap associated with this device. Call this each time you need
1028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        to access the bitmap, as it notifies the subclass to perform any flushing
1038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        etc. before you examine the pixels.
1048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param changePixels set to true if the caller plans to change the pixels
1058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return the device's bitmap
1068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
1078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    const SkBitmap& accessBitmap(bool changePixels);
1088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
10988edf1e50794e6d8cd7cc671ffce4f5e329ef888bungeman@google.com    /**
110ae0fb058dd9a11171ae4b807ce8a65017e52d5e1bsalomon@google.com     *  DEPRECATED: This will be made protected once WebKit stops using it.
1116850eab42ba4c2a7033a99824b02a2846ce0ef2absalomon@google.com     *              Instead use Canvas' writePixels method.
112d58a1cd00b969a7755c375f55cf80f4d49d3047bbsalomon@google.com     *
11388edf1e50794e6d8cd7cc671ffce4f5e329ef888bungeman@google.com     *  Similar to draw sprite, this method will copy the pixels in bitmap onto
11488edf1e50794e6d8cd7cc671ffce4f5e329ef888bungeman@google.com     *  the device, with the top/left corner specified by (x, y). The pixel
11588edf1e50794e6d8cd7cc671ffce4f5e329ef888bungeman@google.com     *  values in the device are completely replaced: there is no blending.
116d58a1cd00b969a7755c375f55cf80f4d49d3047bbsalomon@google.com     *
117d58a1cd00b969a7755c375f55cf80f4d49d3047bbsalomon@google.com     *  Currently if bitmap is backed by a texture this is a no-op. This may be
118d58a1cd00b969a7755c375f55cf80f4d49d3047bbsalomon@google.com     *  relaxed in the future.
119d58a1cd00b969a7755c375f55cf80f4d49d3047bbsalomon@google.com     *
120d58a1cd00b969a7755c375f55cf80f4d49d3047bbsalomon@google.com     *  If the bitmap has config kARGB_8888_Config then the config8888 param
121d58a1cd00b969a7755c375f55cf80f4d49d3047bbsalomon@google.com     *  will determines how the pixel valuess are intepreted. If the bitmap is
122d58a1cd00b969a7755c375f55cf80f4d49d3047bbsalomon@google.com     *  not kARGB_8888_Config then this parameter is ignored.
123398109cc3e56b8122ad21c4d43a74a83be5b42a8bsalomon@google.com     */
124d58a1cd00b969a7755c375f55cf80f4d49d3047bbsalomon@google.com    virtual void writePixels(const SkBitmap& bitmap, int x, int y,
1251f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com                             SkCanvas::Config8888 config8888 = SkCanvas::kNative_Premul_Config8888) = 0;
1268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
127d9f826c0dbc38f3608797a02948adf9bc99d5d50bsalomon@google.com    /**
128d9f826c0dbc38f3608797a02948adf9bc99d5d50bsalomon@google.com     * Return the device's associated gpu render target, or NULL.
129f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com     */
1301f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com    virtual GrRenderTarget* accessRenderTarget() = 0;
131f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com
13288edf1e50794e6d8cd7cc671ffce4f5e329ef888bungeman@google.com
13388edf1e50794e6d8cd7cc671ffce4f5e329ef888bungeman@google.com    /**
13488edf1e50794e6d8cd7cc671ffce4f5e329ef888bungeman@google.com     *  Return the device's origin: its offset in device coordinates from
13588edf1e50794e6d8cd7cc671ffce4f5e329ef888bungeman@google.com     *  the default origin in its canvas' matrix/clip
13688edf1e50794e6d8cd7cc671ffce4f5e329ef888bungeman@google.com     */
13788edf1e50794e6d8cd7cc671ffce4f5e329ef888bungeman@google.com    const SkIPoint& getOrigin() const { return fOrigin; }
13888edf1e50794e6d8cd7cc671ffce4f5e329ef888bungeman@google.com
139fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    /**
14040a1ae4df28810aa5aa5cf2627d8387b2dfb867arobertphillips@google.com     * onAttachToCanvas is invoked whenever a device is installed in a canvas
14140a1ae4df28810aa5aa5cf2627d8387b2dfb867arobertphillips@google.com     * (i.e., setDevice, saveLayer (for the new device created by the save),
1421f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com     * and SkCanvas' SkBaseDevice & SkBitmap -taking ctors). It allows the
14340a1ae4df28810aa5aa5cf2627d8387b2dfb867arobertphillips@google.com     * devices to prepare for drawing (e.g., locking their pixels, etc.)
14440a1ae4df28810aa5aa5cf2627d8387b2dfb867arobertphillips@google.com     */
145e0e385c1d4171e065348ba17c546b3463a0bd651sugoi@google.com    virtual void onAttachToCanvas(SkCanvas*) {
146405d0f43d8fa03874aee23669e5fdb38f21cc3e7bsalomon@google.com        SkASSERT(!fAttachedToCanvas);
14740a1ae4df28810aa5aa5cf2627d8387b2dfb867arobertphillips@google.com        this->lockPixels();
14840a1ae4df28810aa5aa5cf2627d8387b2dfb867arobertphillips@google.com#ifdef SK_DEBUG
14940a1ae4df28810aa5aa5cf2627d8387b2dfb867arobertphillips@google.com        fAttachedToCanvas = true;
15040a1ae4df28810aa5aa5cf2627d8387b2dfb867arobertphillips@google.com#endif
15140a1ae4df28810aa5aa5cf2627d8387b2dfb867arobertphillips@google.com    };
15240a1ae4df28810aa5aa5cf2627d8387b2dfb867arobertphillips@google.com
15340a1ae4df28810aa5aa5cf2627d8387b2dfb867arobertphillips@google.com    /**
15440a1ae4df28810aa5aa5cf2627d8387b2dfb867arobertphillips@google.com     * onDetachFromCanvas notifies a device that it will no longer be drawn to.
15540a1ae4df28810aa5aa5cf2627d8387b2dfb867arobertphillips@google.com     * It gives the device a chance to clean up (e.g., unlock its pixels). It
156fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com     * is invoked from setDevice (for the displaced device), restore and
15740a1ae4df28810aa5aa5cf2627d8387b2dfb867arobertphillips@google.com     * possibly from SkCanvas' dtor.
15840a1ae4df28810aa5aa5cf2627d8387b2dfb867arobertphillips@google.com     */
15940a1ae4df28810aa5aa5cf2627d8387b2dfb867arobertphillips@google.com    virtual void onDetachFromCanvas() {
160405d0f43d8fa03874aee23669e5fdb38f21cc3e7bsalomon@google.com        SkASSERT(fAttachedToCanvas);
16140a1ae4df28810aa5aa5cf2627d8387b2dfb867arobertphillips@google.com        this->unlockPixels();
16240a1ae4df28810aa5aa5cf2627d8387b2dfb867arobertphillips@google.com#ifdef SK_DEBUG
16340a1ae4df28810aa5aa5cf2627d8387b2dfb867arobertphillips@google.com        fAttachedToCanvas = false;
16440a1ae4df28810aa5aa5cf2627d8387b2dfb867arobertphillips@google.com#endif
16540a1ae4df28810aa5aa5cf2627d8387b2dfb867arobertphillips@google.com    };
16640a1ae4df28810aa5aa5cf2627d8387b2dfb867arobertphillips@google.com
167d53f7c28bf8aecd5b7f0ee2189ac97e309a1b06dcaryclark@google.comprotected:
168d53f7c28bf8aecd5b7f0ee2189ac97e309a1b06dcaryclark@google.com    enum Usage {
169d53f7c28bf8aecd5b7f0ee2189ac97e309a1b06dcaryclark@google.com       kGeneral_Usage,
1701f90287df3129cb267422e482c52ebeca6a8990ftomhudson@google.com       kSaveLayer_Usage  // <! internal use only
171d53f7c28bf8aecd5b7f0ee2189ac97e309a1b06dcaryclark@google.com    };
172d53f7c28bf8aecd5b7f0ee2189ac97e309a1b06dcaryclark@google.com
17388edf1e50794e6d8cd7cc671ffce4f5e329ef888bungeman@google.com    struct TextFlags {
17488edf1e50794e6d8cd7cc671ffce4f5e329ef888bungeman@google.com        uint32_t            fFlags;     // SkPaint::getFlags()
17588edf1e50794e6d8cd7cc671ffce4f5e329ef888bungeman@google.com        SkPaint::Hinting    fHinting;
17688edf1e50794e6d8cd7cc671ffce4f5e329ef888bungeman@google.com    };
17788edf1e50794e6d8cd7cc671ffce4f5e329ef888bungeman@google.com
17888edf1e50794e6d8cd7cc671ffce4f5e329ef888bungeman@google.com    /**
17988edf1e50794e6d8cd7cc671ffce4f5e329ef888bungeman@google.com     *  Device may filter the text flags for drawing text here. If it wants to
18088edf1e50794e6d8cd7cc671ffce4f5e329ef888bungeman@google.com     *  make a change to the specified values, it should write them into the
18188edf1e50794e6d8cd7cc671ffce4f5e329ef888bungeman@google.com     *  textflags parameter (output) and return true. If the paint is fine as
18288edf1e50794e6d8cd7cc671ffce4f5e329ef888bungeman@google.com     *  is, then ignore the textflags parameter and return false.
18388edf1e50794e6d8cd7cc671ffce4f5e329ef888bungeman@google.com     *
1841f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com     *  The baseclass SkBaseDevice filters based on its depth and blitters.
18588edf1e50794e6d8cd7cc671ffce4f5e329ef888bungeman@google.com     */
1861f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com    virtual bool filterTextFlags(const SkPaint& paint, TextFlags*) = 0;
18788edf1e50794e6d8cd7cc671ffce4f5e329ef888bungeman@google.com
1883fffb2ee9fa01ae61efb2395973eb7575eda4c96robertphillips@google.com    /**
189a6926b1f0352916c31cda66f2239a25d52f09315bsalomon@google.com     *
190a6926b1f0352916c31cda66f2239a25d52f09315bsalomon@google.com     *  DEPRECATED: This will be removed in a future change. Device subclasses
191a6926b1f0352916c31cda66f2239a25d52f09315bsalomon@google.com     *  should use the matrix and clip from the SkDraw passed to draw functions.
192a6926b1f0352916c31cda66f2239a25d52f09315bsalomon@google.com     *
1933fffb2ee9fa01ae61efb2395973eb7575eda4c96robertphillips@google.com     *  Called with the correct matrix and clip before this device is drawn
1943fffb2ee9fa01ae61efb2395973eb7575eda4c96robertphillips@google.com     *  to using those settings. If your subclass overrides this, be sure to
1953fffb2ee9fa01ae61efb2395973eb7575eda4c96robertphillips@google.com     *  call through to the base class as well.
1963fffb2ee9fa01ae61efb2395973eb7575eda4c96robertphillips@google.com     *
1973fffb2ee9fa01ae61efb2395973eb7575eda4c96robertphillips@google.com     *  The clipstack is another view of the clip. It records the actual
1983fffb2ee9fa01ae61efb2395973eb7575eda4c96robertphillips@google.com     *  geometry that went into building the region. It is present for devices
1993fffb2ee9fa01ae61efb2395973eb7575eda4c96robertphillips@google.com     *  that want to parse it, but is not required: the region is a complete
2003fffb2ee9fa01ae61efb2395973eb7575eda4c96robertphillips@google.com     *  picture of the current clip. (i.e. if you regionize all of the geometry
2013fffb2ee9fa01ae61efb2395973eb7575eda4c96robertphillips@google.com     *  in the clipstack, you will arrive at an equivalent region to the one
2023fffb2ee9fa01ae61efb2395973eb7575eda4c96robertphillips@google.com     *  passed in).
203a6926b1f0352916c31cda66f2239a25d52f09315bsalomon@google.com     */
204a6926b1f0352916c31cda66f2239a25d52f09315bsalomon@google.com     virtual void setMatrixClip(const SkMatrix&, const SkRegion&,
2051f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com                                const SkClipStack&) {};
2063fffb2ee9fa01ae61efb2395973eb7575eda4c96robertphillips@google.com
20788edf1e50794e6d8cd7cc671ffce4f5e329ef888bungeman@google.com    /** Clears the entire device to the specified color (including alpha).
20888edf1e50794e6d8cd7cc671ffce4f5e329ef888bungeman@google.com     *  Ignores the clip.
209f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com     */
2101f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com    virtual void clear(SkColor color) = 0;
211f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com
21262f1048ada9312f48fc62f8de4f91a0a8f8f6047tfarina@chromium.org    SK_ATTR_DEPRECATED("use clear() instead")
21388edf1e50794e6d8cd7cc671ffce4f5e329ef888bungeman@google.com    void eraseColor(SkColor eraseColor) { this->clear(eraseColor); }
2148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** These are called inside the per-device-layer loop for each draw call.
2168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com     When these are called, we have already applied any saveLayer operations,
2178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com     and are handling any looping from the paint, and any effects from the
2188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com     DrawFilter.
2198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com     */
2201f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com    virtual void drawPaint(const SkDraw&, const SkPaint& paint) = 0;
2218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, size_t count,
2221f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com                            const SkPoint[], const SkPaint& paint) = 0;
2238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual void drawRect(const SkDraw&, const SkRect& r,
2241f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com                          const SkPaint& paint) = 0;
22546d3d39e65e0b3ea2ad7c91c176ccafb4df0fa24jvanverth@google.com    virtual void drawOval(const SkDraw&, const SkRect& oval,
2261f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com                          const SkPaint& paint) = 0;
227f2bfd54de32ffbcf90ddcd0e249aaebb1559d9c2commit-bot@chromium.org    virtual void drawRRect(const SkDraw&, const SkRRect& rr,
2281f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com                           const SkPaint& paint) = 0;
229f2bfd54de32ffbcf90ddcd0e249aaebb1559d9c2commit-bot@chromium.org
2307ff8d81290c3d9d461f2e304f4fd7846275f956dreed@google.com    /**
2317ff8d81290c3d9d461f2e304f4fd7846275f956dreed@google.com     *  If pathIsMutable, then the implementation is allowed to cast path to a
2327ff8d81290c3d9d461f2e304f4fd7846275f956dreed@google.com     *  non-const pointer and modify it in place (as an optimization). Canvas
2337ff8d81290c3d9d461f2e304f4fd7846275f956dreed@google.com     *  may do this to implement helpers such as drawOval, by placing a temp
2347ff8d81290c3d9d461f2e304f4fd7846275f956dreed@google.com     *  path on the stack to hold the representation of the oval.
2357ff8d81290c3d9d461f2e304f4fd7846275f956dreed@google.com     *
2367ff8d81290c3d9d461f2e304f4fd7846275f956dreed@google.com     *  If prePathMatrix is not null, it should logically be applied before any
2377ff8d81290c3d9d461f2e304f4fd7846275f956dreed@google.com     *  stroking or other effects. If there are no effects on the paint that
2387ff8d81290c3d9d461f2e304f4fd7846275f956dreed@google.com     *  affect the geometry/rasterization, then the pre matrix can just be
2397ff8d81290c3d9d461f2e304f4fd7846275f956dreed@google.com     *  pre-concated with the current matrix.
2407ff8d81290c3d9d461f2e304f4fd7846275f956dreed@google.com     */
2418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual void drawPath(const SkDraw&, const SkPath& path,
242f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com                          const SkPaint& paint,
243f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com                          const SkMatrix* prePathMatrix = NULL,
2441f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com                          bool pathIsMutable = false) = 0;
2458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual void drawBitmap(const SkDraw&, const SkBitmap& bitmap,
2461f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com                            const SkMatrix& matrix, const SkPaint& paint) = 0;
2478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual void drawSprite(const SkDraw&, const SkBitmap& bitmap,
2481f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com                            int x, int y, const SkPaint& paint) = 0;
24933535f3c48bf723c46f334a93d4a06d782dad30ereed@google.com
25033535f3c48bf723c46f334a93d4a06d782dad30ereed@google.com    /**
25133535f3c48bf723c46f334a93d4a06d782dad30ereed@google.com     *  The default impl. will create a bitmap-shader from the bitmap,
25233535f3c48bf723c46f334a93d4a06d782dad30ereed@google.com     *  and call drawRect with it.
25333535f3c48bf723c46f334a93d4a06d782dad30ereed@google.com     */
25433535f3c48bf723c46f334a93d4a06d782dad30ereed@google.com    virtual void drawBitmapRect(const SkDraw&, const SkBitmap&,
25533535f3c48bf723c46f334a93d4a06d782dad30ereed@google.com                                const SkRect* srcOrNull, const SkRect& dst,
256eed779d866e1e239bfb9ebc6a225b7345a41adf9commit-bot@chromium.org                                const SkPaint& paint,
2571f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com                                SkCanvas::DrawBitmapRectFlags flags) = 0;
25833535f3c48bf723c46f334a93d4a06d782dad30ereed@google.com
25952c748b1691f02f90b27c35bc05074fcef709e66bungeman@google.com    /**
26052c748b1691f02f90b27c35bc05074fcef709e66bungeman@google.com     *  Does not handle text decoration.
26152c748b1691f02f90b27c35bc05074fcef709e66bungeman@google.com     *  Decorations (underline and stike-thru) will be handled by SkCanvas.
26252c748b1691f02f90b27c35bc05074fcef709e66bungeman@google.com     */
2638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual void drawText(const SkDraw&, const void* text, size_t len,
2641f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com                          SkScalar x, SkScalar y, const SkPaint& paint) = 0;
2658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual void drawPosText(const SkDraw&, const void* text, size_t len,
2668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                             const SkScalar pos[], SkScalar constY,
2671f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com                             int scalarsPerPos, const SkPaint& paint) = 0;
2688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual void drawTextOnPath(const SkDraw&, const void* text, size_t len,
2698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                                const SkPath& path, const SkMatrix* matrix,
2701f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com                                const SkPaint& paint) = 0;
2718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual void drawVertices(const SkDraw&, SkCanvas::VertexMode, int vertexCount,
2728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                              const SkPoint verts[], const SkPoint texs[],
2738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                              const SkColor colors[], SkXfermode* xmode,
2748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                              const uint16_t indices[], int indexCount,
2751f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com                              const SkPaint& paint) = 0;
2769b051a375ba6d6b61cea98f35834cd032aaa5347robertphillips@google.com    /** The SkDevice passed will be an SkDevice which was returned by a call to
27788edf1e50794e6d8cd7cc671ffce4f5e329ef888bungeman@google.com        onCreateCompatibleDevice on this device with kSaveLayer_Usage.
27888edf1e50794e6d8cd7cc671ffce4f5e329ef888bungeman@google.com     */
2791f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com    virtual void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y,
2801f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com                            const SkPaint&) = 0;
2818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2826850eab42ba4c2a7033a99824b02a2846ce0ef2absalomon@google.com    /**
2836850eab42ba4c2a7033a99824b02a2846ce0ef2absalomon@google.com     *  On success (returns true), copy the device pixels into the bitmap.
2846850eab42ba4c2a7033a99824b02a2846ce0ef2absalomon@google.com     *  On failure, the bitmap parameter is left unchanged and false is
2856850eab42ba4c2a7033a99824b02a2846ce0ef2absalomon@google.com     *  returned.
2866850eab42ba4c2a7033a99824b02a2846ce0ef2absalomon@google.com     *
2876850eab42ba4c2a7033a99824b02a2846ce0ef2absalomon@google.com     *  The device's pixels are converted to the bitmap's config. The only
2886850eab42ba4c2a7033a99824b02a2846ce0ef2absalomon@google.com     *  supported config is kARGB_8888_Config, though this is likely to be
2896850eab42ba4c2a7033a99824b02a2846ce0ef2absalomon@google.com     *  relaxed in  the future. The meaning of config kARGB_8888_Config is
2906850eab42ba4c2a7033a99824b02a2846ce0ef2absalomon@google.com     *  modified by the enum param config8888. The default value interprets
2916850eab42ba4c2a7033a99824b02a2846ce0ef2absalomon@google.com     *  kARGB_8888_Config as SkPMColor
2926850eab42ba4c2a7033a99824b02a2846ce0ef2absalomon@google.com     *
2936850eab42ba4c2a7033a99824b02a2846ce0ef2absalomon@google.com     *  If the bitmap has pixels already allocated, the device pixels will be
29474b461961607fa57a150a9282c410ef0cab38764vandebo@chromium.org     *  written there. If not, bitmap->allocPixels() will be called
2956850eab42ba4c2a7033a99824b02a2846ce0ef2absalomon@google.com     *  automatically. If the bitmap is backed by a texture readPixels will
2966850eab42ba4c2a7033a99824b02a2846ce0ef2absalomon@google.com     *  fail.
2976850eab42ba4c2a7033a99824b02a2846ce0ef2absalomon@google.com     *
2986850eab42ba4c2a7033a99824b02a2846ce0ef2absalomon@google.com     *  The actual pixels written is the intersection of the device's bounds,
2996850eab42ba4c2a7033a99824b02a2846ce0ef2absalomon@google.com     *  and the rectangle formed by the bitmap's width,height and the specified
3006850eab42ba4c2a7033a99824b02a2846ce0ef2absalomon@google.com     *  x,y. If bitmap pixels extend outside of that intersection, they will not
3016850eab42ba4c2a7033a99824b02a2846ce0ef2absalomon@google.com     *  be modified.
3026850eab42ba4c2a7033a99824b02a2846ce0ef2absalomon@google.com     *
3036850eab42ba4c2a7033a99824b02a2846ce0ef2absalomon@google.com     *  Other failure conditions:
3046850eab42ba4c2a7033a99824b02a2846ce0ef2absalomon@google.com     *    * If the device is not a raster device (e.g. PDF) then readPixels will
3056850eab42ba4c2a7033a99824b02a2846ce0ef2absalomon@google.com     *      fail.
3066850eab42ba4c2a7033a99824b02a2846ce0ef2absalomon@google.com     *    * If bitmap is texture-backed then readPixels will fail. (This may be
3076850eab42ba4c2a7033a99824b02a2846ce0ef2absalomon@google.com     *      relaxed in the future.)
3086850eab42ba4c2a7033a99824b02a2846ce0ef2absalomon@google.com     */
3096850eab42ba4c2a7033a99824b02a2846ce0ef2absalomon@google.com    bool readPixels(SkBitmap* bitmap,
3106850eab42ba4c2a7033a99824b02a2846ce0ef2absalomon@google.com                    int x, int y,
3116850eab42ba4c2a7033a99824b02a2846ce0ef2absalomon@google.com                    SkCanvas::Config8888 config8888);
3126850eab42ba4c2a7033a99824b02a2846ce0ef2absalomon@google.com
3133636ed558fb2af5a48a9634efec55fd8a87c88d7reed@google.com    ///////////////////////////////////////////////////////////////////////////
3143636ed558fb2af5a48a9634efec55fd8a87c88d7reed@google.com
3151f9767c03bad1ef85e5388d84e23e4b5dff4bc1ajunov@chromium.org    /** Update as needed the pixel value in the bitmap, so that the caller can
316772c4e6d09f5e0971a584d2035ee789483d6f47askia.committer@gmail.com        access the pixels directly.
3171f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com        @return The device contents as a bitmap
3188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
3191f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com    virtual const SkBitmap& onAccessBitmap() = 0;
32074b461961607fa57a150a9282c410ef0cab38764vandebo@chromium.org
321c69809745e6496564639e42ef998ad39adf7dfb8bsalomon@google.com    /**
322c69809745e6496564639e42ef998ad39adf7dfb8bsalomon@google.com     * Implements readPixels API. The caller will ensure that:
323c69809745e6496564639e42ef998ad39adf7dfb8bsalomon@google.com     *  1. bitmap has pixel config kARGB_8888_Config.
324c69809745e6496564639e42ef998ad39adf7dfb8bsalomon@google.com     *  2. bitmap has pixels.
325c69809745e6496564639e42ef998ad39adf7dfb8bsalomon@google.com     *  3. The rectangle (x, y, x + bitmap->width(), y + bitmap->height()) is
326c69809745e6496564639e42ef998ad39adf7dfb8bsalomon@google.com     *     contained in the device bounds.
327c69809745e6496564639e42ef998ad39adf7dfb8bsalomon@google.com     */
3286850eab42ba4c2a7033a99824b02a2846ce0ef2absalomon@google.com    virtual bool onReadPixels(const SkBitmap& bitmap,
3296850eab42ba4c2a7033a99824b02a2846ce0ef2absalomon@google.com                              int x, int y,
3301f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com                              SkCanvas::Config8888 config8888) = 0;
331f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com
33207f81a57ba5720fd65563077114bd9e5ba840151robertphillips@google.com    /** Called when this device is installed into a Canvas. Balanced by a call
33388edf1e50794e6d8cd7cc671ffce4f5e329ef888bungeman@google.com        to unlockPixels() when the device is removed from a Canvas.
33488edf1e50794e6d8cd7cc671ffce4f5e329ef888bungeman@google.com    */
3351f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com    virtual void lockPixels() = 0;
3361f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com    virtual void unlockPixels() = 0;
33788edf1e50794e6d8cd7cc671ffce4f5e329ef888bungeman@google.com
33876dd277b1fa021c42fc3acdd8d61e7dc05f9c267reed@google.com    /**
339b55deeb1c7c692023603639a9b29c0e3de124eacreed@google.com     *  Returns true if the device allows processing of this imagefilter. If
340b55deeb1c7c692023603639a9b29c0e3de124eacreed@google.com     *  false is returned, then the filter is ignored. This may happen for
341b55deeb1c7c692023603639a9b29c0e3de124eacreed@google.com     *  some subclasses that do not support pixel manipulations after drawing
342b55deeb1c7c692023603639a9b29c0e3de124eacreed@google.com     *  has occurred (e.g. printing). The default implementation returns true.
343b55deeb1c7c692023603639a9b29c0e3de124eacreed@google.com     */
3441f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com    virtual bool allowImageFilter(SkImageFilter*) = 0;
345b55deeb1c7c692023603639a9b29c0e3de124eacreed@google.com
346b55deeb1c7c692023603639a9b29c0e3de124eacreed@google.com    /**
3478926b169f6a0dfa4c2129a98ec2aee205f0c8527reed@google.com     *  Override and return true for filters that the device can handle
3488926b169f6a0dfa4c2129a98ec2aee205f0c8527reed@google.com     *  intrinsically. Doing so means that SkCanvas will pass-through this
3498926b169f6a0dfa4c2129a98ec2aee205f0c8527reed@google.com     *  filter to drawSprite and drawDevice (and potentially filterImage).
3508926b169f6a0dfa4c2129a98ec2aee205f0c8527reed@google.com     *  Returning false means the SkCanvas will have apply the filter itself,
3518926b169f6a0dfa4c2129a98ec2aee205f0c8527reed@google.com     *  and just pass the resulting image to the device.
35276dd277b1fa021c42fc3acdd8d61e7dc05f9c267reed@google.com     */
3531f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com    virtual bool canHandleImageFilter(SkImageFilter*) = 0;
3548926b169f6a0dfa4c2129a98ec2aee205f0c8527reed@google.com
3558926b169f6a0dfa4c2129a98ec2aee205f0c8527reed@google.com    /**
3568926b169f6a0dfa4c2129a98ec2aee205f0c8527reed@google.com     *  Related (but not required) to canHandleImageFilter, this method returns
3578926b169f6a0dfa4c2129a98ec2aee205f0c8527reed@google.com     *  true if the device could apply the filter to the src bitmap and return
3588926b169f6a0dfa4c2129a98ec2aee205f0c8527reed@google.com     *  the result (and updates offset as needed).
3598926b169f6a0dfa4c2129a98ec2aee205f0c8527reed@google.com     *  If the device does not recognize or support this filter,
3608926b169f6a0dfa4c2129a98ec2aee205f0c8527reed@google.com     *  it just returns false and leaves result and offset unchanged.
3618926b169f6a0dfa4c2129a98ec2aee205f0c8527reed@google.com     */
3628926b169f6a0dfa4c2129a98ec2aee205f0c8527reed@google.com    virtual bool filterImage(SkImageFilter*, const SkBitmap&, const SkMatrix&,
3631f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com                             SkBitmap* result, SkIPoint* offset) = 0;
36476dd277b1fa021c42fc3acdd8d61e7dc05f9c267reed@google.com
36574b461961607fa57a150a9282c410ef0cab38764vandebo@chromium.org    // This is equal kBGRA_Premul_Config8888 or kRGBA_Premul_Config8888 if
3666850eab42ba4c2a7033a99824b02a2846ce0ef2absalomon@google.com    // either is identical to kNative_Premul_Config8888. Otherwise, -1.
3676850eab42ba4c2a7033a99824b02a2846ce0ef2absalomon@google.com    static const SkCanvas::Config8888 kPMColorAlias;
3686850eab42ba4c2a7033a99824b02a2846ce0ef2absalomon@google.com
3698128d8c119382279918b90ad8d80ccb3aaebb8a0commit-bot@chromium.orgprotected:
37076f10a3bd936af7dbe2b5873d5a7eedd73cdc5dareed@google.com    // default impl returns NULL
37176f10a3bd936af7dbe2b5873d5a7eedd73cdc5dareed@google.com    virtual SkSurface* newSurface(const SkImageInfo&);
37276f10a3bd936af7dbe2b5873d5a7eedd73cdc5dareed@google.com
3738128d8c119382279918b90ad8d80ccb3aaebb8a0commit-bot@chromium.org    /**
3748128d8c119382279918b90ad8d80ccb3aaebb8a0commit-bot@chromium.org     *  Leaky properties are those which the device should be applying but it isn't.
3758128d8c119382279918b90ad8d80ccb3aaebb8a0commit-bot@chromium.org     *  These properties will be applied by the draw, when and as it can.
3768128d8c119382279918b90ad8d80ccb3aaebb8a0commit-bot@chromium.org     *  If the device does handle a property, that property should be set to the identity value
3778128d8c119382279918b90ad8d80ccb3aaebb8a0commit-bot@chromium.org     *  for that property, effectively making it non-leaky.
3788128d8c119382279918b90ad8d80ccb3aaebb8a0commit-bot@chromium.org     */
3798128d8c119382279918b90ad8d80ccb3aaebb8a0commit-bot@chromium.org    SkDeviceProperties fLeakyProperties;
3808128d8c119382279918b90ad8d80ccb3aaebb8a0commit-bot@chromium.org
3818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprivate:
3826f8f292aa768869a9e85c314b124875f57504f2creed@google.com    friend class SkCanvas;
3833fffb2ee9fa01ae61efb2395973eb7575eda4c96robertphillips@google.com    friend struct DeviceCM; //for setMatrixClip
38488edf1e50794e6d8cd7cc671ffce4f5e329ef888bungeman@google.com    friend class SkDraw;
38588edf1e50794e6d8cd7cc671ffce4f5e329ef888bungeman@google.com    friend class SkDrawIter;
38688edf1e50794e6d8cd7cc671ffce4f5e329ef888bungeman@google.com    friend class SkDeviceFilteredPaint;
3879c39744a00573b7133fc765b0a9d50a0ceace7b8senorblanco@chromium.org    friend class SkDeviceImageFilterProxy;
38876f10a3bd936af7dbe2b5873d5a7eedd73cdc5dareed@google.com    friend class DeferredDevice;    // for newSurface
38988edf1e50794e6d8cd7cc671ffce4f5e329ef888bungeman@google.com
39097af1a64ae6bdddd346d8babfd9f188279dd6644reed@google.com    friend class SkSurface_Raster;
3911f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com
39297af1a64ae6bdddd346d8babfd9f188279dd6644reed@google.com    // used to change the backend's pixels (and possibly config/rowbytes)
39397af1a64ae6bdddd346d8babfd9f188279dd6644reed@google.com    // but cannot change the width/height, so there should be no change to
39497af1a64ae6bdddd346d8babfd9f188279dd6644reed@google.com    // any clip information.
395ec3ca87d331c4b7058a0fff376a05e84ae0619careed@google.com    // TODO: move to SkBitmapDevice
3961f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com    virtual void replaceBitmapBackendForRasterSurface(const SkBitmap&) = 0;
39797af1a64ae6bdddd346d8babfd9f188279dd6644reed@google.com
3985676b4a23a190b9a0e2f4d803fe17dbfa47caf7evandebo@chromium.org    // just called by SkCanvas when built as a layer
3995676b4a23a190b9a0e2f4d803fe17dbfa47caf7evandebo@chromium.org    void setOrigin(int x, int y) { fOrigin.set(x, y); }
400e97f0856a8044866b12527819d14cdfbcdfd96f2bsalomon@google.com    // just called by SkCanvas for saveLayer
4011f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com    SkBaseDevice* createCompatibleDeviceForSaveLayer(SkBitmap::Config config,
4021f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com                                                     int width, int height,
4031f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com                                                     bool isOpaque);
4046f8f292aa768869a9e85c314b124875f57504f2creed@google.com
40588edf1e50794e6d8cd7cc671ffce4f5e329ef888bungeman@google.com    /**
40688edf1e50794e6d8cd7cc671ffce4f5e329ef888bungeman@google.com     * Subclasses should override this to implement createCompatibleDevice.
40788edf1e50794e6d8cd7cc671ffce4f5e329ef888bungeman@google.com     */
4081f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com    virtual SkBaseDevice* onCreateCompatibleDevice(SkBitmap::Config config,
4091f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com                                                   int width, int height,
4101f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com                                                   bool isOpaque,
4111f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com                                                   Usage usage) = 0;
41288edf1e50794e6d8cd7cc671ffce4f5e329ef888bungeman@google.com
41388edf1e50794e6d8cd7cc671ffce4f5e329ef888bungeman@google.com    /** Causes any deferred drawing to the device to be completed.
41488edf1e50794e6d8cd7cc671ffce4f5e329ef888bungeman@google.com     */
4151f2f338e23789f3eef168dcbd8171a28820ba6c1robertphillips@google.com    virtual void flush() = 0;
41688edf1e50794e6d8cd7cc671ffce4f5e329ef888bungeman@google.com
4176f8f292aa768869a9e85c314b124875f57504f2creed@google.com    SkIPoint    fOrigin;
418a7d948523dce6044fc02db90726e5f971a93628breed@google.com    SkMetaData* fMetaData;
41915e9d3e66e161ce23df30bc13f8a0c87d196b463robertphillips@google.com
42040a1ae4df28810aa5aa5cf2627d8387b2dfb867arobertphillips@google.com#ifdef SK_DEBUG
42140a1ae4df28810aa5aa5cf2627d8387b2dfb867arobertphillips@google.com    bool        fAttachedToCanvas;
42240a1ae4df28810aa5aa5cf2627d8387b2dfb867arobertphillips@google.com#endif
42340a1ae4df28810aa5aa5cf2627d8387b2dfb867arobertphillips@google.com
42415e9d3e66e161ce23df30bc13f8a0c87d196b463robertphillips@google.com    typedef SkRefCnt INHERITED;
4258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com};
4268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
428