Index: sky/engine/core/painting/PaintingContext.cpp |
diff --git a/sky/engine/core/painting/PaintingContext.cpp b/sky/engine/core/painting/PaintingContext.cpp |
index 0bac4898e52ba248bbd421c8bbed01ef0073a218..f2cdde77244a6805e580cbec593dab1a56d5a593 100644 |
--- a/sky/engine/core/painting/PaintingContext.cpp |
+++ b/sky/engine/core/painting/PaintingContext.cpp |
@@ -13,6 +13,14 @@ |
namespace blink { |
+SkRect toSkRect(Vector<float> rect) |
+{ |
+ ASSERT(rect.size() == 4); |
+ SkRect sk_rect; |
+ sk_rect.set(rect[0], rect[1], rect[2], rect[3]); |
+ return sk_rect; |
+} |
+ |
PassRefPtr<PaintingContext> PaintingContext::create(PassRefPtr<Element> element, const FloatSize& size) |
{ |
return adoptRef(new PaintingContext(element, size)); |
@@ -30,6 +38,112 @@ PaintingContext::~PaintingContext() |
{ |
} |
+void PaintingContext::save() |
+{ |
+ if (!m_canvas) |
+ return; |
+ ASSERT(m_displayList->isRecording()); |
+ m_canvas->save(); |
+} |
+ |
+void PaintingContext::saveLayer(Vector<float> bounds, Paint* paint) |
+{ |
+ if (!m_canvas) |
+ return; |
+ ASSERT(m_displayList->isRecording()); |
+ SkRect sk_bounds; |
+ if (bounds.size() != 0) |
+ sk_bounds = toSkRect(bounds); |
+ m_canvas->saveLayer(bounds.size() != 0 ? &sk_bounds : nullptr, |
+ paint ? &paint->paint() : nullptr); |
+} |
+ |
+void PaintingContext::restore() |
+{ |
+ if (!m_canvas) |
+ return; |
+ ASSERT(m_displayList->isRecording()); |
+ m_canvas->restore(); |
+} |
+ |
+void PaintingContext::translate(float dx, float dy) |
+{ |
+ if (!m_canvas) |
+ return; |
+ ASSERT(m_displayList->isRecording()); |
+ m_canvas->translate(dx, dy); |
+} |
+ |
+void PaintingContext::scale(float sx, float sy) |
+{ |
+ if (!m_canvas) |
+ return; |
+ ASSERT(m_displayList->isRecording()); |
+ m_canvas->scale(sx, sy); |
+} |
+ |
+void PaintingContext::rotate(float degrees) |
+{ |
+ if (!m_canvas) |
+ return; |
+ ASSERT(m_displayList->isRecording()); |
+ m_canvas->rotate(degrees); |
+} |
+ |
+void PaintingContext::skew(float sx, float sy) |
+{ |
+ if (!m_canvas) |
+ return; |
+ ASSERT(m_displayList->isRecording()); |
+ m_canvas->skew(sx, sy); |
+} |
+ |
+void PaintingContext::concat(Vector<float> matrix) |
+{ |
+ if (!m_canvas) |
+ return; |
+ ASSERT(m_displayList->isRecording()); |
+ ASSERT(matrix.size() == 9); |
+ SkMatrix sk_matrix; |
+ sk_matrix.set9(matrix.data()); |
+ m_canvas->concat(sk_matrix); |
+} |
+ |
+void PaintingContext::clipRect(Vector<float> rect) |
+{ |
+ if (!m_canvas) |
+ return; |
+ ASSERT(m_displayList->isRecording()); |
+ m_canvas->clipRect(toSkRect(rect)); |
+} |
+ |
+void PaintingContext::drawPaint(Paint* paint) |
+{ |
+ if (!m_canvas) |
+ return; |
+ ASSERT(paint); |
+ ASSERT(m_displayList->isRecording()); |
+ m_canvas->drawPaint(paint->paint()); |
+} |
+ |
+void PaintingContext::drawOval(Vector<float> rect, Paint* paint) |
+{ |
+ if (!m_canvas) |
+ return; |
+ ASSERT(paint); |
+ ASSERT(m_displayList->isRecording()); |
+ m_canvas->drawOval(toSkRect(rect), paint->paint()); |
+} |
+ |
+void PaintingContext::drawRect(Vector<float> rect, Paint* paint) |
+{ |
+ if (!m_canvas) |
+ return; |
+ ASSERT(paint); |
+ ASSERT(m_displayList->isRecording()); |
+ m_canvas->drawRect(toSkRect(rect), paint->paint()); |
+} |
+ |
void PaintingContext::drawCircle(double x, double y, double radius, Paint* paint) |
{ |
if (!m_canvas) |