skia2/include/gpu/GrYUVABackendTextures.h
Brian Salomon c1a249d1dc Revert "Revert "New variant of SkImage::MakeFromYUVATextures.""
This reverts commit be8004d2fb.

Bug: skia:10632
Change-Id: I52dd36ae167623563c7554c40092442a3822ee3c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/327760
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2020-10-19 15:37:29 +00:00

61 lines
1.7 KiB
C++

/*
* Copyright 2020 Google LLC
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef GrYUVABackendTextures_DEFINED
#define GrYUVABackendTextures_DEFINED
#include "include/core/SkYUVAInfo.h"
#include "include/gpu/GrBackendSurface.h"
#include <tuple>
struct SkYUVASizeInfo;
struct SkYUVAIndex;
/**
* A set of GrBackendTextures that hold the planar data for a SkYUVAInfo.
*/
class SK_API GrYUVABackendTextures {
public:
GrYUVABackendTextures() = default;
GrYUVABackendTextures(const GrYUVABackendTextures&) = delete;
GrYUVABackendTextures(GrYUVABackendTextures&&) = default;
GrYUVABackendTextures& operator=(const GrYUVABackendTextures&) = delete;
GrYUVABackendTextures& operator=(GrYUVABackendTextures&&) = default;
GrYUVABackendTextures(const SkYUVAInfo&,
const GrBackendTexture[SkYUVAInfo::kMaxPlanes],
GrSurfaceOrigin textureOrigin);
const std::array<GrBackendTexture, SkYUVAInfo::kMaxPlanes>& textures() const {
return fTextures;
}
GrBackendTexture texture(int i) const {
SkASSERT(i >= 0 && i < SkYUVAInfo::kMaxPlanes);
return fTextures[static_cast<size_t>(i)];
}
const SkYUVAInfo& yuvaInfo() const { return fYUVAInfo; }
int numPlanes() const { return fYUVAInfo.numPlanes(); }
GrSurfaceOrigin textureOrigin() const { return fTextureOrigin; }
bool isValid() const { return fYUVAInfo.isValid(); }
bool toYUVAIndices(SkYUVAIndex[SkYUVAIndex::kIndexCount]) const;
private:
SkYUVAInfo fYUVAInfo;
std::array<GrBackendTexture, SkYUVAInfo::kMaxPlanes> fTextures;
GrSurfaceOrigin fTextureOrigin = kTopLeft_GrSurfaceOrigin;
};
#endif