OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 using Pepper devices |
6 // as the backing stores. The public APIs to this class are thread-safe. | 6 // as the backing stores. The public APIs to this class are thread-safe. |
7 // Calls will dispatch any interaction with the pepper API onto the pepper | 7 // Calls will dispatch any interaction with the pepper API onto the pepper |
8 // main thread. | 8 // main thread. |
9 // | 9 // |
10 // TODO(ajwong): We need to better understand the threading semantics of this | 10 // TODO(ajwong): We need to better understand the threading semantics of this |
11 // class. Currently, we're just going to always run everything on the pepper | 11 // class. Currently, we're just going to always run everything on the pepper |
12 // main thread. Is this smart? | 12 // main thread. Is this smart? |
13 | 13 |
14 #ifndef REMOTING_CLIENT_PLUGIN_PEPPER_VIEW_H_ | 14 #ifndef REMOTING_CLIENT_PLUGIN_PEPPER_VIEW_H_ |
15 #define REMOTING_CLIENT_PLUGIN_PEPPER_VIEW_H_ | 15 #define REMOTING_CLIENT_PLUGIN_PEPPER_VIEW_H_ |
16 | 16 |
17 #include "base/scoped_ptr.h" | 17 #include "base/scoped_ptr.h" |
18 #include "base/task.h" | 18 #include "base/task.h" |
19 #include "media/base/video_frame.h" | 19 #include "media/base/video_frame.h" |
20 #include "remoting/client/chromoting_view.h" | 20 #include "remoting/client/chromoting_view.h" |
| 21 #include "remoting/client/frame_consumer.h" |
| 22 #include "remoting/client/rectangle_update_decoder.h" |
21 #include "third_party/ppapi/cpp/graphics_2d.h" | 23 #include "third_party/ppapi/cpp/graphics_2d.h" |
22 | 24 |
23 namespace remoting { | 25 namespace remoting { |
24 | 26 |
25 class ChromotingInstance; | 27 class ChromotingInstance; |
| 28 class ClientContext; |
26 | 29 |
27 class PepperView : public ChromotingView { | 30 class PepperView : public ChromotingView, |
| 31 public FrameConsumer { |
28 public: | 32 public: |
29 // Constructs a PepperView that draws to the |rendering_device|. The | 33 // Constructs a PepperView that draws to the |rendering_device|. The |
30 // |rendering_device| instance must outlive this class. | 34 // |rendering_device| instance must outlive this class. |
31 // | 35 PepperView(ChromotingInstance* instance, ClientContext* context); |
32 // TODO(ajwong): This probably needs to synchronize with the pepper thread | |
33 // to be safe. | |
34 explicit PepperView(ChromotingInstance* instance); | |
35 virtual ~PepperView(); | 36 virtual ~PepperView(); |
36 | 37 |
37 // ChromotingView implementation. | 38 // ChromotingView implementation. |
38 virtual bool Initialize(); | 39 virtual bool Initialize(); |
39 virtual void TearDown(); | 40 virtual void TearDown(); |
40 virtual void Paint(); | 41 virtual void Paint(); |
41 virtual void SetSolidFill(uint32 color); | 42 virtual void SetSolidFill(uint32 color); |
42 virtual void UnsetSolidFill(); | 43 virtual void UnsetSolidFill(); |
43 virtual void SetViewport(int x, int y, int width, int height); | 44 virtual void SetViewport(int x, int y, int width, int height); |
44 virtual void SetHostScreenSize(int width, int height); | 45 |
45 virtual void HandleBeginUpdateStream(ChromotingHostMessage* msg); | 46 // FrameConsumer implementation. |
46 virtual void HandleUpdateStreamPacket(ChromotingHostMessage* msg); | 47 virtual void AllocateFrame(media::VideoFrame::Format format, |
47 virtual void HandleEndUpdateStream(ChromotingHostMessage* msg); | 48 size_t width, |
| 49 size_t height, |
| 50 base::TimeDelta timestamp, |
| 51 base::TimeDelta duration, |
| 52 scoped_refptr<media::VideoFrame>* frame_out, |
| 53 Task* done); |
| 54 virtual void ReleaseFrame(media::VideoFrame* frame); |
| 55 virtual void OnPartialFrameOutput(media::VideoFrame* frame, |
| 56 UpdatedRects* rects, |
| 57 Task* done); |
48 | 58 |
49 private: | 59 private: |
50 void OnPaintDone(); | 60 void OnPaintDone(); |
51 void OnPartialDecodeDone(); | 61 void PaintFrame(media::VideoFrame* frame, UpdatedRects* rects); |
52 void OnDecodeDone(); | |
53 | 62 |
54 // Reference to the creating plugin instance. Needed for interacting with | 63 // Reference to the creating plugin instance. Needed for interacting with |
55 // pepper. Marking explciitly as const since it must be initialized at | 64 // pepper. Marking explciitly as const since it must be initialized at |
56 // object creation, and never change. | 65 // object creation, and never change. |
57 ChromotingInstance* const instance_; | 66 ChromotingInstance* const instance_; |
58 | 67 |
59 pp::Graphics2D device_context_; | 68 // Context should be constant for the lifetime of the plugin. |
| 69 ClientContext* const context_; |
| 70 |
| 71 pp::Graphics2D graphics2d_; |
60 | 72 |
61 int viewport_x_; | 73 int viewport_x_; |
62 int viewport_y_; | 74 int viewport_y_; |
63 int viewport_width_; | 75 int viewport_width_; |
64 int viewport_height_; | 76 int viewport_height_; |
65 | 77 |
66 bool is_static_fill_; | 78 bool is_static_fill_; |
67 uint32 static_fill_color_; | 79 uint32 static_fill_color_; |
68 | 80 |
69 DISALLOW_COPY_AND_ASSIGN(PepperView); | 81 DISALLOW_COPY_AND_ASSIGN(PepperView); |
70 }; | 82 }; |
71 | 83 |
72 } // namespace remoting | 84 } // namespace remoting |
73 | 85 |
74 DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::PepperView); | 86 DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::PepperView); |
75 | 87 |
76 #endif // REMOTING_CLIENT_PLUGIN_PEPPER_VIEW_H_ | 88 #endif // REMOTING_CLIENT_PLUGIN_PEPPER_VIEW_H_ |
OLD | NEW |