skia2/tools/gpu/YUVUtils.h
Michael Ludwig d9958f865c Use YUV effect in drawEdgeAAImageSet
Adds YUV planar image to the compositor_quads_image GM, confirmed
locally that it uses the effect instead of flattening the planes
into a single proxy (like before).

Bug: skia:
Change-Id: I0dea16bbaae34ae44cb1b51db9d2953231a6bf22
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201619
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2019-03-21 17:43:28 +00:00

55 lines
1.4 KiB
C++

/*
* Copyright 2019 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef YUVUtils_DEFINED
#define YUVUtils_DEFINED
#include "SkAutoMalloc.h"
#include "SkImage.h"
#include "SkYUVAIndex.h"
#include "SkYUVASizeInfo.h"
class SkData;
namespace sk_gpu_test {
// Utility that decodes a JPEG but preserves the YUVA8 planes in the image, and uses
// MakeFromYUVAPixmaps to create a GPU multiplane YUVA image for a context. It extracts the planar
// data once, and lazily creates the actual SkImage when the GrContext is provided (and refreshes
// the image if the context has changed, as in Viewer)
class LazyYUVImage {
public:
// Returns null if the data could not be extracted into YUVA8 planes
static std::unique_ptr<LazyYUVImage> Make(sk_sp<SkData> data);
sk_sp<SkImage> refImage(GrContext* context);
const SkImage* getImage(GrContext* context);
private:
// Decoded YUV data
SkYUVASizeInfo fSizeInfo;
SkYUVColorSpace fColorSpace;
SkYUVAIndex fComponents[SkYUVAIndex::kIndexCount];
SkAutoMalloc fPlaneData;
SkPixmap fPlanes[SkYUVASizeInfo::kMaxCount];
// Memoized SkImage formed with planes
sk_sp<SkImage> fYUVImage;
uint32_t fOwningContextID;
LazyYUVImage() : fOwningContextID(SK_InvalidGenID) {}
bool reset(sk_sp<SkData> data);
bool ensureYUVImage(GrContext* context);
};
} // namespace sk_gpu_test
#endif // YUVUtils_DEFINED