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 |
| 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 |
| 8 // main thread. |
| 9 // |
| 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 |
| 12 // main thread. Is this smart? |
| 13 |
5 #ifndef REMOTING_CLIENT_PLUGIN_PEPPER_VIEW_H_ | 14 #ifndef REMOTING_CLIENT_PLUGIN_PEPPER_VIEW_H_ |
6 #define REMOTING_CLIENT_PLUGIN_PEPPER_VIEW_H_ | 15 #define REMOTING_CLIENT_PLUGIN_PEPPER_VIEW_H_ |
7 | 16 |
8 #include "base/scoped_ptr.h" | 17 #include "base/scoped_ptr.h" |
9 #include "base/task.h" | 18 #include "base/task.h" |
| 19 #include "media/base/video_frame.h" |
10 #include "remoting/client/chromoting_view.h" | 20 #include "remoting/client/chromoting_view.h" |
11 #include "third_party/npapi/bindings/npapi.h" | 21 #include "remoting/client/decoder.h" |
12 #include "third_party/npapi/bindings/npapi_extensions.h" | 22 #include "third_party/ppapi/cpp/device_context_2d.h" |
13 | |
14 class MessageLoop; | |
15 | 23 |
16 namespace remoting { | 24 namespace remoting { |
17 | 25 |
| 26 class ChromotingPlugin; |
18 class Decoder; | 27 class Decoder; |
19 | 28 |
20 class PepperView : public ChromotingView { | 29 class PepperView : public ChromotingView { |
21 public: | 30 public: |
22 // Constructs a PepperView that draw to the |rendering_device|. The | 31 // Constructs a PepperView that draws to the |rendering_device|. The |
23 // |rendering_device| instance must outlive this class. | 32 // |rendering_device| instance must outlive this class. |
24 // | 33 // |
25 // TODO(ajwong): This probably needs to synchronize with the pepper thread | 34 // TODO(ajwong): This probably needs to synchronize with the pepper thread |
26 // to be safe. | 35 // to be safe. |
27 PepperView(MessageLoop* message_loop, NPDevice* rendering_device, | 36 explicit PepperView(ChromotingPlugin* plugin); |
28 NPP plugin_instance); | |
29 virtual ~PepperView(); | 37 virtual ~PepperView(); |
30 | 38 |
31 // ChromotingView implementation. | 39 // ChromotingView implementation. |
32 virtual void Paint(); | 40 virtual void Paint(); |
33 virtual void SetSolidFill(uint32 color); | 41 virtual void SetSolidFill(uint32 color); |
34 virtual void UnsetSolidFill(); | 42 virtual void UnsetSolidFill(); |
35 virtual void SetViewport(int x, int y, int width, int height); | 43 virtual void SetViewport(int x, int y, int width, int height); |
36 virtual void SetBackingStoreSize(int width, int height); | 44 virtual void SetBackingStoreSize(int width, int height); |
37 virtual void HandleBeginUpdateStream(HostMessage* msg); | 45 virtual void HandleBeginUpdateStream(HostMessage* msg); |
38 virtual void HandleUpdateStreamPacket(HostMessage* msg); | 46 virtual void HandleUpdateStreamPacket(HostMessage* msg); |
39 virtual void HandleEndUpdateStream(HostMessage* msg); | 47 virtual void HandleEndUpdateStream(HostMessage* msg); |
40 | 48 |
41 private: | 49 private: |
42 void DoPaint(); | 50 void OnPaintDone(); |
43 void DoSetSolidFill(uint32 color); | 51 void OnPartialDecodeDone(); |
44 void DoUnsetSolidFill(); | 52 void OnDecodeDone(); |
45 void DoSetViewport(int x, int y, int width, int height); | |
46 void DoSetBackingStoreSize(int width, int height); | |
47 void DoHandleBeginUpdateStream(HostMessage* msg); | |
48 void DoHandleUpdateStreamPacket(HostMessage* msg); | |
49 void DoHandleEndUpdateStream(HostMessage* msg); | |
50 | 53 |
51 // Synchronization and thread handling objects. | 54 // Reference to the creating plugin instance. Needed for interacting with |
52 MessageLoop* message_loop_; | 55 // pepper. Marking explciitly as const since it must be initialized at |
| 56 // object creation, and never change. |
| 57 ChromotingPlugin* const plugin_; |
53 | 58 |
54 // Handles to Pepper objects needed for drawing to the screen. | 59 pp::DeviceContext2D device_context_; |
55 NPDevice* rendering_device_; | |
56 NPP plugin_instance_; | |
57 | 60 |
58 int backing_store_width_; | 61 int backing_store_width_; |
59 int backing_store_height_; | 62 int backing_store_height_; |
60 | 63 |
61 int viewport_x_; | 64 int viewport_x_; |
62 int viewport_y_; | 65 int viewport_y_; |
63 int viewport_width_; | 66 int viewport_width_; |
64 int viewport_height_; | 67 int viewport_height_; |
65 | 68 |
66 bool is_static_fill_; | 69 bool is_static_fill_; |
67 uint32 static_fill_color_; | 70 uint32 static_fill_color_; |
68 | 71 |
| 72 scoped_refptr<media::VideoFrame> frame_; |
| 73 UpdatedRects update_rects_; |
| 74 UpdatedRects all_update_rects_; |
| 75 |
69 scoped_ptr<Decoder> decoder_; | 76 scoped_ptr<Decoder> decoder_; |
70 | 77 |
71 DISALLOW_COPY_AND_ASSIGN(PepperView); | 78 DISALLOW_COPY_AND_ASSIGN(PepperView); |
72 }; | 79 }; |
73 | 80 |
74 } // namespace remoting | 81 } // namespace remoting |
75 | 82 |
76 DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::PepperView); | 83 DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::PepperView); |
77 | 84 |
78 #endif // REMOTING_CLIENT_PLUGIN_PEPPER_VIEW_H_ | 85 #endif // REMOTING_CLIENT_PLUGIN_PEPPER_VIEW_H_ |
OLD | NEW |