Skia
2DGraphicsLibrary
 All Classes 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 
13 class SkCanvas;
14 class SkMatrix;
15 class SkPicture;
16 struct SkRect;
17 
25 class SkDrawable : public SkFlattenable {
26 public:
27  SkDrawable();
28 
34  void draw(SkCanvas*, const SkMatrix* = NULL);
35  void draw(SkCanvas*, SkScalar x, SkScalar y);
36 
37  SkPicture* newPictureSnapshot();
38 
46  uint32_t getGenerationID();
47 
53  SkRect getBounds();
54 
60  void notifyDrawingChanged();
61 
62  SK_DEFINE_FLATTENABLE_TYPE(SkDrawable)
63  Factory getFactory() const override { return nullptr; }
64 
65 protected:
66  virtual SkRect onGetBounds() = 0;
67  virtual void onDraw(SkCanvas*) = 0;
68 
76 
77 private:
78  int32_t fGenerationID;
79 };
80 
81 #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:58
The SkMatrix class holds a 3x3 matrix for transforming coordinates.
Definition: SkMatrix.h:26
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:63
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:25
uint32_t getGenerationID()
Return a unique value for this instance.
Definition: SkRect.h:390
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.