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"
25 // A layer to render a thumbnail.
26 class ThumbnailLayer
: public Layer
{
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
,
40 scoped_refptr
<cc::Layer
> layer() override
;
44 ~ThumbnailLayer() override
;
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
61 #endif // CHROME_BROWSER_ANDROID_COMPOSITOR_LAYER_THUMBNAIL_LAYER_H_