diff options
-rw-r--r-- | WebCore/platform/graphics/android/LayerAndroid.cpp | 64 | ||||
-rw-r--r-- | WebCore/platform/graphics/android/LayerAndroid.h | 7 | ||||
-rw-r--r-- | WebCore/platform/graphics/android/SkLayer.h | 16 |
3 files changed, 58 insertions, 29 deletions
diff --git a/WebCore/platform/graphics/android/LayerAndroid.cpp b/WebCore/platform/graphics/android/LayerAndroid.cpp index d5c5442..14b9a96 100644 --- a/WebCore/platform/graphics/android/LayerAndroid.cpp +++ b/WebCore/platform/graphics/android/LayerAndroid.cpp @@ -200,7 +200,7 @@ void LayerAndroid::paintChildren(int scrollX, int scrollY, float scale, SkCanvas* canvas, float opacity) { - canvas->save(); + int count = canvas->save(); if (m_haveClip) setClip(canvas); @@ -219,7 +219,42 @@ void LayerAndroid::paintChildren(int scrollX, int scrollY, } } - canvas->restore(); + canvas->restoreToCount(count); +} + +void LayerAndroid::calcPosition(int scrollX, + int scrollY, + int viewWidth, + int viewHeight, + float scale, + float* xPtr, + float* yPtr) +{ + float x = 0; + float y = 0; + if (m_isFixed) { + float w = viewWidth / scale; + float h = viewHeight / scale; + float dx = scrollX / scale; + float dy = scrollY / scale; + + if (m_fixedLeft.defined()) + x = dx + m_fixedLeft.calcFloatValue(w); + else if (m_fixedRight.defined()) + x = dx + w - m_fixedRight.calcFloatValue(w) - m_size.width(); + + if (m_fixedTop.defined()) + y = dy + m_fixedTop.calcFloatValue(h); + else if (m_fixedBottom.defined()) + y = dy + h - m_fixedBottom.calcFloatValue(h) - m_size.height(); + + m_position.set(x - m_translation.fX, y - m_translation.fY); + } else { + x = m_translation.fX + m_position.fX; + y = m_translation.fY + m_position.fY; + } + if (xPtr) *xPtr = x; + if (yPtr) *yPtr = y; } void LayerAndroid::paintMe(int scrollX, @@ -252,29 +287,8 @@ void LayerAndroid::paintMe(int scrollX, paintMode.setXfermodeMode(SkXfermode::kSrc_Mode); */ - float x = 0; - float y = 0; - if (m_isFixed) { - float w = viewWidth / scale; - float h = viewHeight / scale; - float dx = scrollX / scale; - float dy = scrollY / scale; - - if (m_fixedLeft.defined()) - x = dx + m_fixedLeft.calcFloatValue(w); - else if (m_fixedRight.defined()) - x = dx + w - m_fixedRight.calcFloatValue(w) - m_size.width(); - - if (m_fixedTop.defined()) - y = dy + m_fixedTop.calcFloatValue(h); - else if (m_fixedBottom.defined()) - y = dy + h - m_fixedBottom.calcFloatValue(h) - m_size.height(); - - } else { - x = m_translation.fX + m_position.fX; - y = m_translation.fY + m_position.fY; - } - + float x, y; + calcPosition(scrollX, scrollY, viewWidth, viewHeight, scale, &x, &y); canvas->translate(x, y); if (m_doRotation) { diff --git a/WebCore/platform/graphics/android/LayerAndroid.h b/WebCore/platform/graphics/android/LayerAndroid.h index 06f1a74..911a2f9 100644 --- a/WebCore/platform/graphics/android/LayerAndroid.h +++ b/WebCore/platform/graphics/android/LayerAndroid.h @@ -73,6 +73,13 @@ public: bool evaluateAnimations(double time) const; bool hasAnimations() const; + void calcPosition(int scrollX, int scrollY, int viewWidth, int viewHeight, + float scale, float* xPtr, float* yPtr); + + SkPicture* picture() const { return m_recordingPicture; } + const LayerAndroid* child(unsigned i) const { return m_children[i].get(); } + unsigned childCount() const { return m_children.size(); } + private: void paintChildren(int scrollX, int scrollY, diff --git a/WebCore/platform/graphics/android/SkLayer.h b/WebCore/platform/graphics/android/SkLayer.h index 39f04f4..3e6f4d2 100644 --- a/WebCore/platform/graphics/android/SkLayer.h +++ b/WebCore/platform/graphics/android/SkLayer.h @@ -35,7 +35,7 @@ struct SkLength { type = Undefined; value = 0; } - bool defined() { + bool defined() const { if (type == Undefined) return false; return true; @@ -93,9 +93,17 @@ public: // getters - SkPoint position() { return m_position; } - SkPoint translation() { return m_translation; } - SkSize size() { return m_size; } + 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; + } // paint method |