Home | History | Annotate | Download | only in core
      1 /*
      2  * Copyright 2016 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 SkLiteDL_DEFINED
      9 #define SkLiteDL_DEFINED
     10 
     11 #include "SkCanvas.h"
     12 #include "SkPaint.h"
     13 #include "SkPath.h"
     14 #include "SkDrawable.h"
     15 #include "SkRect.h"
     16 #include "SkTDArray.h"
     17 #include "SkTemplates.h"
     18 
     19 class SkLiteDL final {
     20 public:
     21     ~SkLiteDL();
     22 
     23     void draw(SkCanvas* canvas) const;
     24 
     25     void reset();
     26     bool empty() const { return fUsed == 0; }
     27 
     28     void flush();
     29 
     30     void save();
     31     void saveLayer(const SkRect*, const SkPaint*, const SkImageFilter*, const SkImage*,
     32                    const SkMatrix*, SkCanvas::SaveLayerFlags);
     33     void saveBehind(const SkRect*);
     34     void restore();
     35 
     36     void    concat (const SkMatrix&);
     37     void setMatrix (const SkMatrix&);
     38     void translate(SkScalar, SkScalar);
     39     void translateZ(SkScalar);
     40 
     41     void clipPath  (const   SkPath&, SkClipOp, bool aa);
     42     void clipRect  (const   SkRect&, SkClipOp, bool aa);
     43     void clipRRect (const  SkRRect&, SkClipOp, bool aa);
     44     void clipRegion(const SkRegion&, SkClipOp);
     45 
     46     void drawPaint (const SkPaint&);
     47     void drawBehind(const SkPaint&);
     48     void drawPath  (const SkPath&, const SkPaint&);
     49     void drawRect  (const SkRect&, const SkPaint&);
     50     void drawEdgeAARect(const SkRect&, SkCanvas::QuadAAFlags, SkColor, SkBlendMode);
     51     void drawRegion(const SkRegion&, const SkPaint&);
     52     void drawOval  (const SkRect&, const SkPaint&);
     53     void drawArc   (const SkRect&, SkScalar, SkScalar, bool, const SkPaint&);
     54     void drawRRect (const SkRRect&, const SkPaint&);
     55     void drawDRRect(const SkRRect&, const SkRRect&, const SkPaint&);
     56 
     57     void drawAnnotation     (const SkRect&, const char*, SkData*);
     58     void drawDrawable       (SkDrawable*, const SkMatrix*);
     59     void drawPicture        (const SkPicture*, const SkMatrix*, const SkPaint*);
     60 
     61     void drawTextBlob   (const SkTextBlob*, SkScalar,SkScalar, const SkPaint&);
     62 
     63     void drawImage    (sk_sp<const SkImage>, SkScalar,SkScalar,             const SkPaint*);
     64     void drawImageNine(sk_sp<const SkImage>, const SkIRect&, const SkRect&, const SkPaint*);
     65     void drawImageRect(sk_sp<const SkImage>, const SkRect*, const SkRect&,  const SkPaint*,
     66                        SkCanvas::SrcRectConstraint);
     67     void drawImageLattice(sk_sp<const SkImage>, const SkCanvas::Lattice&,
     68                           const SkRect&, const SkPaint*);
     69     void drawImageSet(const SkCanvas::ImageSetEntry[], int count, SkFilterQuality, SkBlendMode);
     70 
     71     void drawPatch(const SkPoint[12], const SkColor[4], const SkPoint[4],
     72                    SkBlendMode, const SkPaint&);
     73     void drawPoints(SkCanvas::PointMode, size_t, const SkPoint[], const SkPaint&);
     74     void drawVertices(const SkVertices*, const SkVertices::Bone bones[], int boneCount, SkBlendMode,
     75                       const SkPaint&);
     76     void drawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], int,
     77                    SkBlendMode, const SkRect*, const SkPaint*);
     78     void drawShadowRec(const SkPath&, const SkDrawShadowRec&);
     79 
     80 private:
     81     template <typename T, typename... Args>
     82     void* push(size_t, Args&&...);
     83 
     84     template <typename Fn, typename... Args>
     85     void map(const Fn[], Args...) const;
     86 
     87     SkAutoTMalloc<uint8_t> fBytes;
     88     size_t                 fUsed = 0;
     89     size_t                 fReserved = 0;
     90 };
     91 
     92 #endif//SkLiteDL_DEFINED
     93