1 // Copyright 2015 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_GFX_BUFFER_FORMAT_UTIL_H_
6 #define UI_GFX_BUFFER_FORMAT_UTIL_H_
8 #include "base/basictypes.h"
9 #include "ui/gfx/buffer_types.h"
10 #include "ui/gfx/geometry/size.h"
11 #include "ui/gfx/gfx_export.h"
15 // Returns the number of planes for |format|.
16 GFX_EXPORT
size_t NumberOfPlanesForBufferFormat(BufferFormat format
);
18 // Returns the subsampling factor applied to the given zero-indexed |plane| of
19 // |format| both horizontally and vertically.
20 GFX_EXPORT
size_t SubsamplingFactorForBufferFormat(
21 BufferFormat format
, int plane
);
23 // Returns the number of bytes used to store a row of the given zero-indexed
24 // |plane| of |format|.
25 GFX_EXPORT
size_t RowSizeForBufferFormat(
26 size_t width
, gfx::BufferFormat format
, int plane
);
27 GFX_EXPORT
bool RowSizeForBufferFormatChecked(
28 size_t width
, gfx::BufferFormat format
, int plane
, size_t* size_in_bytes
)
31 // Returns the number of bytes used to store all the planes of a given |format|.
32 GFX_EXPORT
size_t BufferSizeForBufferFormat(
33 const Size
& size
, gfx::BufferFormat format
);
34 GFX_EXPORT
bool BufferSizeForBufferFormatChecked(
35 const Size
& size
, gfx::BufferFormat format
, size_t* size_in_bytes
)
40 #endif // UI_GFX_BUFFER_FORMAT_UTIL_H_