| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SkCanvas_DEFINED | 8 #ifndef SkCanvas_DEFINED |
| 9 #define SkCanvas_DEFINED | 9 #define SkCanvas_DEFINED |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 class SkBaseDevice; | 22 class SkBaseDevice; |
| 23 class SkCanvasClipVisitor; | 23 class SkCanvasClipVisitor; |
| 24 class SkDraw; | 24 class SkDraw; |
| 25 class SkDrawable; | 25 class SkDrawable; |
| 26 class SkDrawFilter; | 26 class SkDrawFilter; |
| 27 class SkImage; | 27 class SkImage; |
| 28 class SkMetaData; | 28 class SkMetaData; |
| 29 class SkPicture; | 29 class SkPicture; |
| 30 class SkRRect; | 30 class SkRRect; |
| 31 class SkSurface; | 31 class SkSurface; |
| 32 class SkSurface_Base; | |
| 33 class SkTextBlob; | 32 class SkTextBlob; |
| 34 class GrContext; | 33 class GrContext; |
| 35 class GrRenderTarget; | 34 class GrRenderTarget; |
| 36 | 35 |
| 37 class SkCanvasState; | 36 class SkCanvasState; |
| 38 | 37 |
| 39 /** \class SkCanvas | 38 /** \class SkCanvas |
| 40 | 39 |
| 41 A Canvas encapsulates all of the state about drawing into a device (bitmap). | 40 A Canvas encapsulates all of the state about drawing into a device (bitmap). |
| 42 This includes a reference to the device itself, and a stack of matrix/clip | 41 This includes a reference to the device itself, and a stack of matrix/clip |
| (...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 | 590 |
| 592 /** | 591 /** |
| 593 * Helper method for drawing a color in SRC mode, completely replacing all
the pixels | 592 * Helper method for drawing a color in SRC mode, completely replacing all
the pixels |
| 594 * in the current clip with this color. | 593 * in the current clip with this color. |
| 595 */ | 594 */ |
| 596 void clear(SkColor color) { | 595 void clear(SkColor color) { |
| 597 this->drawColor(color, SkXfermode::kSrc_Mode); | 596 this->drawColor(color, SkXfermode::kSrc_Mode); |
| 598 } | 597 } |
| 599 | 598 |
| 600 /** | 599 /** |
| 601 * This makes the contents of the canvas undefined. Subsequent calls that | 600 * This makes the contents of current layer of the canvas |
| 602 * require reading the canvas contents will produce undefined results. Examp
les | 601 * undefined. Subsequent calls that require reading the canvas contents will |
| 603 * include blending and readPixels. The actual implementation is backend- | 602 * produce undefined results. Examples include blending and readPixels. The |
| 604 * dependent and one legal implementation is to do nothing. Like clear(), th
is | 603 * actual implementation is backend- dependent and one legal implementation |
| 605 * ignores the clip. | 604 * is to do nothing. Like clear(), this ignores the clip. |
| 606 * | 605 * |
| 607 * This function should only be called if the caller intends to subsequently | 606 * This function should only be called if the caller intends to subsequently |
| 608 * draw to the canvas. The canvas may do real work at discard() time in orde
r | 607 * draw to the current layer. The canvas may do real work at discard() time
in order |
| 609 * to optimize performance on subsequent draws. Thus, if you call this and t
hen | 608 * to optimize performance on subsequent draws. Thus, if you call this and t
hen |
| 610 * never draw to the canvas subsequently you may pay a perfomance penalty. | 609 * never draw to the canvas subsequently you may pay a perfomance penalty. |
| 611 */ | 610 */ |
| 612 void discard() { this->onDiscard(); } | 611 void discard() { this->onDiscard(); } |
| 613 | 612 |
| 614 /** | 613 /** |
| 615 * Fill the entire canvas' bitmap (restricted to the current clip) with the | 614 * Fill the entire canvas' bitmap (restricted to the current clip) with the |
| 616 * specified paint. | 615 * specified paint. |
| 617 * @param paint The paint used to fill the canvas | 616 * @param paint The paint used to fill the canvas |
| 618 */ | 617 */ |
| (...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1237 virtual SkCanvas* canvasForDrawIter(); | 1236 virtual SkCanvas* canvasForDrawIter(); |
| 1238 | 1237 |
| 1239 // Clip rectangle bounds. Called internally by saveLayer. | 1238 // Clip rectangle bounds. Called internally by saveLayer. |
| 1240 // returns false if the entire rectangle is entirely clipped out | 1239 // returns false if the entire rectangle is entirely clipped out |
| 1241 // If non-NULL, The imageFilter parameter will be used to expand the clip | 1240 // If non-NULL, The imageFilter parameter will be used to expand the clip |
| 1242 // and offscreen bounds for any margin required by the filter DAG. | 1241 // and offscreen bounds for any margin required by the filter DAG. |
| 1243 bool clipRectBounds(const SkRect* bounds, SaveFlags flags, | 1242 bool clipRectBounds(const SkRect* bounds, SaveFlags flags, |
| 1244 SkIRect* intersection, | 1243 SkIRect* intersection, |
| 1245 const SkImageFilter* imageFilter = NULL); | 1244 const SkImageFilter* imageFilter = NULL); |
| 1246 | 1245 |
| 1247 // notify our surface (if we have one) that we are about to draw, so it | |
| 1248 // can perform copy-on-write or invalidate any cached images | |
| 1249 void predrawNotify(); | |
| 1250 | |
| 1251 private: | 1246 private: |
| 1252 class MCRec; | 1247 class MCRec; |
| 1253 | 1248 |
| 1254 SkAutoTUnref<SkClipStack> fClipStack; | 1249 SkAutoTUnref<SkClipStack> fClipStack; |
| 1255 SkDeque fMCStack; | 1250 SkDeque fMCStack; |
| 1256 // points to top of stack | 1251 // points to top of stack |
| 1257 MCRec* fMCRec; | 1252 MCRec* fMCRec; |
| 1258 // the first N recs that can fit here mean we won't call malloc | 1253 // the first N recs that can fit here mean we won't call malloc |
| 1259 uint32_t fMCRecStorage[32]; | 1254 uint32_t fMCRecStorage[32]; |
| 1260 | 1255 |
| 1261 const SkSurfaceProps fProps; | 1256 const SkSurfaceProps fProps; |
| 1262 | 1257 |
| 1263 int fSaveCount; // value returned by getSaveCount() | 1258 int fSaveCount; // value returned by getSaveCount() |
| 1264 | 1259 |
| 1265 SkMetaData* fMetaData; | 1260 SkMetaData* fMetaData; |
| 1266 | 1261 |
| 1267 SkSurface_Base* fSurfaceBase; | |
| 1268 SkSurface_Base* getSurfaceBase() const { return fSurfaceBase; } | |
| 1269 void setSurfaceBase(SkSurface_Base* sb) { | |
| 1270 fSurfaceBase = sb; | |
| 1271 } | |
| 1272 friend class SkSurface_Base; | 1262 friend class SkSurface_Base; |
| 1273 friend class SkSurface_Gpu; | 1263 friend class SkSurface_Gpu; |
| 1274 | 1264 |
| 1275 bool fDeviceCMDirty; // cleared by updateDeviceCMCache() | 1265 bool fDeviceCMDirty; // cleared by updateDeviceCMCache() |
| 1276 void updateDeviceCMCache(); | 1266 void updateDeviceCMCache(); |
| 1277 | 1267 |
| 1278 void doSave(); | 1268 void doSave(); |
| 1279 void checkForDeferredSave(); | 1269 void checkForDeferredSave(); |
| 1280 | 1270 |
| 1281 friend class SkDrawIter; // needs setupDrawForLayerDevice() | 1271 friend class SkDrawIter; // needs setupDrawForLayerDevice() |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1491 | 1481 |
| 1492 class SkCanvasClipVisitor { | 1482 class SkCanvasClipVisitor { |
| 1493 public: | 1483 public: |
| 1494 virtual ~SkCanvasClipVisitor(); | 1484 virtual ~SkCanvasClipVisitor(); |
| 1495 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; | 1485 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; |
| 1496 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; | 1486 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; |
| 1497 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; | 1487 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; |
| 1498 }; | 1488 }; |
| 1499 | 1489 |
| 1500 #endif | 1490 #endif |
| OLD | NEW |