blob: 570f724b8e7a7b8a825d0ffca7676be4bec582e5 [file] [log] [blame]
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/memory/scoped_refptr.h"
#include "base/threading/thread_checker.h"
#include "media/base/video_frame.h"
#include "media/base/video_types.h"
#include "ui/gfx/buffer_types.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/gpu_memory_buffer.h"
namespace media {
namespace test {
// A helper class used to manage the lifetime of a Texture. Can be backed by
// either a buffer allocated by the VDA, or by a preallocated pixmap.
class TextureRef : public base::RefCounted<TextureRef> {
static scoped_refptr<TextureRef> Create(
uint32_t texture_id,
base::OnceClosure no_longer_needed_cb);
static scoped_refptr<TextureRef> CreatePreallocated(
uint32_t texture_id,
base::OnceClosure no_longer_needed_cb,
VideoPixelFormat pixel_format,
const gfx::Size& size,
gfx::BufferUsage buffer_usage);
gfx::GpuMemoryBufferHandle ExportGpuMemoryBufferHandle() const;
scoped_refptr<VideoFrame> ExportVideoFrame(gfx::Rect visible_rect) const;
// Return true if contains data in a buffer and format directly mappable and
// readable (e.g. not tiled), without a need to first format convert it.
// TODO( Remove this once it is doable to get tiled
// information in media::VideoFrame.
bool IsDirectlyMappable() const;
int32_t texture_id() const { return texture_id_; }
friend class base::RefCounted<TextureRef>;
TextureRef(uint32_t texture_id, base::OnceClosure no_longer_needed_cb);
uint32_t texture_id_;
base::OnceClosure no_longer_needed_cb_;
#if defined(OS_CHROMEOS)
scoped_refptr<VideoFrame> frame_;
} // namespace test
} // namespace media