blob: 347d00de02d56eaacaf7c3ef4b34804dc4f4a880 [file] [log] [blame]
Brian Salomonc1a249d2020-10-19 10:55:45 -04001/*
2 * Copyright 2020 Google LLC
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef GrYUVABackendTextures_DEFINED
9#define GrYUVABackendTextures_DEFINED
10
11#include "include/core/SkYUVAInfo.h"
12#include "include/gpu/GrBackendSurface.h"
13
14#include <tuple>
15
16struct SkYUVASizeInfo;
17struct SkYUVAIndex;
18
19/**
20 * A set of GrBackendTextures that hold the planar data for a SkYUVAInfo.
21 */
22class SK_API GrYUVABackendTextures {
23public:
24 GrYUVABackendTextures() = default;
25 GrYUVABackendTextures(const GrYUVABackendTextures&) = delete;
26 GrYUVABackendTextures(GrYUVABackendTextures&&) = default;
27
28 GrYUVABackendTextures& operator=(const GrYUVABackendTextures&) = delete;
29 GrYUVABackendTextures& operator=(GrYUVABackendTextures&&) = default;
30
31 GrYUVABackendTextures(const SkYUVAInfo&,
32 const GrBackendTexture[SkYUVAInfo::kMaxPlanes],
33 GrSurfaceOrigin textureOrigin);
34
35 const std::array<GrBackendTexture, SkYUVAInfo::kMaxPlanes>& textures() const {
36 return fTextures;
37 }
38
39 GrBackendTexture texture(int i) const {
40 SkASSERT(i >= 0 && i < SkYUVAInfo::kMaxPlanes);
41 return fTextures[static_cast<size_t>(i)];
42 }
43
44 const SkYUVAInfo& yuvaInfo() const { return fYUVAInfo; }
45
46 int numPlanes() const { return fYUVAInfo.numPlanes(); }
47
48 GrSurfaceOrigin textureOrigin() const { return fTextureOrigin; }
49
50 bool isValid() const { return fYUVAInfo.isValid(); }
51
52 bool toYUVAIndices(SkYUVAIndex[SkYUVAIndex::kIndexCount]) const;
53
54private:
55 SkYUVAInfo fYUVAInfo;
56 std::array<GrBackendTexture, SkYUVAInfo::kMaxPlanes> fTextures;
57 GrSurfaceOrigin fTextureOrigin = kTopLeft_GrSurfaceOrigin;
58};
59
60#endif