Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(483)

Side by Side Diff: remoting/client/plugin/pepper_view.h

Issue 9331003: Improving the decoder pipeline. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 for Pepper. It is 5 // This class is an implementation of the ChromotingView for Pepper. It is
6 // callable only on the Pepper thread. 6 // callable only on the Pepper thread.
7 7
8 #ifndef REMOTING_CLIENT_PLUGIN_PEPPER_VIEW_H_ 8 #ifndef REMOTING_CLIENT_PLUGIN_PEPPER_VIEW_H_
9 #define REMOTING_CLIENT_PLUGIN_PEPPER_VIEW_H_ 9 #define REMOTING_CLIENT_PLUGIN_PEPPER_VIEW_H_
10 10
11 #include <vector> 11 #include <list>
12 12
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "media/base/video_frame.h"
16 #include "ppapi/cpp/graphics_2d.h" 15 #include "ppapi/cpp/graphics_2d.h"
17 #include "ppapi/cpp/point.h" 16 #include "ppapi/cpp/point.h"
18 #include "remoting/client/chromoting_view.h" 17 #include "remoting/client/chromoting_view.h"
19 #include "remoting/client/frame_consumer.h" 18 #include "remoting/client/frame_consumer.h"
20 19
21 namespace remoting { 20 namespace remoting {
22 21
23 class ChromotingInstance; 22 class ChromotingInstance;
24 class ClientContext; 23 class ClientContext;
24 class FrameProducer;
25 25
26 class PepperView : public ChromotingView, 26 class PepperView : public ChromotingView,
27 public FrameConsumer { 27 public FrameConsumer {
28 public: 28 public:
29 // Constructs a PepperView for the |instance|. The |instance| and 29 // Constructs a PepperView for the |instance|. The |instance|, |context|
30 // |context| must outlive this class. 30 // and |producer| must outlive this class.
31 PepperView(ChromotingInstance* instance, ClientContext* context); 31 PepperView(ChromotingInstance* instance,
32 ClientContext* context,
33 FrameProducer* producer);
32 virtual ~PepperView(); 34 virtual ~PepperView();
33 35
34 // ChromotingView implementation. 36 // ChromotingView implementation.
35 virtual bool Initialize() OVERRIDE; 37 virtual bool Initialize() OVERRIDE;
36 virtual void TearDown() OVERRIDE; 38 virtual void TearDown() OVERRIDE;
37 virtual void Paint() OVERRIDE; 39 virtual void Paint() OVERRIDE;
38 virtual void SetSolidFill(uint32 color) OVERRIDE; 40 virtual void SetSolidFill(uint32 color) OVERRIDE;
39 virtual void UnsetSolidFill() OVERRIDE; 41 virtual void UnsetSolidFill() OVERRIDE;
40 virtual void SetConnectionState( 42 virtual void SetConnectionState(
41 protocol::ConnectionToHost::State state, 43 protocol::ConnectionToHost::State state,
42 protocol::ConnectionToHost::Error error) OVERRIDE; 44 protocol::ConnectionToHost::Error error) OVERRIDE;
43 45
44 // FrameConsumer implementation. 46 // FrameConsumer implementation.
45 virtual void AllocateFrame(media::VideoFrame::Format format, 47 virtual void PaintBuffer(const SkISize& view_size,
46 const SkISize& size, 48 const SkIRect& clip_area,
47 scoped_refptr<media::VideoFrame>* frame_out, 49 pp::ImageData* buffer,
48 const base::Closure& done) OVERRIDE; 50 const SkRegion& region) OVERRIDE;
49 virtual void ReleaseFrame(media::VideoFrame* frame) OVERRIDE; 51 virtual void ReturnBuffer(pp::ImageData* buffer) OVERRIDE;
50 virtual void OnPartialFrameOutput(media::VideoFrame* frame, 52 virtual void SetScreenSize(const SkISize& screen_size) OVERRIDE;
51 SkRegion* region,
52 const base::Closure& done) OVERRIDE;
53 53
54 // Sets the display size of this view. Returns true if plugin size has 54 // Sets the display size and clipping area of this view. Returns true
55 // changed, false otherwise. 55 // if plugin size or clipping area has changed, false otherwise.
56 bool SetViewSize(const SkISize& plugin_size); 56 bool SetView(const SkISize& view_size, const SkIRect& clip_area);
57 57
58 // Return the client view and original host dimensions. 58 // Return the client view and original host dimensions.
59 const SkISize& get_view_size() const { 59 const SkISize& get_view_size() const {
60 return view_size_; 60 return view_size_;
61 } 61 }
62 const SkISize& get_host_size() const { 62 const SkISize& get_screen_size() const {
63 return host_size_; 63 return screen_size_;
64 } 64 }
65 65
66 private: 66 private:
67 void OnPaintDone(base::Time paint_start); 67 // This routine allocates an image buffer.
68 pp::ImageData* AllocateBuffer();
68 69
69 // Set the dimension of the entire host screen. 70 // This routine frees an image buffer allocated by AllocateBuffer().
70 void SetHostSize(const SkISize& host_size); 71 void FreeBuffer(pp::ImageData* buffer);
71 72
72 void PaintFrame(media::VideoFrame* frame, const SkRegion& region); 73 // This routine makes sure that enough image buffers are in flight to keep
74 // the decoding pipeline busy.
75 void InitiateDrawing();
73 76
74 // Render the rectangle of |frame| to the backing store. 77 // This routine applies the given image buffer to the screen taking into
75 // Returns true if this rectangle is not clipped. 78 // account |clip_area| of the buffer and |region| describing valid parts
76 bool PaintRect(media::VideoFrame* frame, const SkIRect& rect); 79 // of the buffer.
80 void FlushBuffer(const SkIRect& clip_area,
81 pp::ImageData* buffer,
82 const SkRegion& region);
77 83
78 // Blanks out a rectangle in an image. 84 // This is a completion callback for FlushGraphics().
79 void BlankRect(pp::ImageData& image_data, const pp::Rect& rect); 85 void OnFlushDone(base::Time paint_start, pp::ImageData* buffer);
80
81 // Perform a flush on the graphics context.
82 void FlushGraphics(base::Time paint_start);
83 86
84 // Reference to the creating plugin instance. Needed for interacting with 87 // Reference to the creating plugin instance. Needed for interacting with
85 // pepper. Marking explicitly as const since it must be initialized at 88 // pepper. Marking explicitly as const since it must be initialized at
86 // object creation, and never change. 89 // object creation, and never change.
87 ChromotingInstance* const instance_; 90 ChromotingInstance* const instance_;
88 91
89 // Context should be constant for the lifetime of the plugin. 92 // Context should be constant for the lifetime of the plugin.
90 ClientContext* const context_; 93 ClientContext* const context_;
91 94
92 pp::Graphics2D graphics2d_; 95 pp::Graphics2D graphics2d_;
93 96
94 // A backing store that saves the current desktop image. 97 FrameProducer* producer_;
95 scoped_ptr<pp::ImageData> backing_store_;
96 98
97 // True if there is pending paint commands in Pepper's queue. This is set to 99 // List of allocated image buffers.
98 // true if the last flush returns a PP_ERROR_INPROGRESS error. 100 std::list<pp::ImageData*> buffers_;
99 bool flush_blocked_; 101
102 pp::ImageData* merge_buffer_;
103 SkIRect merge_clip_area_;
104 SkRegion merge_region_;
100 105
101 // The size of the plugin element. 106 // The size of the plugin element.
102 SkISize view_size_; 107 SkISize view_size_;
103 108
109 // The current clip area rectangle.
110 SkIRect clip_area_;
111
104 // The size of the host screen. 112 // The size of the host screen.
105 SkISize host_size_; 113 SkISize screen_size_;
106 114
107 bool is_static_fill_;
108 uint32 static_fill_color_; 115 uint32 static_fill_color_;
109 116
117 // True if there is pending paint commands in Pepper's queue. This is set to
Wez 2012/02/17 23:42:17 nit: is -> are Consider rewording: True if there
alexeypa (please no reviews) 2012/02/21 23:00:44 Done.
118 // true if the last flush returns a PP_ERROR_INPROGRESS error.
119 bool flush_pending_;
120
121 // When true no new work should be posted to the producer.
Wez 2012/02/17 23:42:17 Doesn't work come from the RectangleUpdateDecoder?
alexeypa (please no reviews) 2012/02/21 23:00:44 Done: work -> buffers.
122 bool producer_disabled_;
123
124 // True if solid fill requested.
125 bool solid_fill_requested_;
126
110 base::WeakPtrFactory<PepperView> weak_factory_; 127 base::WeakPtrFactory<PepperView> weak_factory_;
111 128
112 DISALLOW_COPY_AND_ASSIGN(PepperView); 129 DISALLOW_COPY_AND_ASSIGN(PepperView);
113 }; 130 };
114 131
115 } // namespace remoting 132 } // namespace remoting
116 133
117 #endif // REMOTING_CLIENT_PLUGIN_PEPPER_VIEW_H_ 134 #endif // REMOTING_CLIENT_PLUGIN_PEPPER_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698