blob: ba1a4f9f15a5243b3536ac66d78f2941e5e1d43c [file] [log] [blame]
// Copyright 2020 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SCREEN_CAPTURE_UTILS_BO_IMPORT_CAPTURE_H_
#define SCREEN_CAPTURE_UTILS_BO_IMPORT_CAPTURE_H_
#include <stdint.h>
#include <memory>
#include <base/files/scoped_file.h>
#include <base/macros.h>
#include <gbm.h>
#include "screen-capture-utils/capture.h"
#include "screen-capture-utils/ptr_util.h"
namespace screenshot {
class Crtc;
class ScopedMapData;
// Utility class to map/unmap GBM buffer with RAII.
class GbmBoDisplayBuffer : public DisplayBuffer {
public:
GbmBoDisplayBuffer(const Crtc* crtc,
uint32_t x,
uint32_t y,
uint32_t width,
uint32_t height);
GbmBoDisplayBuffer(const GbmBoDisplayBuffer&) = delete;
GbmBoDisplayBuffer& operator=(const GbmBoDisplayBuffer&) = delete;
~GbmBoDisplayBuffer() override;
DisplayBuffer::Result Capture() override;
private:
const Crtc& crtc_;
const ScopedGbmDevicePtr device_;
const uint32_t x_;
const uint32_t y_;
const uint32_t width_;
const uint32_t height_;
ScopedGbmBoPtr bo_{nullptr};
uint32_t stride_{0};
std::unique_ptr<ScopedMapData> map_data_{nullptr};
};
} // namespace screenshot
#endif // SCREEN_CAPTURE_UTILS_BO_IMPORT_CAPTURE_H_