| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef UI_GFX_OZONE_IMPL_SOFTWARE_SURFACE_OZONE_H_ | 5 #ifndef UI_GFX_OZONE_IMPL_DRI_SURFACE_H_ |
| 6 #define UI_GFX_OZONE_IMPL_SOFTWARE_SURFACE_OZONE_H_ | 6 #define UI_GFX_OZONE_IMPL_DRI_SURFACE_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "ui/gfx/skia_util.h" | 10 #include "ui/gfx/skia_util.h" |
| 11 | 11 |
| 12 class SkBitmapDevice; | 12 class SkBitmapDevice; |
| 13 class SkCanvas; | 13 class SkCanvas; |
| 14 | 14 |
| 15 namespace gfx { | 15 namespace gfx { |
| 16 | 16 |
| 17 class DrmSkBitmapOzone; | 17 class DriSkBitmap; |
| 18 class HardwareDisplayControllerOzone; | 18 class HardwareDisplayController; |
| 19 | 19 |
| 20 // SoftwareSurfaceOzone is used to represent a surface that can be scanned out | 20 // DriSurface is used to represent a surface that can be scanned out |
| 21 // to a monitor. It will store the internal state associated with the drawing | 21 // to a monitor. It will store the internal state associated with the drawing |
| 22 // surface associated with it. SoftwareSurfaceOzone also performs all the needed | 22 // surface associated with it. DriSurface also performs all the needed |
| 23 // operations to initialize and update the drawing surface. | 23 // operations to initialize and update the drawing surface. |
| 24 // | 24 // |
| 25 // The implementation uses dumb buffers, which is used for software rendering. | 25 // The implementation uses dumb buffers, which is used for software rendering. |
| 26 // The intent is to have one SoftwareSurfaceOzone implementation for a | 26 // The intent is to have one DriSurface implementation for a |
| 27 // HardwareDisplayControllerOzone. | 27 // HardwareDisplayController. |
| 28 // | 28 // |
| 29 // DoubleBufferedSurface is intended to be the software analog to | 29 // DoubleBufferedSurface is intended to be the software analog to |
| 30 // EGLNativeSurface while SoftwareSurfaceOzone is intended to provide the glue | 30 // EGLNativeSurface while DriSurface is intended to provide the glue |
| 31 // necessary to initialize and display the surface to the screen. | 31 // necessary to initialize and display the surface to the screen. |
| 32 // | 32 // |
| 33 // The typical usage pattern is: | 33 // The typical usage pattern is: |
| 34 // ----------------------------------------------------------------------------- | 34 // ----------------------------------------------------------------------------- |
| 35 // HardwareDisplayControllerOzone controller; | 35 // HardwareDisplayController controller; |
| 36 // // Initialize controller | 36 // // Initialize controller |
| 37 // | 37 // |
| 38 // SoftwareSurfaceOzone* surface = new SoftwareSurfaceOzone(controller); | 38 // DriSurface* surface = new DriSurface(controller); |
| 39 // surface.Initialize(); | 39 // surface.Initialize(); |
| 40 // controller.BindSurfaceToController(surface); | 40 // controller.BindSurfaceToController(surface); |
| 41 // | 41 // |
| 42 // while (true) { | 42 // while (true) { |
| 43 // SkCanvas* canvas = surface->GetDrawableForWidget(); | 43 // SkCanvas* canvas = surface->GetDrawableForWidget(); |
| 44 // DrawStuff(canvas); | 44 // DrawStuff(canvas); |
| 45 // controller.SchedulePageFlip(); | 45 // controller.SchedulePageFlip(); |
| 46 // | 46 // |
| 47 // Wait for page flip event. The DRM page flip handler will call | 47 // Wait for page flip event. The DRM page flip handler will call |
| 48 // surface.SwapBuffers(); | 48 // surface.SwapBuffers(); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 // | d | | d | | 109 // | d | | d | |
| 110 // | | | | | 110 // | | | | |
| 111 // | | | | | 111 // | | | | |
| 112 // ------- ------- | 112 // ------- ------- |
| 113 // b[0] b[1]* | 113 // b[0] b[1]* |
| 114 // | 114 // |
| 115 // The synchronization consists of copying the damaged area from the frontbuffer | 115 // The synchronization consists of copying the damaged area from the frontbuffer |
| 116 // to the backbuffer. | 116 // to the backbuffer. |
| 117 // | 117 // |
| 118 // At this point we're back to step 1 and can start a new draw iteration. | 118 // At this point we're back to step 1 and can start a new draw iteration. |
| 119 class SoftwareSurfaceOzone { | 119 class DriSurface { |
| 120 public: | 120 public: |
| 121 SoftwareSurfaceOzone(HardwareDisplayControllerOzone* controller); | 121 DriSurface(HardwareDisplayController* controller); |
| 122 | 122 |
| 123 virtual ~SoftwareSurfaceOzone(); | 123 virtual ~DriSurface(); |
| 124 | 124 |
| 125 // Used to allocate all necessary buffers for this surface. If the | 125 // Used to allocate all necessary buffers for this surface. If the |
| 126 // initialization succeeds, the device is ready to be used for drawing | 126 // initialization succeeds, the device is ready to be used for drawing |
| 127 // operations. | 127 // operations. |
| 128 // Returns true if the initialization is successful, false otherwise. | 128 // Returns true if the initialization is successful, false otherwise. |
| 129 bool Initialize(); | 129 bool Initialize(); |
| 130 | 130 |
| 131 // Returns the ID of the current backbuffer. | 131 // Returns the ID of the current backbuffer. |
| 132 uint32_t GetFramebufferId() const; | 132 uint32_t GetFramebufferId() const; |
| 133 | 133 |
| 134 // Synchronizes and swaps the back buffer with the front buffer. | 134 // Synchronizes and swaps the back buffer with the front buffer. |
| 135 void SwapBuffers(); | 135 void SwapBuffers(); |
| 136 | 136 |
| 137 // Get a Skia canvas for a backbuffer. | 137 // Get a Skia canvas for a backbuffer. |
| 138 SkCanvas* GetDrawableForWidget(); | 138 SkCanvas* GetDrawableForWidget(); |
| 139 | 139 |
| 140 private: | 140 private: |
| 141 friend class HardwareDisplayControllerOzone; | 141 friend class HardwareDisplayController; |
| 142 | 142 |
| 143 // Used to create the backing buffers. | 143 // Used to create the backing buffers. |
| 144 virtual DrmSkBitmapOzone* CreateBuffer(); | 144 virtual DriSkBitmap* CreateBuffer(); |
| 145 | 145 |
| 146 // Stores DRM information for this output device (connector, encoder, last | 146 // Stores DRM information for this output device (connector, encoder, last |
| 147 // CRTC state). | 147 // CRTC state). |
| 148 HardwareDisplayControllerOzone* controller_; | 148 HardwareDisplayController* controller_; |
| 149 | 149 |
| 150 // The actual buffers used for painting. | 150 // The actual buffers used for painting. |
| 151 scoped_ptr<DrmSkBitmapOzone> bitmaps_[2]; | 151 scoped_ptr<DriSkBitmap> bitmaps_[2]; |
| 152 | 152 |
| 153 // BitmapDevice for the current backbuffer. | 153 // BitmapDevice for the current backbuffer. |
| 154 skia::RefPtr<SkBitmapDevice> skia_device_; | 154 skia::RefPtr<SkBitmapDevice> skia_device_; |
| 155 | 155 |
| 156 // Canvas for the current backbuffer. | 156 // Canvas for the current backbuffer. |
| 157 skia::RefPtr<SkCanvas> skia_canvas_; | 157 skia::RefPtr<SkCanvas> skia_canvas_; |
| 158 | 158 |
| 159 // Keeps track of which bitmap is |buffers_| is the frontbuffer. | 159 // Keeps track of which bitmap is |buffers_| is the frontbuffer. |
| 160 int front_buffer_; | 160 int front_buffer_; |
| 161 | 161 |
| 162 DISALLOW_COPY_AND_ASSIGN(SoftwareSurfaceOzone); | 162 DISALLOW_COPY_AND_ASSIGN(DriSurface); |
| 163 }; | 163 }; |
| 164 | 164 |
| 165 } // namespace gfx | 165 } // namespace gfx |
| 166 | 166 |
| 167 #endif // UI_GFX_OZONE_IMPL_SOFTWARE_SURFACE_OZONE_H_ | 167 #endif // UI_GFX_OZONE_IMPL_DRI_SURFACE_H_ |
| OLD | NEW |