1f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved.
22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// found in the LICENSE file.
42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
503b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)#ifndef CC_BLINK_WEB_LAYER_IMPL_FIXED_BOUNDS_H_
603b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)#define CC_BLINK_WEB_LAYER_IMPL_FIXED_BOUNDS_H_
72a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)#include "cc/blink/web_layer_impl.h"
92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ui/gfx/size.h"
102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ui/gfx/transform.h"
112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)namespace cc_blink {
132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// A special implementation of WebLayerImpl for layers that its contents
152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// need to be automatically scaled when the bounds changes. The compositor
162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// can efficiently handle the bounds change of such layers if the bounds
172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// is fixed to a given value and the change of bounds are converted to
182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// transformation scales.
192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class WebLayerImplFixedBounds : public WebLayerImpl {
202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) public:
2103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  CC_BLINK_EXPORT WebLayerImplFixedBounds();
2203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  CC_BLINK_EXPORT explicit WebLayerImplFixedBounds(scoped_refptr<cc::Layer>);
232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual ~WebLayerImplFixedBounds();
242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // WebLayerImpl overrides.
26f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  virtual void invalidateRect(const blink::WebFloatRect& rect);
2746d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)  virtual void setTransformOrigin(
2846d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)      const blink::WebFloatPoint3D& transform_origin);
29f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  virtual void setBounds(const blink::WebSize& bounds);
30f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  virtual blink::WebSize bounds() const;
312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void setTransform(const SkMatrix44& transform);
322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual SkMatrix44 transform() const;
332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
3403b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  CC_BLINK_EXPORT void SetFixedBounds(gfx::Size bounds);
352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) protected:
372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void SetTransformInternal(const gfx::Transform& transform);
382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void UpdateLayerBoundsAndTransform();
392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  gfx::Transform original_transform_;
412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  gfx::Size original_bounds_;
422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  gfx::Size fixed_bounds_;
432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) private:
452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(WebLayerImplFixedBounds);
462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)};
472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)}  // namespace cc_blink
492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)#endif  // CC_BLINK_WEB_LAYER_IMPL_FIXED_BOUNDS_H_
51