Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
GrAHardwareBufferImageGenerator.h
Go to the documentation of this file.
1/*
2 * Copyright 2017 Google Inc.
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#ifndef GrAHardwareBufferImageGenerator_DEFINED
8#define GrAHardwareBufferImageGenerator_DEFINED
9
12
13class GrGpuResource;
15
16extern "C" {
18}
19
20/**
21 * GrAHardwareBufferImageGenerator allows to create an SkImage attached to
22 * an existing android native hardware buffer. A hardware buffer has to be
23 * created with AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE usage, because it is
24 * bound to an external texture using an EGLImage. The image generator will
25 * keep a reference to the hardware buffer for its lifetime. A hardware buffer
26 * can be shared between processes and same buffer can be used in multiple GPU
27 * contexts.
28 * To implement certain features like tiling, Skia may copy the texture to
29 * avoid OpenGL API limitations.
30 */
32public:
33 static std::unique_ptr<SkImageGenerator> Make(AHardwareBuffer*, SkAlphaType,
35
37
38 static void DeleteGLTexture(void* ctx);
39
40private:
42 bool isProtectedContent, uint32_t bufferFormat,
43 GrSurfaceOrigin surfaceOrigin);
44
45 bool onIsValid(GrRecordingContext*) const override;
46
48 const SkImageInfo&,
50 GrImageTexGenPolicy) override;
51
52 GrSurfaceOrigin origin() const override { return fSurfaceOrigin; }
53
54 GrSurfaceProxyView makeView(GrRecordingContext* context);
55
56 void releaseTextureRef();
57
58 static void ReleaseRefHelper_TextureReleaseProc(void* ctx);
59
60 AHardwareBuffer* fHardwareBuffer;
61 uint32_t fBufferFormat;
62 const bool fIsProtectedContent;
63 GrSurfaceOrigin fSurfaceOrigin;
64};
65#endif // GrAHardwareBufferImageGenerator_DEFINED
struct AHardwareBuffer AHardwareBuffer
GrSurfaceOrigin
Definition GrTypes.h:147
SkAlphaType
Definition SkAlphaType.h:26
GrImageTexGenPolicy
Definition SkGr.h:141
bool onIsValid(GrRecordingContext *) const override
static std::unique_ptr< SkImageGenerator > Make(AHardwareBuffer *, SkAlphaType, sk_sp< SkColorSpace >, GrSurfaceOrigin)
GrSurfaceOrigin origin() const override
static void DeleteGLTexture(void *ctx)
GrSurfaceProxyView onGenerateTexture(GrRecordingContext *, const SkImageInfo &, skgpu::Mipmapped, GrImageTexGenPolicy) override
Mipmapped
Definition GpuTypes.h:53