SkDevice.h revision f67e4cf4c18cd228738a11372859ee0280bce1d7
18a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/* 28c1d88dcfb978835779b6b5c5e7d1cbb78b6ca4dvandebo@chromium.org * Copyright (C) 2010 The Android Open Source Project 38a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * 48a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * Licensed under the Apache License, Version 2.0 (the "License"); 58a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * you may not use this file except in compliance with the License. 68a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * You may obtain a copy of the License at 78a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * 88a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * http://www.apache.org/licenses/LICENSE-2.0 98a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * 108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * Unless required by applicable law or agreed to in writing, software 118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * distributed under the License is distributed on an "AS IS" BASIS, 128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * See the License for the specific language governing permissions and 148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * limitations under the License. 158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifndef SkDevice_DEFINED 188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define SkDevice_DEFINED 198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkRefCnt.h" 218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkBitmap.h" 228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkCanvas.h" 238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkColor.h" 243636ed558fb2af5a48a9634efec55fd8a87c88d7reed@google.com#include "SkRefDict.h" 258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2646799cd9f0bded51a189d77731b25af159ab4609reed@google.comclass SkClipStack; 278d84fac294682647694b0d2d8a87ac2bd19b6aabvandebo@chromium.orgclass SkDevice; 288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkDraw; 298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comstruct SkIRect; 308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkMatrix; 318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkRegion; 328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 338d84fac294682647694b0d2d8a87ac2bd19b6aabvandebo@chromium.org/** \class SkDeviceFactory 348d84fac294682647694b0d2d8a87ac2bd19b6aabvandebo@chromium.org 358d84fac294682647694b0d2d8a87ac2bd19b6aabvandebo@chromium.org Devices that extend SkDevice should also provide a SkDeviceFactory class 368d84fac294682647694b0d2d8a87ac2bd19b6aabvandebo@chromium.org to pass into SkCanvas. Doing so will eliminate the need to extend 378d84fac294682647694b0d2d8a87ac2bd19b6aabvandebo@chromium.org SkCanvas as well. 388d84fac294682647694b0d2d8a87ac2bd19b6aabvandebo@chromium.org*/ 39b70ae310bbdaa1b26786773aabce5548c1f48563vandebo@chromium.orgclass SkDeviceFactory { 408d84fac294682647694b0d2d8a87ac2bd19b6aabvandebo@chromium.orgpublic: 418c1d88dcfb978835779b6b5c5e7d1cbb78b6ca4dvandebo@chromium.org virtual ~SkDeviceFactory(); 42f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com virtual SkDevice* newDevice(SkCanvas*, SkBitmap::Config, int width, 43f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com int height, bool isOpaque, bool isLayer) = 0; 448d84fac294682647694b0d2d8a87ac2bd19b6aabvandebo@chromium.org}; 458d84fac294682647694b0d2d8a87ac2bd19b6aabvandebo@chromium.org 468d84fac294682647694b0d2d8a87ac2bd19b6aabvandebo@chromium.orgclass SkRasterDeviceFactory : public SkDeviceFactory { 478d84fac294682647694b0d2d8a87ac2bd19b6aabvandebo@chromium.orgpublic: 48f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com virtual SkDevice* newDevice(SkCanvas*, SkBitmap::Config, int width, 49f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com int height, bool isOpaque, bool isLayer); 508d84fac294682647694b0d2d8a87ac2bd19b6aabvandebo@chromium.org}; 518d84fac294682647694b0d2d8a87ac2bd19b6aabvandebo@chromium.org 528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkDevice : public SkRefCnt { 538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic: 54f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com SkDevice(SkCanvas*); 55f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com /** Construct a new device, extracting the width/height/config/isOpaque values from 56f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com the bitmap. If transferPixelOwnership is true, and the bitmap claims to own its 57f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com own pixels (getOwnsPixels() == true), then transfer this responsibility to the 58f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com device, and call setOwnsPixels(false) on the bitmap. 593dd42b3c87299ad17b4df93fe251f6f9362495dcreed@google.com 60f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com Subclasses may override the destructor, which is virtual, even though this class 61f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com doesn't have one. SkRefCnt does. 623dd42b3c87299ad17b4df93fe251f6f9362495dcreed@google.com 638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param bitmap A copy of this bitmap is made and stored in the device 648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 65f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com SkDevice(SkCanvas*, const SkBitmap& bitmap, bool forOffscreen); 668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 678d84fac294682647694b0d2d8a87ac2bd19b6aabvandebo@chromium.org virtual SkDeviceFactory* getDeviceFactory() { 688d84fac294682647694b0d2d8a87ac2bd19b6aabvandebo@chromium.org return SkNEW(SkRasterDeviceFactory); 698d84fac294682647694b0d2d8a87ac2bd19b6aabvandebo@chromium.org } 708d84fac294682647694b0d2d8a87ac2bd19b6aabvandebo@chromium.org 7135fc62b960db6739b19c59576085663796951e47vandebo@chromium.org enum Capabilities { 7235fc62b960db6739b19c59576085663796951e47vandebo@chromium.org kGL_Capability = 0x1, //!< mask indicating GL support 7335fc62b960db6739b19c59576085663796951e47vandebo@chromium.org kVector_Capability = 0x2, //!< mask indicating a vector representation 7435fc62b960db6739b19c59576085663796951e47vandebo@chromium.org kAll_Capabilities = 0x3 7535fc62b960db6739b19c59576085663796951e47vandebo@chromium.org }; 7635fc62b960db6739b19c59576085663796951e47vandebo@chromium.org virtual uint32_t getDeviceCapabilities() { return 0; } 7735fc62b960db6739b19c59576085663796951e47vandebo@chromium.org 788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Return the width of the device (in pixels). 798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 809b49dc0db8254e3dcdc2de4a1e0add4f8a7ac5a8vandebo@chromium.org virtual int width() const { return fBitmap.width(); } 818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Return the height of the device (in pixels). 828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 839b49dc0db8254e3dcdc2de4a1e0add4f8a7ac5a8vandebo@chromium.org virtual int height() const { return fBitmap.height(); } 846f8f292aa768869a9e85c314b124875f57504f2creed@google.com 856f8f292aa768869a9e85c314b124875f57504f2creed@google.com /** 866f8f292aa768869a9e85c314b124875f57504f2creed@google.com * Return the device's origin: its offset in device coordinates from 876f8f292aa768869a9e85c314b124875f57504f2creed@google.com * the default origin in its canvas' matrix/clip 886f8f292aa768869a9e85c314b124875f57504f2creed@google.com */ 896f8f292aa768869a9e85c314b124875f57504f2creed@google.com const SkIPoint& getOrigin() const { return fOrigin; } 906f8f292aa768869a9e85c314b124875f57504f2creed@google.com 918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Return the bitmap config of the device's pixels 928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkBitmap::Config config() const { return fBitmap.getConfig(); } 948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Returns true if the device's bitmap's config treats every pixels as 958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com implicitly opaque. 968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool isOpaque() const { return fBitmap.isOpaque(); } 983dd42b3c87299ad17b4df93fe251f6f9362495dcreed@google.com 998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Return the bounds of the device 1008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 1018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void getBounds(SkIRect* bounds) const; 1023dd42b3c87299ad17b4df93fe251f6f9362495dcreed@google.com 1038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Return true if the specified rectangle intersects the bounds of the 1048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com device. If sect is not NULL and there is an intersection, sect returns 1058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com the intersection. 1068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 1078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool intersects(const SkIRect& r, SkIRect* sect = NULL) const; 1088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Return the bitmap associated with this device. Call this each time you need 1108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com to access the bitmap, as it notifies the subclass to perform any flushing 1118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com etc. before you examine the pixels. 1128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param changePixels set to true if the caller plans to change the pixels 1138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the device's bitmap 1148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 1158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkBitmap& accessBitmap(bool changePixels); 1168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Helper to erase the entire device to the specified color (including 1188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com alpha). 1198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 1208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void eraseColor(SkColor eraseColor); 1218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Called when this device is installed into a Canvas. Balanaced by a call 1238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com to unlockPixels() when the device is removed from a Canvas. 1248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 1258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void lockPixels(); 1268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void unlockPixels(); 1278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 128f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com /** Return the device's associated texture, or NULL. If returned, it may be 129f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com drawn into another device 130f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com */ 131f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com virtual SkGpuTexture* accessTexture() { return NULL; } 132f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com 13346799cd9f0bded51a189d77731b25af159ab4609reed@google.com /** 13446799cd9f0bded51a189d77731b25af159ab4609reed@google.com * Called with the correct matrix and clip before this device is drawn 13546799cd9f0bded51a189d77731b25af159ab4609reed@google.com * to using those settings. If your subclass overrides this, be sure to 13646799cd9f0bded51a189d77731b25af159ab4609reed@google.com * call through to the base class as well. 13746799cd9f0bded51a189d77731b25af159ab4609reed@google.com * 13846799cd9f0bded51a189d77731b25af159ab4609reed@google.com * The clipstack is another view of the clip. It records the actual 13946799cd9f0bded51a189d77731b25af159ab4609reed@google.com * geometry that went into building the region. It is present for devices 14046799cd9f0bded51a189d77731b25af159ab4609reed@google.com * that want to parse it, but is not required: the region is a complete 14146799cd9f0bded51a189d77731b25af159ab4609reed@google.com * picture of the current clip. (i.e. if you regionize all of the geometry 14246799cd9f0bded51a189d77731b25af159ab4609reed@google.com * in the clipstack, you will arrive at an equivalent region to the one 14346799cd9f0bded51a189d77731b25af159ab4609reed@google.com * passed in). 1448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 14546799cd9f0bded51a189d77731b25af159ab4609reed@google.com virtual void setMatrixClip(const SkMatrix&, const SkRegion&, 14646799cd9f0bded51a189d77731b25af159ab4609reed@google.com const SkClipStack&); 1478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Called when this device gains focus (i.e becomes the current device 1498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com for drawing). 1508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 151d302f1401b3c9aea094804bad4e76de98782cfe8bsalomon@google.com virtual void gainFocus(SkCanvas*, const SkMatrix&, const SkRegion&, 152d302f1401b3c9aea094804bad4e76de98782cfe8bsalomon@google.com const SkClipStack&) {} 1533dd42b3c87299ad17b4df93fe251f6f9362495dcreed@google.com 154f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com /** Causes any deferred drawing to the device to be completed. 155f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com */ 156f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com virtual void flush() {} 157f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com 158f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com /** 159f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com * Copy the pixels from the device into bitmap. Returns true on success. 160f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com * If false is returned, then the bitmap parameter is left unchanged. 1613dd42b3c87299ad17b4df93fe251f6f9362495dcreed@google.com * The bitmap parameter is treated as output-only, and will be completely 1623dd42b3c87299ad17b4df93fe251f6f9362495dcreed@google.com * overwritten (if the method returns true). 163f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com */ 164f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com virtual bool readPixels(const SkIRect& srcRect, SkBitmap* bitmap); 165f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com 166f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com /** 167f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com * Similar to draw sprite, this method will copy the pixels in bitmap onto 168f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com * the device, with the top/left corner specified by (x, y). The pixel 169f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com * values in the device are completely replaced: there is no blending. 170f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com */ 171f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com virtual void writePixels(const SkBitmap& bitmap, int x, int y); 1728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** These are called inside the per-device-layer loop for each draw call. 1748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com When these are called, we have already applied any saveLayer operations, 1758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com and are handling any looping from the paint, and any effects from the 1768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com DrawFilter. 1778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 1788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void drawPaint(const SkDraw&, const SkPaint& paint); 1798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, size_t count, 1808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPoint[], const SkPaint& paint); 1818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void drawRect(const SkDraw&, const SkRect& r, 1828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPaint& paint); 1838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void drawPath(const SkDraw&, const SkPath& path, 184f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com const SkPaint& paint, 185f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com const SkMatrix* prePathMatrix = NULL, 186f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com bool pathIsMutable = false); 1878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void drawBitmap(const SkDraw&, const SkBitmap& bitmap, 188f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com const SkIRect* srcRectOrNull, 1898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkMatrix& matrix, const SkPaint& paint); 1908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void drawSprite(const SkDraw&, const SkBitmap& bitmap, 1918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com int x, int y, const SkPaint& paint); 1928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void drawText(const SkDraw&, const void* text, size_t len, 1938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkScalar x, SkScalar y, const SkPaint& paint); 1948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void drawPosText(const SkDraw&, const void* text, size_t len, 1958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkScalar pos[], SkScalar constY, 1968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com int scalarsPerPos, const SkPaint& paint); 1978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void drawTextOnPath(const SkDraw&, const void* text, size_t len, 1988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPath& path, const SkMatrix* matrix, 1998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPaint& paint); 200cd9d69b9ce7eb301a9fd8d91b9f95fd99b07bae5djsollen@google.com#ifdef ANDROID 201cd9d69b9ce7eb301a9fd8d91b9f95fd99b07bae5djsollen@google.com virtual void drawPosTextOnPath(const SkDraw& draw, const void* text, size_t len, 202cd9d69b9ce7eb301a9fd8d91b9f95fd99b07bae5djsollen@google.com const SkPoint pos[], const SkPaint& paint, 203cd9d69b9ce7eb301a9fd8d91b9f95fd99b07bae5djsollen@google.com const SkPath& path, const SkMatrix* matrix); 204cd9d69b9ce7eb301a9fd8d91b9f95fd99b07bae5djsollen@google.com#endif 2058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void drawVertices(const SkDraw&, SkCanvas::VertexMode, int vertexCount, 2068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPoint verts[], const SkPoint texs[], 2078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkColor colors[], SkXfermode* xmode, 2088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const uint16_t indices[], int indexCount, 2098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPaint& paint); 2108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void drawDevice(const SkDraw&, SkDevice*, int x, int y, 2118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const SkPaint&); 2128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2133636ed558fb2af5a48a9634efec55fd8a87c88d7reed@google.com /////////////////////////////////////////////////////////////////////////// 2143636ed558fb2af5a48a9634efec55fd8a87c88d7reed@google.com 2153636ed558fb2af5a48a9634efec55fd8a87c88d7reed@google.com SkRefDict& getRefDict() { return fRefDict; } 2163636ed558fb2af5a48a9634efec55fd8a87c88d7reed@google.com 217f67e4cf4c18cd228738a11372859ee0280bce1d7reed@google.com struct TextFlags { 218f67e4cf4c18cd228738a11372859ee0280bce1d7reed@google.com uint32_t fFlags; // SkPaint::getFlags() 219f67e4cf4c18cd228738a11372859ee0280bce1d7reed@google.com SkPaint::Hinting fHinting; 220f67e4cf4c18cd228738a11372859ee0280bce1d7reed@google.com }; 221f67e4cf4c18cd228738a11372859ee0280bce1d7reed@google.com 222f67e4cf4c18cd228738a11372859ee0280bce1d7reed@google.com /** 223f67e4cf4c18cd228738a11372859ee0280bce1d7reed@google.com * Device may filter the text flags for drawing text here. If it wants to 224f67e4cf4c18cd228738a11372859ee0280bce1d7reed@google.com * make a change to the specified values, it should write them into the 225f67e4cf4c18cd228738a11372859ee0280bce1d7reed@google.com * textflags parameter (output) and return true. If the paint is fine as 226f67e4cf4c18cd228738a11372859ee0280bce1d7reed@google.com * is, then ignore the textflags parameter and return false. 227f67e4cf4c18cd228738a11372859ee0280bce1d7reed@google.com * 228f67e4cf4c18cd228738a11372859ee0280bce1d7reed@google.com * The baseclass SkDevice filters based on its depth and blitters. 229f67e4cf4c18cd228738a11372859ee0280bce1d7reed@google.com */ 230f67e4cf4c18cd228738a11372859ee0280bce1d7reed@google.com virtual bool filterTextFlags(const SkPaint& paint, TextFlags*); 231f67e4cf4c18cd228738a11372859ee0280bce1d7reed@google.com 2328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprotected: 2338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Update as needed the pixel value in the bitmap, so that the caller can access 2348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com the pixels directly. Note: only the pixels field should be altered. The config/width/height/rowbytes 2358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com must remain unchanged. 2368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 2378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void onAccessBitmap(SkBitmap*); 2388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 239f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com SkPixelRef* getPixelRef() const { return fBitmap.pixelRef(); } 240f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com // just for subclasses, to assign a custom pixelref 241f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com SkPixelRef* setPixelRef(SkPixelRef* pr, size_t offset) { 242f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com fBitmap.setPixelRef(pr, offset); 243f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com return pr; 244f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com } 245f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com 2468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprivate: 2476f8f292aa768869a9e85c314b124875f57504f2creed@google.com friend class SkCanvas; 2486f8f292aa768869a9e85c314b124875f57504f2creed@google.com // just called by SkCanvas when built as a layer 2496f8f292aa768869a9e85c314b124875f57504f2creed@google.com void setOrigin(int x, int y) { fOrigin.set(x, y); } 2506f8f292aa768869a9e85c314b124875f57504f2creed@google.com 2513636ed558fb2af5a48a9634efec55fd8a87c88d7reed@google.com SkCanvas* fCanvas; 2523636ed558fb2af5a48a9634efec55fd8a87c88d7reed@google.com SkBitmap fBitmap; 2533636ed558fb2af5a48a9634efec55fd8a87c88d7reed@google.com SkRefDict fRefDict; 2546f8f292aa768869a9e85c314b124875f57504f2creed@google.com SkIPoint fOrigin; 2558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}; 2568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif 258