summaryrefslogtreecommitdiffstats
path: root/ui/gfx/buffer_format_util.h
blob: 81e7cdf30faee5ad12b9dca3dea2a915b9566bcf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright 2015 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.

#ifndef UI_GFX_BUFFER_FORMAT_UTIL_H_
#define UI_GFX_BUFFER_FORMAT_UTIL_H_

#include <stddef.h>

#include <vector>

#include "ui/gfx/buffer_types.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/gfx_export.h"

namespace gfx {

// Returns a vector containing all buffer formats.
GFX_EXPORT std::vector<BufferFormat> GetBufferFormatsForTesting();

// Returns the number of planes for |format|.
GFX_EXPORT size_t NumberOfPlanesForBufferFormat(BufferFormat format);

// Returns the subsampling factor applied to the given zero-indexed |plane| of
// |format| both horizontally and vertically.
GFX_EXPORT size_t SubsamplingFactorForBufferFormat(BufferFormat format,
                                                   int plane);

// Returns the number of bytes used to store a row of the given zero-indexed
// |plane| of |format|.
GFX_EXPORT size_t RowSizeForBufferFormat(size_t width,
                                         BufferFormat format,
                                         int plane);

// Returns the number of bytes used to store all the planes of a given |format|.
GFX_EXPORT size_t BufferSizeForBufferFormat(const Size& size,
                                            BufferFormat format);
GFX_EXPORT bool BufferSizeForBufferFormatChecked(const Size& size,
                                                 BufferFormat format,
                                                 size_t* size_in_bytes)
    WARN_UNUSED_RESULT;

GFX_EXPORT int BufferOffsetForBufferFormat(const Size& size,
                                           BufferFormat format,
                                           size_t plane);

}  // namespace gfx

#endif  // UI_GFX_BUFFER_FORMAT_UTIL_H_