Skia
2DGraphicsLibrary
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SkDrawable.h
1 /*
2  * Copyright 2014 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #ifndef SkDrawable_DEFINED
9 #define SkDrawable_DEFINED
10 
11 #include "SkFlattenable.h"
12 #include "SkScalar.h"
13 
14 class SkCanvas;
15 class SkMatrix;
16 class SkPicture;
17 struct SkRect;
18 
26 class SkDrawable : public SkFlattenable {
27 public:
28  SkDrawable();
29 
35  void draw(SkCanvas*, const SkMatrix* = NULL);
36  void draw(SkCanvas*, SkScalar x, SkScalar y);
37 
38  SkPicture* newPictureSnapshot();
39 
47  uint32_t getGenerationID();
48 
54  SkRect getBounds();
55 
61  void notifyDrawingChanged();
62 
63  SK_DEFINE_FLATTENABLE_TYPE(SkDrawable)
64  Factory getFactory() const override { return nullptr; }
65 
66 protected:
67  virtual SkRect onGetBounds() = 0;
68  virtual void onDraw(SkCanvas*) = 0;
69 
77 
78 private:
79  int32_t fGenerationID;
80 };
81 
82 #endif
void notifyDrawingChanged()
Calling this invalidates the previous generation ID, and causes a new one to be computed the next tim...
void draw(SkCanvas *, const SkMatrix *=NULL)
Draws into the specified content.
A Canvas encapsulates all of the state about drawing into a device (bitmap).
Definition: SkCanvas.h:59
The SkMatrix class holds a 3x3 matrix for transforming coordinates.
Definition: SkMatrix.h:28
Factory getFactory() const override
Implement this to return a factory function pointer that can be called to recreate your class given a...
Definition: SkDrawable.h:64
An SkPicture records drawing commands made to a canvas to be played back at a later time...
Definition: SkPicture.h:38
SkFlattenable is the base class for objects that need to be flattened into a data stream for either t...
Definition: SkFlattenable.h:70
Base-class for objects that draw into SkCanvas.
Definition: SkDrawable.h:26
uint32_t getGenerationID()
Return a unique value for this instance.
Definition: SkRect.h:404
SkRect getBounds()
Return the (conservative) bounds of what the drawable will draw.
virtual SkPicture * onNewPictureSnapshot()
Default implementation calls onDraw() with a canvas that records into a picture.