skia2/experimental/sksg/geometry/SkSGRect.h
Florin Malita 4aa4441186 Initial scene graph (SkSG)
Sketching a thin (as in close-to-skia-semantics) scene graph API, focused on
external animation, inval tracking and minimal repaint.

Only a few concrete classes/features so far:

* Rect/Color/Transform/Group
* basic inval tracking
* a trivial animated sample with inval visualization

Pretty much everything (especially naming) is volatile, so treat accordingly.

The interesting bits to review are likely in Node.{h,cpp} for inval and
SampleSGInval.cpp for usage.

Initial class hierarchy:

  * Node: invalidation/ancestors tracking
  |
   -- * RenderNode: onRender(SkCanvas)
  |   |
  |    -- * Draw (concrete): rendering a [geometry, paint] tuple
  |   |
  |    -- * Group (concrete): grouping multiple RenderNodes
  |   |
  |    -- * EffectNode: single-descendant effect wrapper
  |       |
  |        -- * Transform (concrete): transform effect
  |
   -- * PaintNode: onMakePaint()
  |   |
  |    -- * Color (concrete): SkColor paint wrapper
  |
   -- * GeometryNode: onComputeBounds(), onDraw(SkCanvas, SkPaint)
      |
       -- * Rect (concrete): SkRect wrapper

TBR=

Change-Id: Iacf9b773c181a7582ecd31ee968562f179d1aa1b
Reviewed-on: https://skia-review.googlesource.com/85502
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2017-12-21 20:56:32 +00:00

47 lines
991 B
C++

/*
* Copyright 2017 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkSGRect_DEFINED
#define SkSGRect_DEFINED
#include "SkSGGeometryNode.h"
#include "SkRect.h"
class SkCanvas;
class SkPaint;
namespace sksg {
/**
* Concrete Geometry node, wrapping an SkRect.
*/
class Rect : public GeometryNode {
public:
static sk_sp<Rect> Make() { return sk_sp<Rect>(new Rect(SkRect::MakeEmpty())); }
static sk_sp<Rect> Make(const SkRect& r) { return sk_sp<Rect>(new Rect(r)); }
SG_ATTRIBUTE(L, SkScalar, fRect.fLeft )
SG_ATTRIBUTE(T, SkScalar, fRect.fTop )
SG_ATTRIBUTE(R, SkScalar, fRect.fRight )
SG_ATTRIBUTE(B, SkScalar, fRect.fBottom)
protected:
void onDraw(SkCanvas*, const SkPaint&) const override;
SkRect onComputeBounds() const override;
private:
explicit Rect(const SkRect&);
SkRect fRect;
};
} // namespace sksg
#endif // SkSGRect_DEFINED