| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_OZONE_PLATFORM_DRI_DRI_BUFFER_H_ | 5 #ifndef UI_OZONE_PLATFORM_DRI_DRI_BUFFER_H_ |
| 6 #define UI_OZONE_PLATFORM_DRI_DRI_BUFFER_H_ | 6 #define UI_OZONE_PLATFORM_DRI_DRI_BUFFER_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "skia/ext/refptr.h" | 9 #include "skia/ext/refptr.h" |
| 10 #include "third_party/skia/include/core/SkSurface.h" | 10 #include "third_party/skia/include/core/SkSurface.h" |
| 11 | 11 #include "ui/ozone/platform/dri/scanout_buffer.h" |
| 12 class SkCanvas; | |
| 13 | 12 |
| 14 namespace ui { | 13 namespace ui { |
| 15 | 14 |
| 16 class DriWrapper; | 15 class DriWrapper; |
| 17 | 16 |
| 18 // Wrapper for a DRM allocated buffer. Keeps track of the native properties of | 17 // Wrapper for a DRM allocated buffer. Keeps track of the native properties of |
| 19 // the buffer and wraps the pixel memory into a SkSurface which can be used to | 18 // the buffer and wraps the pixel memory into a SkSurface which can be used to |
| 20 // draw into using Skia. | 19 // draw into using Skia. |
| 21 class DriBuffer { | 20 class DriBuffer : public ScanoutBuffer { |
| 22 public: | 21 public: |
| 23 DriBuffer(DriWrapper* dri); | 22 DriBuffer(DriWrapper* dri); |
| 24 ~DriBuffer(); | |
| 25 | |
| 26 uint32_t stride() const { return stride_; } | |
| 27 uint32_t handle() const { return handle_; } | |
| 28 uint32_t framebuffer() const { return framebuffer_; } | |
| 29 SkCanvas* canvas() { return surface_->getCanvas(); } | |
| 30 | 23 |
| 31 // Allocates the backing pixels and wraps them in |surface_|. |info| is used | 24 // Allocates the backing pixels and wraps them in |surface_|. |info| is used |
| 32 // to describe the buffer characteristics (size, color format). | 25 // to describe the buffer characteristics (size, color format). |
| 33 bool Initialize(const SkImageInfo& info); | 26 bool Initialize(const SkImageInfo& info); |
| 34 | 27 |
| 35 private: | 28 SkCanvas* GetCanvas() const; |
| 29 |
| 30 // ScanoutBuffer: |
| 31 virtual uint32_t GetFramebufferId() const OVERRIDE; |
| 32 virtual uint32_t GetHandle() const OVERRIDE; |
| 33 virtual gfx::Size GetSize() const OVERRIDE; |
| 34 |
| 35 // NativePixmap: |
| 36 virtual void* GetEGLClientBuffer() OVERRIDE; |
| 37 virtual int GetDmaBufFd() OVERRIDE; |
| 38 |
| 39 protected: |
| 40 virtual ~DriBuffer(); |
| 41 |
| 36 DriWrapper* dri_; // Not owned. | 42 DriWrapper* dri_; // Not owned. |
| 37 | 43 |
| 38 // Wrapper around the native pixel memory. | 44 // Wrapper around the native pixel memory. |
| 39 skia::RefPtr<SkSurface> surface_; | 45 skia::RefPtr<SkSurface> surface_; |
| 40 | 46 |
| 41 // Length of a row of pixels. | 47 // Length of a row of pixels. |
| 42 uint32_t stride_; | 48 uint32_t stride_; |
| 43 | 49 |
| 44 // Buffer handle used by the DRM allocator. | 50 // Buffer handle used by the DRM allocator. |
| 45 uint32_t handle_; | 51 uint32_t handle_; |
| 46 | 52 |
| 47 // Buffer ID used by the DRM modesettings API. This is set when the buffer is | 53 // Buffer ID used by the DRM modesettings API. This is set when the buffer is |
| 48 // registered with the CRTC. | 54 // registered with the CRTC. |
| 49 uint32_t framebuffer_; | 55 uint32_t framebuffer_; |
| 50 | 56 |
| 51 DISALLOW_COPY_AND_ASSIGN(DriBuffer); | 57 DISALLOW_COPY_AND_ASSIGN(DriBuffer); |
| 52 }; | 58 }; |
| 53 | 59 |
| 60 class DriBufferGenerator : public ScanoutBufferGenerator { |
| 61 public: |
| 62 DriBufferGenerator(DriWrapper* dri); |
| 63 virtual ~DriBufferGenerator(); |
| 64 |
| 65 // ScanoutBufferGenerator: |
| 66 virtual scoped_refptr<ScanoutBuffer> Create(const gfx::Size& size) OVERRIDE; |
| 67 |
| 68 private: |
| 69 DriWrapper* dri_; // Not owned. |
| 70 |
| 71 DISALLOW_COPY_AND_ASSIGN(DriBufferGenerator); |
| 72 }; |
| 73 |
| 54 } // namespace ui | 74 } // namespace ui |
| 55 | 75 |
| 56 #endif // UI_OZONE_PLATFORM_DRI_DRI_BUFFER_H_ | 76 #endif // UI_OZONE_PLATFORM_DRI_DRI_BUFFER_H_ |
| OLD | NEW |