| OLD | NEW |
| 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 <list> | 11 #include <list> |
| 12 | 12 |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "ppapi/cpp/graphics_2d.h" | 14 #include "ppapi/cpp/graphics_2d.h" |
| 15 #include "ppapi/cpp/view.h" |
| 15 #include "ppapi/cpp/point.h" | 16 #include "ppapi/cpp/point.h" |
| 16 #include "remoting/client/frame_consumer.h" | 17 #include "remoting/client/frame_consumer.h" |
| 17 | 18 |
| 18 namespace base { | 19 namespace base { |
| 19 class Time; | 20 class Time; |
| 20 } // namespace base | 21 } // namespace base |
| 21 | 22 |
| 22 namespace remoting { | 23 namespace remoting { |
| 23 | 24 |
| 24 class ChromotingInstance; | 25 class ChromotingInstance; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 37 | 38 |
| 38 // FrameConsumer implementation. | 39 // FrameConsumer implementation. |
| 39 virtual void ApplyBuffer(const SkISize& view_size, | 40 virtual void ApplyBuffer(const SkISize& view_size, |
| 40 const SkIRect& clip_area, | 41 const SkIRect& clip_area, |
| 41 pp::ImageData* buffer, | 42 pp::ImageData* buffer, |
| 42 const SkRegion& region) OVERRIDE; | 43 const SkRegion& region) OVERRIDE; |
| 43 virtual void ReturnBuffer(pp::ImageData* buffer) OVERRIDE; | 44 virtual void ReturnBuffer(pp::ImageData* buffer) OVERRIDE; |
| 44 virtual void SetSourceSize(const SkISize& source_size, | 45 virtual void SetSourceSize(const SkISize& source_size, |
| 45 const SkIPoint& dpi) OVERRIDE; | 46 const SkIPoint& dpi) OVERRIDE; |
| 46 | 47 |
| 47 // Sets the display size and clipping area of this view. | 48 // Updates the PepperView's size, clipping area and scale factor. |
| 48 void SetView(const SkISize& view_size, const SkIRect& clip_area); | 49 void SetView(const pp::View& view); |
| 49 | 50 |
| 50 // Return the client view and original host dimensions. | 51 // Return the dimensions of the view and source in device pixels. |
| 51 const SkISize& get_view_size() const { | 52 const SkISize& get_view_size() const { |
| 52 return view_size_; | 53 return view_size_; |
| 53 } | 54 } |
| 54 const SkISize& get_screen_size() const { | 55 const SkISize& get_screen_size() const { |
| 55 return source_size_; | 56 return source_size_; |
| 56 } | 57 } |
| 57 | 58 |
| 59 // Return the dimensions of the view in Density Independent Pixels (DIPs). |
| 60 // On high-DPI devices this will be smaller than the size in device pixels. |
| 61 const SkISize& get_view_size_dips() const { |
| 62 return view_size_dips_; |
| 63 } |
| 64 |
| 58 private: | 65 private: |
| 59 // This routine allocates an image buffer. | 66 // This routine allocates an image buffer. |
| 60 pp::ImageData* AllocateBuffer(); | 67 pp::ImageData* AllocateBuffer(); |
| 61 | 68 |
| 62 // This routine frees an image buffer allocated by AllocateBuffer(). | 69 // This routine frees an image buffer allocated by AllocateBuffer(). |
| 63 void FreeBuffer(pp::ImageData* buffer); | 70 void FreeBuffer(pp::ImageData* buffer); |
| 64 | 71 |
| 65 // This routine makes sure that enough image buffers are in flight to keep | 72 // This routine makes sure that enough image buffers are in flight to keep |
| 66 // the decoding pipeline busy. | 73 // the decoding pipeline busy. |
| 67 void InitiateDrawing(); | 74 void InitiateDrawing(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 84 // Context should be constant for the lifetime of the plugin. | 91 // Context should be constant for the lifetime of the plugin. |
| 85 ClientContext* const context_; | 92 ClientContext* const context_; |
| 86 | 93 |
| 87 pp::Graphics2D graphics2d_; | 94 pp::Graphics2D graphics2d_; |
| 88 | 95 |
| 89 FrameProducer* producer_; | 96 FrameProducer* producer_; |
| 90 | 97 |
| 91 // List of allocated image buffers. | 98 // List of allocated image buffers. |
| 92 std::list<pp::ImageData*> buffers_; | 99 std::list<pp::ImageData*> buffers_; |
| 93 | 100 |
| 101 // Queued buffer to paint, with clip area and dirty region in device pixels. |
| 94 pp::ImageData* merge_buffer_; | 102 pp::ImageData* merge_buffer_; |
| 95 SkIRect merge_clip_area_; | 103 SkIRect merge_clip_area_; |
| 96 SkRegion merge_region_; | 104 SkRegion merge_region_; |
| 97 | 105 |
| 98 // The size of the plugin element. | 106 // View size, clip area and host dimensions, in device pixels. |
| 99 SkISize view_size_; | 107 SkISize view_size_; |
| 100 | |
| 101 // The current clip area rectangle. | |
| 102 SkIRect clip_area_; | 108 SkIRect clip_area_; |
| 103 | |
| 104 // The size of the host screen. | |
| 105 SkISize source_size_; | 109 SkISize source_size_; |
| 106 | 110 |
| 107 // The DPI of the host screen. | 111 // The DPI of the host screen. |
| 108 SkIPoint source_dpi_; | 112 SkIPoint source_dpi_; |
| 109 | 113 |
| 114 // View size in Density-Independent pixels. |
| 115 SkISize view_size_dips_; |
| 116 |
| 117 // DIP-to-device pixel scale factor. |
| 118 float view_scale_; |
| 119 |
| 110 // True if there is already a Flush() pending on the Graphics2D context. | 120 // True if there is already a Flush() pending on the Graphics2D context. |
| 111 bool flush_pending_; | 121 bool flush_pending_; |
| 112 | 122 |
| 113 // True after Initialize() has been called, until TearDown(). | 123 // True after Initialize() has been called, until TearDown(). |
| 114 bool is_initialized_; | 124 bool is_initialized_; |
| 115 | 125 |
| 116 // True after the first call to ApplyBuffer(). | 126 // True after the first call to ApplyBuffer(). |
| 117 bool frame_received_; | 127 bool frame_received_; |
| 118 | 128 |
| 119 DISALLOW_COPY_AND_ASSIGN(PepperView); | 129 DISALLOW_COPY_AND_ASSIGN(PepperView); |
| 120 }; | 130 }; |
| 121 | 131 |
| 122 } // namespace remoting | 132 } // namespace remoting |
| 123 | 133 |
| 124 #endif // REMOTING_CLIENT_PLUGIN_PEPPER_VIEW_H_ | 134 #endif // REMOTING_CLIENT_PLUGIN_PEPPER_VIEW_H_ |
| OLD | NEW |