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

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: Integer ScaleRect 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
« no previous file with comments | « remoting/client/plugin/chromoting_instance.cc ('k') | remoting/client/plugin/pepper_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
38 virtual void SetSolidFill(uint32 color) OVERRIDE;
39 virtual void UnsetSolidFill() OVERRIDE;
40 virtual void SetConnectionState( 39 virtual void SetConnectionState(
41 protocol::ConnectionToHost::State state, 40 protocol::ConnectionToHost::State state,
42 protocol::ConnectionToHost::Error error) OVERRIDE; 41 protocol::ConnectionToHost::Error error) OVERRIDE;
43 42
44 // FrameConsumer implementation. 43 // FrameConsumer implementation.
45 virtual void AllocateFrame(media::VideoFrame::Format format, 44 virtual void ApplyBuffer(const SkISize& view_size,
46 const SkISize& size, 45 const SkIRect& clip_area,
47 scoped_refptr<media::VideoFrame>* frame_out, 46 pp::ImageData* buffer,
48 const base::Closure& done) OVERRIDE; 47 const SkRegion& region) OVERRIDE;
49 virtual void ReleaseFrame(media::VideoFrame* frame) OVERRIDE; 48 virtual void ReturnBuffer(pp::ImageData* buffer) OVERRIDE;
50 virtual void OnPartialFrameOutput(media::VideoFrame* frame, 49 virtual void SetSourceSize(const SkISize& source_size) OVERRIDE;
51 SkRegion* region,
52 const base::Closure& done) OVERRIDE;
53 50
54 // Sets the display size of this view. Returns true if plugin size has 51 // Sets the display size and clipping area of this view.
55 // changed, false otherwise. 52 void SetView(const SkISize& view_size, const SkIRect& clip_area);
56 bool SetViewSize(const SkISize& plugin_size);
57 53
58 // Return the client view and original host dimensions. 54 // Return the client view and original host dimensions.
59 const SkISize& get_view_size() const { 55 const SkISize& get_view_size() const {
60 return view_size_; 56 return view_size_;
61 } 57 }
62 const SkISize& get_host_size() const { 58 const SkISize& get_screen_size() const {
63 return host_size_; 59 return source_size_;
64 } 60 }
65 61
66 private: 62 private:
67 void OnPaintDone(base::Time paint_start); 63 // This routine allocates an image buffer.
64 pp::ImageData* AllocateBuffer();
68 65
69 // Set the dimension of the entire host screen. 66 // This routine frees an image buffer allocated by AllocateBuffer().
70 void SetHostSize(const SkISize& host_size); 67 void FreeBuffer(pp::ImageData* buffer);
71 68
72 void PaintFrame(media::VideoFrame* frame, const SkRegion& region); 69 // This routine makes sure that enough image buffers are in flight to keep
70 // the decoding pipeline busy.
71 void InitiateDrawing();
73 72
74 // Render the rectangle of |frame| to the backing store. 73 // This routine applies the given image buffer to the screen taking into
75 // Returns true if this rectangle is not clipped. 74 // account |clip_area| of the buffer and |region| describing valid parts
76 bool PaintRect(media::VideoFrame* frame, const SkIRect& rect); 75 // of the buffer.
76 void FlushBuffer(const SkIRect& clip_area,
77 pp::ImageData* buffer,
78 const SkRegion& region);
77 79
78 // Blanks out a rectangle in an image. 80 // This is a completion callback for FlushGraphics().
79 void BlankRect(pp::ImageData& image_data, const pp::Rect& rect); 81 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 82
84 // Reference to the creating plugin instance. Needed for interacting with 83 // Reference to the creating plugin instance. Needed for interacting with
85 // pepper. Marking explicitly as const since it must be initialized at 84 // pepper. Marking explicitly as const since it must be initialized at
86 // object creation, and never change. 85 // object creation, and never change.
87 ChromotingInstance* const instance_; 86 ChromotingInstance* const instance_;
88 87
89 // Context should be constant for the lifetime of the plugin. 88 // Context should be constant for the lifetime of the plugin.
90 ClientContext* const context_; 89 ClientContext* const context_;
91 90
92 pp::Graphics2D graphics2d_; 91 pp::Graphics2D graphics2d_;
93 92
94 // A backing store that saves the current desktop image. 93 FrameProducer* producer_;
95 scoped_ptr<pp::ImageData> backing_store_;
96 94
97 // True if there is pending paint commands in Pepper's queue. This is set to 95 // List of allocated image buffers.
98 // true if the last flush returns a PP_ERROR_INPROGRESS error. 96 std::list<pp::ImageData*> buffers_;
99 bool flush_blocked_; 97
98 pp::ImageData* merge_buffer_;
99 SkIRect merge_clip_area_;
100 SkRegion merge_region_;
100 101
101 // The size of the plugin element. 102 // The size of the plugin element.
102 SkISize view_size_; 103 SkISize view_size_;
103 104
105 // The current clip area rectangle.
106 SkIRect clip_area_;
107
104 // The size of the host screen. 108 // The size of the host screen.
105 SkISize host_size_; 109 SkISize source_size_;
106 110
107 bool is_static_fill_; 111 // True if there is already a Flush() pending on the Graphics2D context.
108 uint32 static_fill_color_; 112 bool flush_pending_;
113
114 bool in_teardown_;
109 115
110 base::WeakPtrFactory<PepperView> weak_factory_; 116 base::WeakPtrFactory<PepperView> weak_factory_;
111 117
112 DISALLOW_COPY_AND_ASSIGN(PepperView); 118 DISALLOW_COPY_AND_ASSIGN(PepperView);
113 }; 119 };
114 120
115 } // namespace remoting 121 } // namespace remoting
116 122
117 #endif // REMOTING_CLIENT_PLUGIN_PEPPER_VIEW_H_ 123 #endif // REMOTING_CLIENT_PLUGIN_PEPPER_VIEW_H_
OLDNEW
« no previous file with comments | « remoting/client/plugin/chromoting_instance.cc ('k') | remoting/client/plugin/pepper_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698