OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This class is an implementation of the ChromotingView using Pepper devices | 5 // This class is an implementation of the ChromotingView for Pepper. It is |
6 // as the backing stores. This class is used only on pepper thread. | 6 // callable only on the Pepper thread. |
7 // Chromoting objects access this object through PepperViewProxy which | |
8 // delegates method calls on the pepper thread. | |
9 | 7 |
10 #ifndef REMOTING_CLIENT_PLUGIN_PEPPER_VIEW_H_ | 8 #ifndef REMOTING_CLIENT_PLUGIN_PEPPER_VIEW_H_ |
11 #define REMOTING_CLIENT_PLUGIN_PEPPER_VIEW_H_ | 9 #define REMOTING_CLIENT_PLUGIN_PEPPER_VIEW_H_ |
12 | 10 |
13 #include <vector> | 11 #include <vector> |
14 | 12 |
15 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
16 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
17 #include "media/base/video_frame.h" | 15 #include "media/base/video_frame.h" |
18 #include "ppapi/cpp/graphics_2d.h" | 16 #include "ppapi/cpp/graphics_2d.h" |
19 #include "ppapi/cpp/point.h" | 17 #include "ppapi/cpp/point.h" |
20 #include "remoting/client/chromoting_view.h" | 18 #include "remoting/client/chromoting_view.h" |
21 #include "remoting/client/frame_consumer.h" | 19 #include "remoting/client/frame_consumer.h" |
22 | 20 |
23 namespace remoting { | 21 namespace remoting { |
24 | 22 |
25 class ChromotingInstance; | 23 class ChromotingInstance; |
26 class ClientContext; | 24 class ClientContext; |
27 | 25 |
28 class PepperView : public ChromotingView, | 26 class PepperView : public ChromotingView, |
29 public FrameConsumer { | 27 public FrameConsumer { |
30 public: | 28 public: |
31 // Constructs a PepperView that draws to the |rendering_device|. The | 29 // Constructs a PepperView for the |instance|. The |instance| and |
32 // |rendering_device| instance must outlive this class. | 30 // |context| must outlive this class. |
33 PepperView(ChromotingInstance* instance, ClientContext* context); | 31 PepperView(ChromotingInstance* instance, ClientContext* context); |
34 virtual ~PepperView(); | 32 virtual ~PepperView(); |
35 | 33 |
36 // ChromotingView implementation. | 34 // ChromotingView implementation. |
37 virtual bool Initialize() OVERRIDE; | 35 virtual bool Initialize() OVERRIDE; |
38 virtual void TearDown() OVERRIDE; | 36 virtual void TearDown() OVERRIDE; |
39 virtual void Paint() OVERRIDE; | 37 virtual void Paint() OVERRIDE; |
40 virtual void SetSolidFill(uint32 color) OVERRIDE; | 38 virtual void SetSolidFill(uint32 color) OVERRIDE; |
41 virtual void UnsetSolidFill() OVERRIDE; | 39 virtual void UnsetSolidFill() OVERRIDE; |
42 virtual void SetConnectionState( | 40 virtual void SetConnectionState( |
43 protocol::ConnectionToHost::State state, | 41 protocol::ConnectionToHost::State state, |
44 protocol::ConnectionToHost::Error error) OVERRIDE; | 42 protocol::ConnectionToHost::Error error) OVERRIDE; |
45 virtual double GetHorizontalScaleRatio() const OVERRIDE; | |
46 virtual double GetVerticalScaleRatio() const OVERRIDE; | |
47 | 43 |
48 // FrameConsumer implementation. | 44 // FrameConsumer implementation. |
49 virtual void AllocateFrame(media::VideoFrame::Format format, | 45 virtual void AllocateFrame(media::VideoFrame::Format format, |
50 const SkISize& size, | 46 const SkISize& size, |
51 scoped_refptr<media::VideoFrame>* frame_out, | 47 scoped_refptr<media::VideoFrame>* frame_out, |
52 const base::Closure& done) OVERRIDE; | 48 const base::Closure& done) OVERRIDE; |
53 virtual void ReleaseFrame(media::VideoFrame* frame) OVERRIDE; | 49 virtual void ReleaseFrame(media::VideoFrame* frame) OVERRIDE; |
54 virtual void OnPartialFrameOutput(media::VideoFrame* frame, | 50 virtual void OnPartialFrameOutput(media::VideoFrame* frame, |
55 RectVector* rects, | 51 RectVector* rects, |
56 const base::Closure& done) OVERRIDE; | 52 const base::Closure& done) OVERRIDE; |
57 | 53 |
58 // This is called when the dimension of the plugin element has changed. | 54 // Sets the display size of this view. Returns true if plugin size has |
59 // Return true if plugin size has changed, false otherwise. | 55 // changed, false otherwise. |
60 bool SetPluginSize(const SkISize& plugin_size); | 56 bool SetViewSize(const SkISize& plugin_size); |
| 57 |
| 58 // Return the client view and original host dimensions. |
| 59 const SkISize& get_view_size() const { |
| 60 return view_size_; |
| 61 } |
| 62 const SkISize& get_host_size() const { |
| 63 return host_size_; |
| 64 } |
61 | 65 |
62 private: | 66 private: |
63 void OnPaintDone(base::Time paint_start); | 67 void OnPaintDone(base::Time paint_start); |
64 | 68 |
65 // Set the dimension of the entire host screen. | 69 // Set the dimension of the entire host screen. |
66 void SetHostSize(const SkISize& host_size); | 70 void SetHostSize(const SkISize& host_size); |
67 | 71 |
68 void PaintFrame(media::VideoFrame* frame, RectVector* rects); | 72 void PaintFrame(media::VideoFrame* frame, RectVector* rects); |
69 | 73 |
70 // Render the rectangle of |frame| to the backing store. | 74 // Render the rectangle of |frame| to the backing store. |
(...skipping 17 matching lines...) Expand all Loading... |
88 pp::Graphics2D graphics2d_; | 92 pp::Graphics2D graphics2d_; |
89 | 93 |
90 // A backing store that saves the current desktop image. | 94 // A backing store that saves the current desktop image. |
91 scoped_ptr<pp::ImageData> backing_store_; | 95 scoped_ptr<pp::ImageData> backing_store_; |
92 | 96 |
93 // True if there is pending paint commands in Pepper's queue. This is set to | 97 // True if there is pending paint commands in Pepper's queue. This is set to |
94 // true if the last flush returns a PP_ERROR_INPROGRESS error. | 98 // true if the last flush returns a PP_ERROR_INPROGRESS error. |
95 bool flush_blocked_; | 99 bool flush_blocked_; |
96 | 100 |
97 // The size of the plugin element. | 101 // The size of the plugin element. |
98 SkISize plugin_size_; | 102 SkISize view_size_; |
99 | 103 |
100 // The size of the host screen. | 104 // The size of the host screen. |
101 SkISize host_size_; | 105 SkISize host_size_; |
102 | 106 |
103 bool is_static_fill_; | 107 bool is_static_fill_; |
104 uint32 static_fill_color_; | 108 uint32 static_fill_color_; |
105 | 109 |
106 base::WeakPtrFactory<PepperView> weak_factory_; | 110 base::WeakPtrFactory<PepperView> weak_factory_; |
107 | 111 |
108 DISALLOW_COPY_AND_ASSIGN(PepperView); | 112 DISALLOW_COPY_AND_ASSIGN(PepperView); |
109 }; | 113 }; |
110 | 114 |
111 } // namespace remoting | 115 } // namespace remoting |
112 | 116 |
113 #endif // REMOTING_CLIENT_PLUGIN_PEPPER_VIEW_H_ | 117 #endif // REMOTING_CLIENT_PLUGIN_PEPPER_VIEW_H_ |
OLD | NEW |