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
3 // found in the LICENSE file.
5 #ifndef UI_OZONE_PLATFORM_DRM_GPU_GBM_BUFFER_H_
6 #define UI_OZONE_PLATFORM_DRM_GPU_GBM_BUFFER_H_
8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "ui/gfx/buffer_types.h"
11 #include "ui/gfx/geometry/size.h"
12 #include "ui/ozone/platform/drm/gpu/gbm_buffer_base.h"
13 #include "ui/ozone/platform/drm/gpu/screen_manager.h"
14 #include "ui/ozone/public/native_pixmap.h"
22 class GbmBuffer
: public GbmBufferBase
{
24 static scoped_refptr
<GbmBuffer
> CreateBuffer(
25 const scoped_refptr
<GbmDevice
>& gbm
,
26 gfx::BufferFormat format
,
27 const gfx::Size
& size
,
28 gfx::BufferUsage usage
);
29 gfx::BufferUsage
GetUsage() const { return usage_
; }
32 GbmBuffer(const scoped_refptr
<GbmDevice
>& gbm
,
34 gfx::BufferUsage usage
);
35 ~GbmBuffer() override
;
37 gfx::BufferUsage usage_
;
39 DISALLOW_COPY_AND_ASSIGN(GbmBuffer
);
42 class GbmPixmap
: public NativePixmap
{
44 GbmPixmap(const scoped_refptr
<GbmBuffer
>& buffer
,
45 ScreenManager
* screen_manager
);
47 void SetScalingCallback(const ScalingCallback
& scaling_callback
) override
;
48 scoped_refptr
<NativePixmap
> GetScaledPixmap(gfx::Size new_size
) override
;
51 void* GetEGLClientBuffer() override
;
52 int GetDmaBufFd() override
;
53 int GetDmaBufPitch() override
;
54 bool ScheduleOverlayPlane(gfx::AcceleratedWidget widget
,
56 gfx::OverlayTransform plane_transform
,
57 const gfx::Rect
& display_bounds
,
58 const gfx::RectF
& crop_rect
) override
;
59 gfx::NativePixmapHandle
ExportHandle() override
;
61 scoped_refptr
<GbmBuffer
> buffer() { return buffer_
; }
64 ~GbmPixmap() override
;
65 bool ShouldApplyScaling(const gfx::Rect
& display_bounds
,
66 const gfx::RectF
& crop_rect
,
67 gfx::Size
* required_size
);
69 scoped_refptr
<GbmBuffer
> buffer_
;
72 ScreenManager
* screen_manager_
; // Not owned.
74 ScalingCallback scaling_callback_
;
76 DISALLOW_COPY_AND_ASSIGN(GbmPixmap
);
81 #endif // UI_OZONE_PLATFORM_DRM_GPU_GBM_BUFFER_H_