10#if defined(SK_BUILD_FOR_ANDROID) && __ANDROID_API__ >= 26
25#if defined(SK_GRAPHITE)
45 AHardwareBuffer_release(
buffer);
62#if defined(SK_GRAPHITE)
90#if defined(SK_GRAPHITE)
95 skgpu::Mipmapped::kNo,
107 AHardwareBuffer_Desc hwbDesc;
108 hwbDesc.width =
width;
111 hwbDesc.usage = AHARDWAREBUFFER_USAGE_CPU_READ_NEVER |
112 AHARDWAREBUFFER_USAGE_CPU_WRITE_NEVER |
113 AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE |
114 AHARDWAREBUFFER_USAGE_GPU_COLOR_OUTPUT;
116 hwbDesc.usage |= AHARDWAREBUFFER_USAGE_PROTECTED_CONTENT;
118 hwbDesc.format = AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM;
124 if (
int error = AHardwareBuffer_allocate(&hwbDesc, &
buffer)) {
125 SkDebugf(
"Failed to allocated hardware buffer, error: %d\n",
error);
140 SkDebugf(
"Failed to make SkSurface.\n");
146 return surf->makeImageSnapshot();
156 sk_sp<SkSurface> tmpSurface = create_protected_render_target(dContext, recorder, ii);
163 return tmpSurface->makeImageSnapshot();
168class ProtectedSlide :
public Slide {
170 ProtectedSlide() {
fName =
"Protected"; }
180#if defined(SK_GANESH)
187#if defined(SK_GRAPHITE)
188 if (recorder && recorder->
priv().
isProtected() == skgpu::Protected::kNo) {
194 if (!dContext && !recorder) {
203 sk_sp<SkImage> protectedSkImage = create_protected_skia_image(dContext, recorder,
216 sk_sp<SkSurface> tmpS = create_protected_render_target(dContext, recorder, ii);
219 tmpS->getCanvas()->drawCircle(64, 64, 32,
SkPaint());
222 tmpS->getCanvas()->drawImage(imgToUse, 0, 0);
223 indirectImg = tmpS->makeImageSnapshot();
229 protectedAHBImage.
reset();
230 protectedSkImage.
reset();
235 static const int kSize = 128;
struct AHardwareBuffer AHardwareBuffer
static GrDirectContext * GrAsDirectContext(GrContext_Base *base)
@ kTopLeft_GrSurfaceOrigin
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
constexpr SkColor SK_ColorMAGENTA
constexpr SkColor SK_ColorTRANSPARENT
constexpr SkColor SK_ColorBLUE
constexpr SkColor SK_ColorRED
constexpr SkColor SK_ColorGREEN
constexpr SkColor SK_ColorDKGRAY
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
SK_API bool supportsProtectedContent() const
virtual GrRecordingContext * recordingContext() const
virtual skgpu::graphite::Recorder * recorder() const
void clear(SkColor color)
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
virtual SkISize getDimensions() const
virtual void draw(SkCanvas *canvas)=0
void reset(T *ptr=nullptr)
Protected isProtected() const
static constexpr int kSize
static const uint8_t buffer[]
const uint8_t uint32_t uint32_t GError ** error
SK_API sk_sp< SkSurface > WrapAndroidHardwareBuffer(skgpu::graphite::Recorder *recorder, AHardwareBuffer *hardwareBuffer, sk_sp< SkColorSpace > colorSpace, const SkSurfaceProps *surfaceProps, BufferReleaseProc=nullptr, ReleaseContext=nullptr, bool fromWindow=false)
SK_API sk_sp< SkSurface > RenderTarget(GrRecordingContext *context, skgpu::Budgeted budgeted, const SkImageInfo &imageInfo, int sampleCount, GrSurfaceOrigin surfaceOrigin, const SkSurfaceProps *surfaceProps, bool shouldCreateWithMips=false, bool isProtected=false)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)