Index: webkit/compositor_bindings/web_layer_impl_fixed_bounds.h |
diff --git a/webkit/compositor_bindings/web_layer_impl_fixed_bounds.h b/webkit/compositor_bindings/web_layer_impl_fixed_bounds.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..2e83a4415c02dd114b0d4605a3c9fb57ff369d79 |
--- /dev/null |
+++ b/webkit/compositor_bindings/web_layer_impl_fixed_bounds.h |
@@ -0,0 +1,52 @@ |
+// Copyright 2013 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. |
+ |
+#ifndef WebLayerImplFixedBounds_h |
+#define WebLayerImplFixedBounds_h |
+ |
+#include "ui/gfx/size.h" |
+#include "ui/gfx/transform.h" |
+#include "webkit/compositor_bindings/web_layer_impl.h" |
+ |
+namespace WebKit { |
+ |
+// A special implementation of WebLayerImpl for layers that its contents |
+// need to be automatically scaled when the bounds changes. The compositor |
+// can efficiently handle the bounds change of such layers if the bounds |
+// is fixed to a given value and the change of bounds are converted to |
+// transformation scales. |
+class WebLayerImplFixedBounds : public WebLayerImpl { |
+public: |
+ WEBKIT_COMPOSITOR_BINDINGS_EXPORT WebLayerImplFixedBounds(); |
+ WEBKIT_COMPOSITOR_BINDINGS_EXPORT explicit WebLayerImplFixedBounds(scoped_refptr<cc::Layer>); |
+ virtual ~WebLayerImplFixedBounds(); |
+ |
+ // WebLayerImpl overrides. |
+ virtual void invalidateRect(const WebFloatRect&) OVERRIDE; |
+ virtual void setAnchorPoint(const WebFloatPoint&) OVERRIDE; |
+ virtual void setBounds(const WebSize&) OVERRIDE; |
+ virtual WebSize bounds() const OVERRIDE; |
+ virtual void setSublayerTransform(const SkMatrix44&) OVERRIDE; |
+ virtual void setSublayerTransform(const WebTransformationMatrix&) OVERRIDE; |
+ virtual SkMatrix44 sublayerTransform() const OVERRIDE; |
+ virtual void setTransform(const SkMatrix44&) OVERRIDE; |
+ virtual void setTransform(const WebTransformationMatrix&) OVERRIDE; |
+ virtual SkMatrix44 transform() const OVERRIDE; |
+ |
+ WEBKIT_COMPOSITOR_BINDINGS_EXPORT void setFixedBounds(const gfx::Size& fixedBounds); |
+ |
+protected: |
+ void setTransformInternal(const gfx::Transform&); |
+ void setSublayerTransformInternal(const gfx::Transform&); |
+ void updateLayerBoundsAndTransform(); |
+ |
+ gfx::Transform m_originalSublayerTransform; |
+ gfx::Transform m_originalTransform; |
+ gfx::Size m_originalBounds; |
+ gfx::Size m_fixedBounds; |
+}; |
+ |
+} // namespace WebKit |
+ |
+#endif // WebLayerImplFixedBounds_h |