| 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 |
| 12 class SkCanvas; | 12 class SkCanvas; |
| 13 | 13 |
| 14 namespace ui { | 14 namespace ui { |
| 15 | 15 |
| 16 class DriWrapper; | 16 class DriWrapper; |
| 17 | 17 |
| 18 // Wrapper for a DRM allocated buffer. Keeps track of the native properties of | 18 // 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 | 19 // the buffer and wraps the pixel memory into a SkSurface which can be used to |
| 20 // draw into using Skia. | 20 // draw into using Skia. |
| 21 class DriBuffer { | 21 class DriBuffer { |
| 22 public: | 22 public: |
| 23 DriBuffer(DriWrapper* dri); | 23 DriBuffer(DriWrapper* dri); |
| 24 virtual ~DriBuffer(); | 24 ~DriBuffer(); |
| 25 | 25 |
| 26 uint32_t stride() const { return stride_; } | 26 uint32_t stride() const { return stride_; } |
| 27 uint32_t handle() const { return handle_; } | 27 uint32_t handle() const { return handle_; } |
| 28 uint32_t framebuffer() const { return framebuffer_; } | 28 uint32_t framebuffer() const { return framebuffer_; } |
| 29 SkCanvas* canvas() { return surface_->getCanvas(); } | 29 SkCanvas* canvas() { return surface_->getCanvas(); } |
| 30 | 30 |
| 31 // Allocates the backing pixels and wraps them in |surface_|. |info| is used | 31 // Allocates the backing pixels and wraps them in |surface_|. |info| is used |
| 32 // to describe the buffer characteristics (size, color format). | 32 // to describe the buffer characteristics (size, color format). |
| 33 virtual bool Initialize(const SkImageInfo& info); | 33 bool Initialize(const SkImageInfo& info); |
| 34 | 34 |
| 35 protected: | 35 private: |
| 36 DriWrapper* dri_; // Not owned. | 36 DriWrapper* dri_; // Not owned. |
| 37 | 37 |
| 38 // Wrapper around the native pixel memory. | 38 // Wrapper around the native pixel memory. |
| 39 skia::RefPtr<SkSurface> surface_; | 39 skia::RefPtr<SkSurface> surface_; |
| 40 | 40 |
| 41 // Length of a row of pixels. | 41 // Length of a row of pixels. |
| 42 uint32_t stride_; | 42 uint32_t stride_; |
| 43 | 43 |
| 44 // Buffer handle used by the DRM allocator. | 44 // Buffer handle used by the DRM allocator. |
| 45 uint32_t handle_; | 45 uint32_t handle_; |
| 46 | 46 |
| 47 // Buffer ID used by the DRM modesettings API. This is set when the buffer is | 47 // Buffer ID used by the DRM modesettings API. This is set when the buffer is |
| 48 // registered with the CRTC. | 48 // registered with the CRTC. |
| 49 uint32_t framebuffer_; | 49 uint32_t framebuffer_; |
| 50 | 50 |
| 51 DISALLOW_COPY_AND_ASSIGN(DriBuffer); | 51 DISALLOW_COPY_AND_ASSIGN(DriBuffer); |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 } // namespace ui | 54 } // namespace ui |
| 55 | 55 |
| 56 #endif // UI_OZONE_PLATFORM_DRI_DRI_BUFFER_H_ | 56 #endif // UI_OZONE_PLATFORM_DRI_DRI_BUFFER_H_ |
| OLD | NEW |