OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 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. | |
4 | |
5 #ifndef BLIMP_CLIENT_PUBLIC_CONTENTS_BLIMP_CONTENTS_VIEW_H_ | |
6 #define BLIMP_CLIENT_PUBLIC_CONTENTS_BLIMP_CONTENTS_VIEW_H_ | |
7 | |
8 #include "base/macros.h" | |
9 #include "ui/gfx/native_widget_types.h" | |
10 | |
11 namespace cc { | |
12 class Layer; | |
13 } // namespace cc | |
14 | |
15 namespace gfx { | |
16 class Size; | |
17 } // namespace gfx | |
18 | |
19 namespace ui { | |
20 class MotionEvent; | |
21 } | |
22 | |
23 namespace blimp { | |
24 namespace client { | |
25 | |
26 // A BlimpContentsView exposes the classes required to visually represent a | |
27 // BlimpContents (gfx::NativeView and cc::Layer). It also exposes methods that | |
28 // let the embedder interact with the page content. | |
29 class BlimpContentsView { | |
30 public: | |
31 using ReadbackRequestCallback = | |
32 base::Callback<void(std::unique_ptr<SkBitmap>)>; | |
33 | |
34 virtual ~BlimpContentsView() = default; | |
35 | |
36 // Returns the platform specific NativeView that represents the contents of | |
37 // this BlimpContents. | |
38 virtual gfx::NativeView GetNativeView() = 0; | |
39 | |
40 // Returns the CC Layer that represents the contents of this BlimpContents. | |
41 // This can be used instead of |GetNativeView()| if only the CC Layer is | |
42 // required. | |
43 virtual scoped_refptr<cc::Layer> GetLayer() = 0; | |
44 | |
45 // Called to set both the size and the scale of the BlimpContents. |size| is | |
46 // in pixels and |device_scale_factor| is in terms of dp to px. | |
47 virtual void SetSizeAndScale(const gfx::Size& size, | |
48 float device_scale_factor) = 0; | |
49 | |
50 // Called to pass a ui::MotionEvent to the BlimpContents. Returns whether or | |
51 // not |motion_event| was handled. | |
52 virtual bool OnTouchEvent(const ui::MotionEvent& motion_event) = 0; | |
53 | |
54 // Copies the current visible content from the BlimpContents and returns a | |
55 // SkBitmap through |callback|. If the readback fails |nullptr| is returned | |
56 // instead. | |
57 // Only one readback can be outstanding at a time, so subsequent readbacks | |
58 // will be treated like failures. | |
59 // If |flush_pending_commits| is |true|, the readback request will wait until | |
60 // all currently outstanding compositor commits have been pushed to the | |
61 // screen. If it is |false|, the readback will happen regardless of whether | |
62 // or not there are outstanding commits. If the underlying content layer is | |
63 // destroyed or swapped, this will also count as a valid flush and the | |
64 // readback will start immediately. This is mainly used for tests to | |
65 // guarantee compositor state at validation time. | |
66 virtual void CopyFromCompositingSurface( | |
Khushal
2016/09/13 23:47:10
This looks fine for now. Basically we want to expo
David Trainor- moved to gerrit
2016/09/14 00:31:09
Discussed offline. Removing flush_pending_commits
| |
67 const ReadbackRequestCallback& callback, | |
68 bool flush_pending_commits) = 0; | |
69 | |
70 protected: | |
71 BlimpContentsView() = default; | |
72 | |
73 private: | |
74 DISALLOW_COPY_AND_ASSIGN(BlimpContentsView); | |
75 }; | |
76 | |
77 } // namespace client | |
78 } // namespace blimp | |
79 | |
80 #endif // BLIMP_CLIENT_PUBLIC_CONTENTS_BLIMP_CONTENTS_VIEW_H_ | |
OLD | NEW |