Index: Source/core/paint/TranslationRecorder.cpp |
diff --git a/Source/core/paint/TranslationRecorder.cpp b/Source/core/paint/TranslationRecorder.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..19450f0787c7bfb158a65c1c8fbe9ff78afa0107 |
--- /dev/null |
+++ b/Source/core/paint/TranslationRecorder.cpp |
@@ -0,0 +1,43 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "config.h" |
+#include "core/paint/TranslationRecorder.h" |
+ |
+#include "platform/RuntimeEnabledFeatures.h" |
+#include "platform/graphics/GraphicsContext.h" |
+ |
+namespace blink { |
+ |
+void TranslationDisplayItem::replay(GraphicsContext* context) |
chrishtr
2014/11/01 23:44:11
Scale, rotate and translate are just convenience w
trchen
2014/11/02 10:36:46
That makes sense. I was thinking that 2D translati
|
+{ |
+ context->translate(m_translation.width(), m_translation.height()); |
+} |
+ |
+TranslationRecorder::TranslationRecorder(RenderObject* renderer, GraphicsContext* context, const FloatSize& translation) |
+ : m_renderer(renderer) |
+ , m_context(context) |
+ , m_translation(translation) |
+{ |
+ if (m_translation.isZero()) |
+ return; |
+ |
+ if (RuntimeEnabledFeatures::slimmingPaintEnabled()) |
+ ViewDisplayList::fromRenderObject(m_renderer).add(adoptPtr(new TranslationDisplayItem(m_translation))); |
+ else |
+ context->translate(m_translation.width(), m_translation.height()); |
+} |
+ |
+TranslationRecorder::~TranslationRecorder() |
+{ |
+ if (m_translation.isZero()) |
+ return; |
+ |
+ if (RuntimeEnabledFeatures::slimmingPaintEnabled()) |
+ ViewDisplayList::fromRenderObject(m_renderer).add(adoptPtr(new EndTranslationDisplayItem(m_translation))); |
+ else |
+ m_context->translate(-m_translation.width(), -m_translation.height()); |
+} |
+ |
+} // namespace blink |