10#if __ANDROID_API__ >= 26
66 intptr_t pixels =
reinterpret_cast<intptr_t
>(bmp.
getPixels());
83 const uint32_t srcPixel = *expectedBitmap.
getAddr32(
x,
y);
84 const uint32_t dstPixel = *actualBitmap.
getAddr32(
x,
y);
85 if (srcPixel != dstPixel) {
86 ERRORF(
reporter,
"Expected readback pixel (%d, %d) value 0x%08x, got 0x%08x.",
87 x,
y, srcPixel, dstPixel);
100 bool forSurface,
bool isProtected,
103 AHardwareBuffer_Desc hwbDesc;
104 hwbDesc.width =
width;
107 hwbDesc.usage = AHARDWAREBUFFER_USAGE_CPU_READ_NEVER |
108 AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE |
109 (isProtected ? AHARDWAREBUFFER_USAGE_PROTECTED_CONTENT : 0);
113 hwbDesc.usage |= AHARDWAREBUFFER_USAGE_CPU_WRITE_NEVER |
114 AHARDWAREBUFFER_USAGE_GPU_COLOR_OUTPUT;
116 hwbDesc.usage |= AHARDWAREBUFFER_USAGE_CPU_WRITE_OFTEN;
119 hwbDesc.format = AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM;
126 if (
int error = AHardwareBuffer_allocate(&hwbDesc, &
buffer)) {
134 AHardwareBuffer_describe(
buffer, &hwbDesc);
136 uint32_t* bufferAddr;
137 if (AHardwareBuffer_lock(
buffer, AHARDWAREBUFFER_USAGE_CPU_WRITE_OFTEN, -1,
nullptr,
138 reinterpret_cast<void**
>(&bufferAddr))) {
140 AHardwareBuffer_release(
buffer);
144 int bbp =
data->bytesPerPixel();
145 uint32_t*
src = (uint32_t*)
data->getPixels();
146 int nextLineStep =
width;
147 uint32_t*
dst = bufferAddr;
149 memcpy(dst, src,
width * bbp);
151 dst += hwbDesc.stride;
153 AHardwareBuffer_unlock(
buffer,
nullptr);
159void delete_buffer(
void* context) {
162 AHardwareBuffer_release(
buffer);
173 if (!context->priv().caps()->supportsAHardwareBufferImages()) {
177 bool isProtected = context->priv().caps()->protectedSupport();
179 std::unique_ptr<Recorder> recorder = context->makeRecorder();
185 const SkBitmap srcBitmap = make_src_bitmap();
209 surface->getCanvas()->drawImage(grBacked, 0, 0);
struct AHardwareBuffer AHardwareBuffer
static bool check_read(skiatest::Reporter *reporter, const SkBitmap &bitmap)
static SkPMColor get_src_color(int x, int y)
static SkPMColor SkPremultiplyARGBInline(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
#define REPORTER_ASSERT(r, cond,...)
#define DEF_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS(name, reporter, graphite_context, ctsEnforcement)
sk_sp< SkImage > asImage() const
int bytesPerPixel() const
void allocN32Pixels(int width, int height, bool isOpaque=false)
uint32_t * getAddr32(int x, int y) const
static const uint8_t buffer[]
const uint8_t uint32_t uint32_t GError ** error
SK_API sk_sp< SkImage > TextureFromImage(GrDirectContext *, const SkImage *, skgpu::Mipmapped=skgpu::Mipmapped::kNo, skgpu::Budgeted=skgpu::Budgeted::kYes)
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)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data