skia2/tools/gpu/YUVUtils.h
Mike Klein c0bd9f9fe5 rewrite includes to not need so much -Ifoo
Current strategy: everything from the top

Things to look at first are the manual changes:

   - added tools/rewrite_includes.py
   - removed -Idirectives from BUILD.gn
   - various compile.sh simplifications
   - tweak tools/embed_resources.py
   - update gn/find_headers.py to write paths from the top
   - update gn/gn_to_bp.py SkUserConfig.h layout
     so that #include "include/config/SkUserConfig.h" always
     gets the header we want.

No-Presubmit: true
Change-Id: I73a4b181654e0e38d229bc456c0d0854bae3363e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/209706
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Hal Canary <halcanary@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
2019-04-24 16:27:11 +00:00

55 lines
1.5 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 "include/core/SkImage.h"
#include "include/core/SkYUVAIndex.h"
#include "include/core/SkYUVASizeInfo.h"
#include "src/core/SkAutoMalloc.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