diff options
author | 2010-02-19 21:41:30 +0000 | |
---|---|---|
committer | 2010-02-19 21:41:30 +0000 | |
commit | da6fb3246a4f3e7e835f23b4834affb80bb613fa (patch) | |
tree | ff4f435c24668b6a3a23559d7355a07f14b5950b /include/utils | |
parent | 81dc331e65ba5a24d515c11890234dd205408c89 (diff) |
more layers extracted from webkit
git-svn-id: http://skia.googlecode.com/svn/trunk@503 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/utils')
-rw-r--r-- | include/utils/SkLayer.h | 108 |
1 files changed, 18 insertions, 90 deletions
diff --git a/include/utils/SkLayer.h b/include/utils/SkLayer.h index 36eccc7873..c97bf72680 100644 --- a/include/utils/SkLayer.h +++ b/include/utils/SkLayer.h @@ -26,33 +26,6 @@ #include "SkSize.h" class SkCanvas; -class SkPicture; - - -struct SkLength { - enum SkLengthType { Undefined, Auto, Relative, Percent, Fixed, Static, Intrinsic, MinIntrinsic }; - SkLengthType type; - SkScalar value; - SkLength() { - type = Undefined; - value = 0; - } - bool defined() const { - if (type == Undefined) - return false; - return true; - } - float calcFloatValue(float max) const { - switch (type) { - case Percent: - return (max * value) / 100.0f; - case Fixed: - return value; - default: - return value; - } - } -}; class SkLayer : public SkRefCnt { @@ -61,48 +34,21 @@ public: SkLayer(const SkLayer&); virtual ~SkLayer(); - // deprecated - void setTranslation(SkScalar x, SkScalar y) { m_translation.set(x, y); } - void setRotation(SkScalar a) { m_angleTransform = a; m_doRotation = true; } - void setScale(SkScalar x, SkScalar y) { m_scale.set(x, y); } - SkPoint position() const { return m_position; } - SkPoint translation() const { return m_translation; } - SkSize size() const { return m_size; } - SkRect bounds() const { - SkRect rect; - rect.set(m_position.fX, m_position.fY, - m_position.fX + m_size.width(), - m_position.fY + m_size.height()); - rect.offset(m_translation.fX, m_translation.fY); - return rect; - } - - const SkSize& getSize() const { return m_size; } - void setSize(SkScalar w, SkScalar h) { m_size.set(w, h); } - SkScalar getOpacity() const { return m_opacity; } - void setOpacity(SkScalar opacity) { m_opacity = opacity; } - + const SkSize& getSize() const { return m_size; } const SkPoint& getPosition() const { return m_position; } - void setPosition(SkScalar x, SkScalar y) { m_position.set(x, y); } - const SkPoint& getAnchorPoint() const { return m_anchorPoint; } - void setAnchorPoint(SkScalar x, SkScalar y) { m_anchorPoint.set(x, y); } - - virtual void setBackgroundColor(SkColor color) { m_backgroundColor = color; m_backgroundColorSet = true; } + const SkMatrix& getMatrix() const { return fMatrix; } + const SkMatrix& getChildrenMatrix() const { return fChildrenMatrix; } - void setFixedPosition(SkLength left, SkLength top, SkLength right, SkLength bottom) { - m_fixedLeft = left; - m_fixedTop = top; - m_fixedRight = right; - m_fixedBottom = bottom; - m_isFixed = true; - } + SkScalar getWidth() const { return m_size.width(); } + SkScalar getHeight() const { return m_size.height(); } - const SkMatrix& getMatrix() const { return fMatrix; } + void setOpacity(SkScalar opacity) { m_opacity = opacity; } + void setSize(SkScalar w, SkScalar h) { m_size.set(w, h); } + void setPosition(SkScalar x, SkScalar y) { m_position.set(x, y); } + void setAnchorPoint(SkScalar x, SkScalar y) { m_anchorPoint.set(x, y); } void setMatrix(const SkMatrix&); - - const SkMatrix& getChildrenMatrix() const { return fChildrenMatrix; } void setChildrenMatrix(const SkMatrix&); // children @@ -114,40 +60,22 @@ public: // paint method - virtual void draw(SkCanvas*, SkScalar opacity, const SkRect* viewPort); + void draw(SkCanvas*, SkScalar opacity); + void draw(SkCanvas* canvas) { + this->draw(canvas, SK_Scalar1); + } protected: - virtual void onSetupCanvas(SkCanvas*, SkScalar opacity, const SkRect*); - virtual void onDraw(SkCanvas*, SkScalar opacity, const SkRect* viewPort); + virtual void onDraw(SkCanvas*, SkScalar opacity); private: + SkScalar m_opacity; + SkSize m_size; + SkPoint m_position; + SkPoint m_anchorPoint; SkMatrix fMatrix; SkMatrix fChildrenMatrix; -public: - - bool m_doRotation; - bool m_isFixed; - bool m_backgroundColorSet; - - // layers properties - - SkScalar m_angleTransform; - SkScalar m_opacity; - - SkSize m_size; - SkPoint m_position; - SkPoint m_translation; - SkPoint m_anchorPoint; - SkPoint m_scale; - - SkLength m_fixedLeft; - SkLength m_fixedTop; - SkLength m_fixedRight; - SkLength m_fixedBottom; - - SkColor m_backgroundColor; - SkTDArray<SkLayer*> m_children; }; |