Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / android / compositor / layer / thumbnail_layer.h
blob0da3e4eb71e9b345a6678cf5a764ffa55e86b5ab
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_ANDROID_COMPOSITOR_LAYER_THUMBNAIL_LAYER_H_
6 #define CHROME_BROWSER_ANDROID_COMPOSITOR_LAYER_THUMBNAIL_LAYER_H_
8 #include "base/macros.h"
9 #include "base/memory/ref_counted.h"
10 #include "cc/layers/ui_resource_layer.h"
11 #include "cc/resources/ui_resource_client.h"
12 #include "chrome/browser/android/compositor/layer/layer.h"
13 #include "ui/gfx/geometry/rect.h"
14 #include "ui/gfx/geometry/size_f.h"
16 class Thumbnail;
18 namespace cc {
19 class Layer;
22 namespace chrome {
23 namespace android {
25 // A layer to render a thumbnail.
26 class ThumbnailLayer : public Layer {
27 public:
28 // Creates a ThumbnailLayer.
29 static scoped_refptr<ThumbnailLayer> Create();
30 // Sets thumbnail that will be shown. |thumbnail| should not be nullptr.
31 void SetThumbnail(Thumbnail* thumbnail);
32 // Clip the thumbnail to the given |clipping|.
33 void Clip(const gfx::Rect& clipping);
34 // Add self to |parent| or replace self at |index| if there already is an
35 // instance with the same ID at |index|.
36 void AddSelfToParentOrReplaceAt(scoped_refptr<cc::Layer> parent,
37 size_t index);
39 // Implements Layer.
40 scoped_refptr<cc::Layer> layer() override;
42 protected:
43 ThumbnailLayer();
44 ~ThumbnailLayer() override;
46 private:
47 void UpdateSizes(const gfx::SizeF& content_size,
48 const gfx::SizeF& resource_size);
50 scoped_refptr<cc::UIResourceLayer> layer_;
51 gfx::SizeF content_size_;
52 gfx::Rect last_clipping_;
53 gfx::SizeF resource_size_;
55 DISALLOW_COPY_AND_ASSIGN(ThumbnailLayer);
58 } // namespace android
59 } // namespace chrome
61 #endif // CHROME_BROWSER_ANDROID_COMPOSITOR_LAYER_THUMBNAIL_LAYER_H_