46 paint.setStrokeWidth(seed);
66 path.cubicTo(768, 0, -512, 256, 256, 256);
79 font.setSize(2 + seed);
110 static const int NUM_FRAMES = 12;
111 static const int WIDTH = 256;
112 static const int HEIGHT = 256;
127 std::vector<sk_sp<SkImage>> expectedImages;
129 for (
int i=0;
i<NUM_FRAMES;
i++) {
136 expectedImages.push_back(surf->makeImageSnapshot());
142 std::unique_ptr<SkStreamAsset> writtenStream =
stream.detachAsStream();
144 "Written data length too short (%zu)", writtenStream->getLength());
156 "Expected %d frames, got %d. \n 0 frames may indicate the written file was not a "
157 "MultiPictureDocument.", NUM_FRAMES, frame_count);
160 std::vector<SkDocumentPage> frames(frame_count);
163 "Failed while reading MultiPictureDocument");
167 for (
const auto&
frame : frames) {
170 "Page width: expected (%d) got (%d)",
WIDTH, (
int)
bounds.width());
172 "Page height: expected (%d) got (%d)",
HEIGHT, (
int)
bounds.height());
175 surf->getCanvas()->drawPicture(
frame.fPicture);
176 auto img = surf->makeImageSnapshot();
178 "Frame %d is wrong",
i);
185#if defined(SK_GANESH) && defined(SK_BUILD_FOR_ANDROID) && __ANDROID_API__ >= 26
235 intptr_t pixels =
reinterpret_cast<intptr_t
>(bmp.
getPixels());
249 AHardwareBuffer_release(
buffer);
256 const SkBitmap srcBitmap = make_src_bitmap();
258 AHardwareBuffer_Desc hwbDesc;
259 hwbDesc.width =
DEV_W;
260 hwbDesc.height =
DEV_H;
262 hwbDesc.usage = AHARDWAREBUFFER_USAGE_CPU_READ_OFTEN |
263 AHARDWAREBUFFER_USAGE_CPU_WRITE_OFTEN |
264 AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE;
265 hwbDesc.format = AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM;
271 if (
int error = AHardwareBuffer_allocate(&hwbDesc, &
buffer)) {
273 cleanup_resources(
buffer);
278 AHardwareBuffer_describe(
buffer, &hwbDesc);
281 if (AHardwareBuffer_lock(
buffer, AHARDWAREBUFFER_USAGE_CPU_WRITE_OFTEN, -1,
nullptr,
284 cleanup_resources(
buffer);
291 int nextLineStep =
DEV_W;
292 uint32_t*
dst =
static_cast<uint32_t*
>(bufferAddr);
296 dst += hwbDesc.stride;
298 AHardwareBuffer_unlock(
buffer,
nullptr);
302 GrAHardwareBufferUtils::GetBackendFormat(context,
buffer, hwbDesc.format,
false);
303 GrAHardwareBufferUtils::DeleteImageProc deleteProc;
304 GrAHardwareBufferUtils::UpdateImageProc updateProc;
305 GrAHardwareBufferUtils::TexImageCtx imageCtx;
307 context,
buffer, hwbDesc.width, hwbDesc.height,
338 auto context = ctx_info.directContext();
355 [sharingCtx = &ctx](
const SkPicture* pic) {
359 static const int WIDTH = 256;
360 static const int HEIGHT = 256;
367 std::vector<sk_sp<SkImage>> expectedImages;
376 expectedImages.push_back(surf->makeImageSnapshot());
382 cleanup_resources(ahbuffer);
388 std::unique_ptr<SkStreamAsset> writtenStream =
stream.detachAsStream();
390 "Written data length too short (%zu)", writtenStream->getLength());
401 "Expected 1 frame, got %d. \n 0 frames may indicate the written file was not a "
402 "MultiPictureDocument.", frame_count);
405 std::vector<SkDocumentPage> frames(frame_count);
408 "Failed while reading MultiPictureDocument");
413 "Page width: expected (%d) got (%d)",
WIDTH, (
int)
bounds.width());
415 "Page height: expected (%d) got (%d)",
HEIGHT, (
int)
bounds.height());
418 surf2->getCanvas()->drawPicture(frames[0].fPicture);
419 auto img = surf2->makeImageSnapshot();
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
struct AHardwareBuffer AHardwareBuffer
@ kTopLeft_GrSurfaceOrigin
static void draw_advanced(SkCanvas *canvas, int seed, sk_sp< SkImage > image, sk_sp< SkPicture > sub)
DEF_TEST(SkMultiPictureDocument_Serialize_and_deserialize, reporter)
static void draw_basic(SkCanvas *canvas, int seed, sk_sp< SkImage > image)
static SkPMColor get_src_color(int x, int y)
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
static SkPMColor SkPremultiplyARGBInline(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
constexpr SkColor SK_ColorYELLOW
constexpr SkColor SK_ColorCYAN
constexpr SkColor SK_ColorBLUE
constexpr SkColor SK_ColorRED
constexpr SkColor SK_ColorGREEN
constexpr SkColor SK_ColorWHITE
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
SK_API SkString SkStringPrintf(const char *format,...) SK_PRINTF_LIKE(1
Creates a new string and writes into it using a printf()-style format.
#define REPORTER_ASSERT(r, cond,...)
#define DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS(name, reporter, context_info, ctsEnforcement)
const GrCaps * caps() const
bool supportsAHardwareBufferImages() const
GrDirectContextPriv priv()
int bytesPerPixel() const
void allocN32Pixels(int width, int height, bool isOpaque=false)
void drawRect(const SkRect &rect, const SkPaint &paint)
void translate(SkScalar dx, SkScalar dy)
void drawColor(SkColor color, SkBlendMode mode=SkBlendMode::kSrcOver)
void drawRRect(const SkRRect &rrect, const SkPaint &paint)
void drawRoundRect(const SkRect &rect, SkScalar rx, SkScalar ry, const SkPaint &paint)
void drawImageRect(const SkImage *, const SkRect &src, const SkRect &dst, const SkSamplingOptions &, const SkPaint *, SrcRectConstraint)
void drawPath(const SkPath &path, const SkPaint &paint)
void drawPicture(const SkPicture *picture)
void drawTextBlob(const SkTextBlob *blob, SkScalar x, SkScalar y, const SkPaint &paint)
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
void drawCircle(SkScalar cx, SkScalar cy, SkScalar radius, const SkPaint &paint)
static sk_sp< SkColorSpace > MakeSRGB()
virtual bool isTextureBacked() const =0
@ kStroke_Style
set to stroke geometry
SkCanvas * beginRecording(const SkRect &bounds, sk_sp< SkBBoxHierarchy > bbh)
sk_sp< SkPicture > finishRecordingAsPicture()
static sk_sp< SkTextBlob > MakeFromString(const char *string, const SkFont &font, SkTextEncoding encoding=SkTextEncoding::kUTF8)
const uint8_t uint32_t uint32_t GError ** error
SK_API sk_sp< SkImage > BorrowTextureFrom(GrRecordingContext *context, const GrBackendTexture &backendTexture, GrSurfaceOrigin origin, SkColorType colorType, SkAlphaType alphaType, sk_sp< SkColorSpace > colorSpace, TextureReleaseProc textureReleaseProc=nullptr, ReleaseContext releaseContext=nullptr)
SK_API sk_sp< SkDocument > Make(SkWStream *dst, const SkSerialProcs *=nullptr, std::function< void(const SkPicture *)> onEndPage=nullptr)
SK_API bool Read(SkStreamSeekable *src, SkDocumentPage *dstArray, int dstArrayCount, const SkDeserialProcs *=nullptr)
SK_API int ReadPageCount(SkStreamSeekable *src)
Optional< SkRect > bounds
sk_sp< const SkImage > image
sk_sp< SkBlender > blender SkRect rect
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
font
Font Metadata and Metrics.
SkSamplingOptions(SkFilterMode::kLinear))
SkDeserialImageProc fImageProc
static SkImageInfo MakeN32Premul(int width, int height)
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
void offset(float dx, float dy)
SkSerialImageProc fImageProc
static sk_sp< SkImage > deserializeImage(const void *data, size_t length, void *ctx)
static sk_sp< SkData > serializeImage(SkImage *img, void *ctx)
static void collectNonTextureImagesFromPicture(const SkPicture *pic, SkSharingSerialContext *sharingCtx)