Skia
2D Graphics Library
SkDrawLooper.h
Go to the documentation of this file.
1 
2 /*
3  * Copyright 2011 The Android Open Source Project
4  *
5  * Use of this source code is governed by a BSD-style license that can be
6  * found in the LICENSE file.
7  */
8 
9 
10 #ifndef SkDrawLooper_DEFINED
11 #define SkDrawLooper_DEFINED
12 
14 #include "include/core/SkColor.h"
16 #include "include/core/SkPoint.h"
17 #include <functional> // std::function
18 
19 #ifndef SK_SUPPORT_LEGACY_DRAWLOOPER
20 #error "SkDrawLooper is unsupported"
21 #endif
22 
23 class SkArenaAlloc;
24 class SkCanvas;
25 class SkMatrix;
26 class SkPaint;
27 struct SkRect;
28 
33 public:
40  class SK_API Context {
41  public:
42  Context() {}
43  virtual ~Context() {}
44 
45  struct Info {
48 
49  void applyToCTM(SkMatrix* ctm) const;
50  void applyToCanvas(SkCanvas*) const;
51  };
52 
67  virtual bool next(Info*, SkPaint*) = 0;
68 
69  private:
70  Context(const Context&) = delete;
71  Context& operator=(const Context&) = delete;
72  };
73 
78  virtual Context* makeContext(SkArenaAlloc*) const = 0;
79 
90  bool canComputeFastBounds(const SkPaint& paint) const;
91  void computeFastBounds(const SkPaint& paint, const SkRect& src, SkRect* dst) const;
92 
93  struct BlurShadowRec {
98  };
108  virtual bool asABlurShadow(BlurShadowRec*) const;
109 
111  return kSkDrawLooper_Type;
112  }
113 
115  return kSkDrawLooper_Type;
116  }
117 
118  static sk_sp<SkDrawLooper> Deserialize(const void* data, size_t size,
119  const SkDeserialProcs* procs = nullptr) {
120  return sk_sp<SkDrawLooper>(static_cast<SkDrawLooper*>(
122  kSkDrawLooper_Type, data, size, procs).release()));
123  }
124 
125  void apply(SkCanvas* canvas, const SkPaint& paint,
126  std::function<void(SkCanvas*, const SkPaint&)>);
127 
128 protected:
130 
131 private:
132  using INHERITED = SkFlattenable;
133 };
134 
135 #endif
SkFlattenable.h
SkDrawLooper::getFlattenableType
SkFlattenable::Type getFlattenableType() const override
Definition: SkDrawLooper.h:114
SkDrawLooper::SkDrawLooper
SkDrawLooper()
Definition: SkDrawLooper.h:129
SkFlattenable::Deserialize
static sk_sp< SkFlattenable > Deserialize(Type, const void *data, size_t length, const SkDeserialProcs *procs=nullptr)
SkBlurTypes.h
SkDrawLooper::apply
void apply(SkCanvas *canvas, const SkPaint &paint, std::function< void(SkCanvas *, const SkPaint &)>)
SkFlattenable::Type
Type
Definition: SkFlattenable.h:28
SkDrawLooper::GetFlattenableType
static SkFlattenable::Type GetFlattenableType()
Definition: SkDrawLooper.h:110
SkDrawLooper::BlurShadowRec::fOffset
SkVector fOffset
Definition: SkDrawLooper.h:95
SkDrawLooper::asABlurShadow
virtual bool asABlurShadow(BlurShadowRec *) const
If this looper can be interpreted as having two layers, such that.
SkDrawLooper::Context::Info::applyToCTM
void applyToCTM(SkMatrix *ctm) const
sk_sp
Shared pointer class to wrap classes that support a ref()/unref() interface.
Definition: SkRefCnt.h:215
SkPoint
Definition: SkPoint.h:160
SkPaint
Definition: SkPaint.h:39
SK_API
#define SK_API
Definition: SkTypes.h:181
SkDrawLooper::Context::next
virtual bool next(Info *, SkPaint *)=0
Called in a loop on objects returned by SkDrawLooper::createContext().
SkDrawLooper::Context::Info::fApplyPostCTM
bool fApplyPostCTM
Definition: SkDrawLooper.h:47
SkDrawLooper::canComputeFastBounds
bool canComputeFastBounds(const SkPaint &paint) const
The fast bounds functions are used to enable the paint to be culled early in the drawing pipeline.
SkDrawLooper::Context::Info::fTranslate
SkVector fTranslate
Definition: SkDrawLooper.h:46
SkDrawLooper::Deserialize
static sk_sp< SkDrawLooper > Deserialize(const void *data, size_t size, const SkDeserialProcs *procs=nullptr)
Definition: SkDrawLooper.h:118
SkCanvas
Definition: SkCanvas.h:87
SkPoint.h
SkDrawLooper::Context::~Context
virtual ~Context()
Definition: SkDrawLooper.h:43
SkDrawLooper
Definition: SkDrawLooper.h:32
SkDrawLooper::Context
Holds state during a draw.
Definition: SkDrawLooper.h:40
SkDrawLooper::computeFastBounds
void computeFastBounds(const SkPaint &paint, const SkRect &src, SkRect *dst) const
SkDrawLooper::BlurShadowRec::fStyle
SkBlurStyle fStyle
Definition: SkDrawLooper.h:97
SkDrawLooper::BlurShadowRec::fSigma
SkScalar fSigma
Definition: SkDrawLooper.h:94
SkScalar
float SkScalar
Definition: SkScalar.h:16
SkDrawLooper::makeContext
virtual Context * makeContext(SkArenaAlloc *) const =0
Called right before something is being drawn.
SkDrawLooper::BlurShadowRec
Definition: SkDrawLooper.h:93
SkDrawLooper::Context::Context
Context()
Definition: SkDrawLooper.h:42
SkMatrix
Definition: SkMatrix.h:48
SkColor
uint32_t SkColor
32-bit ARGB color value, unpremultiplied.
Definition: SkColor.h:35
SkRect
Definition: SkRect.h:572
SkDeserialProcs
Definition: SkSerialProcs.h:61
SkDrawLooper::Context::Info::applyToCanvas
void applyToCanvas(SkCanvas *) const
SkDrawLooper::Context::Info
Definition: SkDrawLooper.h:45
SkColor.h
SkDrawLooper::BlurShadowRec::fColor
SkColor fColor
Definition: SkDrawLooper.h:96
SkBlurStyle
SkBlurStyle
Definition: SkBlurTypes.h:13
SkFlattenable
Definition: SkFlattenable.h:26