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 #include "ui/ozone/platform/drm/gpu/drm_console_buffer.h"
8 #include <xf86drmMode.h>
10 #include "third_party/skia/include/core/SkCanvas.h"
11 #include "ui/ozone/platform/drm/gpu/drm_device.h"
12 #include "ui/ozone/platform/drm/gpu/drm_util.h"
13 #include "ui/ozone/platform/drm/gpu/scoped_drm_types.h"
17 DrmConsoleBuffer::DrmConsoleBuffer(const scoped_refptr
<DrmDevice
>& drm
,
21 framebuffer_(framebuffer
),
26 DrmConsoleBuffer::~DrmConsoleBuffer() {
28 if (munmap(mmap_base_
, mmap_size_
))
29 PLOG(ERROR
) << "munmap";
32 bool DrmConsoleBuffer::Initialize() {
33 ScopedDrmFramebufferPtr
fb(drm_
->GetFramebuffer(framebuffer_
));
40 SkImageInfo info
= SkImageInfo::MakeN32Premul(fb
->width
, fb
->height
);
42 mmap_size_
= info
.getSafeSize(stride_
);
44 if (!MapDumbBuffer(drm_
->get_fd(), fb
->handle
, mmap_size_
, &mmap_base_
)) {
50 skia::AdoptRef(SkSurface::NewRasterDirect(info
, mmap_base_
, stride_
));