[sksg] Add 'plane' geometry node

SG geometry corresponding to SkCanvas::drawPaint().

TBR=

Change-Id: I3b368adda187fb92f524756496a3694c03a3113d
Reviewed-on: https://skia-review.googlesource.com/108562
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
This commit is contained in:
Florin Malita 2018-02-20 11:26:15 -05:00 committed by Skia Commit-Bot
parent 2a552179cc
commit 97b3d2bcdb
4 changed files with 79 additions and 1 deletions

View File

@ -1401,6 +1401,7 @@ if (skia_enable_tools) {
"experimental/sksg/geometry/SkSGGeometryTransform.cpp",
"experimental/sksg/geometry/SkSGMerge.cpp",
"experimental/sksg/geometry/SkSGPath.cpp",
"experimental/sksg/geometry/SkSGPlane.cpp",
"experimental/sksg/geometry/SkSGRect.cpp",
"experimental/sksg/geometry/SkSGText.cpp",
"experimental/sksg/geometry/SkSGTrimEffect.cpp",

View File

@ -0,0 +1,36 @@
/*
* Copyright 2018 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "SkSGPlane.h"
#include "SkCanvas.h"
#include "SkPath.h"
namespace sksg {
Plane::Plane() = default;
void Plane::onClip(SkCanvas*, bool) const {}
void Plane::onDraw(SkCanvas* canvas, const SkPaint& paint) const {
canvas->drawPaint(paint);
}
SkRect Plane::onRevalidate(InvalidationController*, const SkMatrix&) {
SkASSERT(this->hasInval());
return SkRect::MakeLTRB(SK_ScalarMin, SK_ScalarMin, SK_ScalarMax, SK_ScalarMax);
}
SkPath Plane::onAsPath() const {
SkPath path;
path.setFillType(SkPath::kInverseWinding_FillType);
return path;
}
} // namespace sksg

View File

@ -0,0 +1,40 @@
/*
* Copyright 2018 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkSGPlane_DEFINED
#define SkSGPlane_DEFINED
#include "SkSGGeometryNode.h"
class SkCanvas;
class SkPaint;
namespace sksg {
/**
* Concrete Geometry node, representing the whole canvas.
*/
class Plane final : public GeometryNode {
public:
static sk_sp<Plane> Make() { return sk_sp<Plane>(new Plane()); }
protected:
void onClip(SkCanvas*, bool antiAlias) const override;
void onDraw(SkCanvas*, const SkPaint&) const override;
SkRect onRevalidate(InvalidationController*, const SkMatrix&) override;
SkPath onAsPath() const override;
private:
Plane();
using INHERITED = GeometryNode;
};
} // namespace sksg
#endif // SkSGPlane_DEFINED

View File

@ -14,6 +14,7 @@
#include "SkSGColor.h"
#include "SkSGDraw.h"
#include "SkSGGroup.h"
#include "SkSGPlane.h"
#include "SkSGRect.h"
#include "SkSGRenderNode.h"
#include "SkSGScene.h"
@ -110,7 +111,7 @@ public:
fMap.setPts(kFocusCtrl1, kFocusCtrl0);
fShadePaint = sksg::Color::Make(kFocusShade);
fShade = sksg::Draw::Make(sksg::Rect::Make(SkRect::MakeSize(dir->fWinSize)), fShadePaint);
fShade = sksg::Draw::Make(sksg::Plane::Make(), fShadePaint);
}
bool hasFocus() const { return fState == State::kFocused; }