| 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 using Pepper devices |
| 6 // as the backing stores. This class is used only on pepper thread. | 6 // as the backing stores. This class is used only on pepper thread. |
| 7 // Chromoting objects access this object through PepperViewProxy which | 7 // Chromoting objects access this object through PepperViewProxy which |
| 8 // delegates method calls on the pepper thread. | 8 // delegates method calls on the pepper thread. |
| 9 | 9 |
| 10 #ifndef REMOTING_CLIENT_PLUGIN_PEPPER_VIEW_H_ | 10 #ifndef REMOTING_CLIENT_PLUGIN_PEPPER_VIEW_H_ |
| 11 #define REMOTING_CLIENT_PLUGIN_PEPPER_VIEW_H_ | 11 #define REMOTING_CLIENT_PLUGIN_PEPPER_VIEW_H_ |
| 12 | 12 |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/task.h" | 16 #include "base/task.h" |
| 17 #include "media/base/video_frame.h" | 17 #include "media/base/video_frame.h" |
| 18 #include "ppapi/cpp/graphics_2d.h" | 18 #include "ppapi/cpp/graphics_2d.h" |
| 19 #include "ppapi/cpp/point.h" | 19 #include "ppapi/cpp/point.h" |
| 20 #include "remoting/client/chromoting_view.h" | 20 #include "remoting/client/chromoting_view.h" |
| 21 #include "remoting/client/frame_consumer.h" | 21 #include "remoting/client/frame_consumer.h" |
| 22 #include "ui/gfx/size.h" | |
| 23 | 22 |
| 24 namespace remoting { | 23 namespace remoting { |
| 25 | 24 |
| 26 class ChromotingInstance; | 25 class ChromotingInstance; |
| 27 class ClientContext; | 26 class ClientContext; |
| 28 | 27 |
| 29 class PepperView : public ChromotingView, | 28 class PepperView : public ChromotingView, |
| 30 public FrameConsumer { | 29 public FrameConsumer { |
| 31 public: | 30 public: |
| 32 // Constructs a PepperView that draws to the |rendering_device|. The | 31 // Constructs a PepperView that draws to the |rendering_device|. The |
| (...skipping 16 matching lines...) Expand all Loading... |
| 49 // FrameConsumer implementation. | 48 // FrameConsumer implementation. |
| 50 virtual void AllocateFrame(media::VideoFrame::Format format, | 49 virtual void AllocateFrame(media::VideoFrame::Format format, |
| 51 size_t width, | 50 size_t width, |
| 52 size_t height, | 51 size_t height, |
| 53 base::TimeDelta timestamp, | 52 base::TimeDelta timestamp, |
| 54 base::TimeDelta duration, | 53 base::TimeDelta duration, |
| 55 scoped_refptr<media::VideoFrame>* frame_out, | 54 scoped_refptr<media::VideoFrame>* frame_out, |
| 56 Task* done); | 55 Task* done); |
| 57 virtual void ReleaseFrame(media::VideoFrame* frame); | 56 virtual void ReleaseFrame(media::VideoFrame* frame); |
| 58 virtual void OnPartialFrameOutput(media::VideoFrame* frame, | 57 virtual void OnPartialFrameOutput(media::VideoFrame* frame, |
| 59 UpdatedRects* rects, | 58 RectVector* rects, |
| 60 Task* done); | 59 Task* done); |
| 61 | 60 |
| 62 // This is called when the dimension of the plugin element has changed. | 61 // This is called when the dimension of the plugin element has changed. |
| 63 // Return true if plugin size has changed, false otherwise. | 62 // Return true if plugin size has changed, false otherwise. |
| 64 bool SetPluginSize(const gfx::Size& plugin_size); | 63 bool SetPluginSize(const SkISize& plugin_size); |
| 65 | 64 |
| 66 private: | 65 private: |
| 67 void OnPaintDone(base::Time paint_start); | 66 void OnPaintDone(base::Time paint_start); |
| 68 | 67 |
| 69 // Set the dimension of the entire host screen. | 68 // Set the dimension of the entire host screen. |
| 70 void SetHostSize(const gfx::Size& host_size); | 69 void SetHostSize(const SkISize& host_size); |
| 71 | 70 |
| 72 void PaintFrame(media::VideoFrame* frame, UpdatedRects* rects); | 71 void PaintFrame(media::VideoFrame* frame, RectVector* rects); |
| 73 | 72 |
| 74 // Render the rectangle of |frame| to the backing store. | 73 // Render the rectangle of |frame| to the backing store. |
| 75 // Returns true if this rectangle is not clipped. | 74 // Returns true if this rectangle is not clipped. |
| 76 bool PaintRect(media::VideoFrame* frame, const gfx::Rect& rect); | 75 bool PaintRect(media::VideoFrame* frame, const SkIRect& rect); |
| 77 | 76 |
| 78 // Blanks out a rectangle in an image. | 77 // Blanks out a rectangle in an image. |
| 79 void BlankRect(pp::ImageData& image_data, const pp::Rect& rect); | 78 void BlankRect(pp::ImageData& image_data, const pp::Rect& rect); |
| 80 | 79 |
| 81 // Perform a flush on the graphics context. | 80 // Perform a flush on the graphics context. |
| 82 void FlushGraphics(base::Time paint_start); | 81 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 // A backing store that saves the current desktop image. |
| 95 scoped_ptr<pp::ImageData> backing_store_; | 94 scoped_ptr<pp::ImageData> backing_store_; |
| 96 | 95 |
| 97 // True if there is pending paint commands in Pepper's queue. This is set to | 96 // True if there is pending paint commands in Pepper's queue. This is set to |
| 98 // true if the last flush returns a PP_ERROR_INPROGRESS error. | 97 // true if the last flush returns a PP_ERROR_INPROGRESS error. |
| 99 bool flush_blocked_; | 98 bool flush_blocked_; |
| 100 | 99 |
| 101 // The size of the plugin element. | 100 // The size of the plugin element. |
| 102 gfx::Size plugin_size_; | 101 SkISize plugin_size_; |
| 103 | 102 |
| 104 // The size of the host screen. | 103 // The size of the host screen. |
| 105 gfx::Size host_size_; | 104 SkISize host_size_; |
| 106 | 105 |
| 107 bool is_static_fill_; | 106 bool is_static_fill_; |
| 108 uint32 static_fill_color_; | 107 uint32 static_fill_color_; |
| 109 | 108 |
| 110 ScopedRunnableMethodFactory<PepperView> task_factory_; | 109 ScopedRunnableMethodFactory<PepperView> task_factory_; |
| 111 | 110 |
| 112 DISALLOW_COPY_AND_ASSIGN(PepperView); | 111 DISALLOW_COPY_AND_ASSIGN(PepperView); |
| 113 }; | 112 }; |
| 114 | 113 |
| 115 } // namespace remoting | 114 } // namespace remoting |
| 116 | 115 |
| 117 #endif // REMOTING_CLIENT_PLUGIN_PEPPER_VIEW_H_ | 116 #endif // REMOTING_CLIENT_PLUGIN_PEPPER_VIEW_H_ |
| OLD | NEW |