40#include <initializer_list>
50 auto dstLocation = [
dst, dstBpp, rowBytes](
int x,
int y) {
51 return dst +
y * rowBytes +
x * dstBpp;
54 for (
int j = top; j < top +
height; ++j) {
72 std::fill_n(tolerances, 4, 0);
79 for (
int i = 0;
i < 4; ++
i) {
80 if (descA[
i] != descB[
i]) {
83 tolerances[
i] = 1.f / (
m - 1);
90 float tolerances[4]) {
91 auto* context =
texture->getContext();
92 auto* gpu = context->priv().getGpu();
93 auto* caps = context->priv().caps();
101 std::fill_n(tolerances, 4, 0);
104 std::unique_ptr<char[]> tmpPixels(
new char[tmpRowBytes *
h]);
117 GrPixmap(tmpInfo, tmpPixels.get(), tmpRowBytes));
119 return gpu->readPixels(
texture,
135 auto* caps = dContext->
priv().
caps();
138 if (!backendFormat.isValid()) {
145 static constexpr SkISize kTexDims = {16, 16};
146 int srcBufferWidth = caps->transferPixelsToRowBytesSupport() ? 20 : 16;
167 caps->surfaceSupportsReadPixels(tex.
get())) {
185 caps->transferBufferRowBytesAlignment());
187 std::unique_ptr<char[]> srcData(
new char[kTexDims.
fHeight * srcRowBytes]);
223 std::unique_ptr<char[]> dstBuffer(
new char[dstRowBytes * kTexDims.
fHeight]());
225 float compareTolerances[4] = {};
228 ERRORF(
reporter,
"Could not read pixels from texture, color type: %d",
233 auto error = std::function<ComparePixmapsErrorReporter>(
236 "Error at (%d %d) in transfer, color type: %s, diffs: (%f, %f, %f, %f)",
238 diffs[0], diffs[1], diffs[2], diffs[3]);
243 GrCPixmap(dstInfo, dstBuffer.get(), dstRowBytes),
251 if (!caps->transferPixelsToRowBytesSupport()) {
260 const int width = 10;
272 offset = top * srcRowBytes;
293 ERRORF(
reporter,
"Could not transfer pixels to texture, color type: %d",
300 ERRORF(
reporter,
"Could not read pixels from texture, color type: %d",
305 GrCPixmap(dstInfo, dstBuffer.get(), dstRowBytes),
318 auto resourceProvider = context->priv().resourceProvider();
319 GrGpu* gpu = context->priv().getGpu();
321 static constexpr SkISize kTexDims = {16, 16};
325 const int kPartialLeft = 2;
326 const int kPartialTop = 10;
327 const int kPartialWidth = 10;
328 const int kPartialHeight = 2;
331 auto format = context->priv().caps()->getDefaultBackendFormat(
colorType, renderable);
337 size_t textureDataRowBytes = kTexDims.
fWidth * textureDataBpp;
338 std::unique_ptr<char[]> textureData(
new char[kTexDims.
fHeight * textureDataRowBytes]);
342 data.fPixels = textureData.get();
343 data.fRowBytes = textureDataRowBytes;
360 caps->surfaceSupportsReadPixels(tex.
get())) {
373 if (!allowedRead.fOffsetAlignmentForTransferBuffer) {
380 caps->transferBufferRowBytesAlignment());
381 size_t partialBufferRowBytes =
SkAlignTo(kPartialWidth * bpp,
382 caps->transferBufferRowBytesAlignment());
383 size_t offsetAlignment = allowedRead.fOffsetAlignmentForTransferBuffer;
386 size_t bufferSize = fullBufferRowBytes * kTexDims.
fHeight;
388 static constexpr size_t kStartingOffset = 11;
389 size_t partialReadOffset = kStartingOffset +
390 (offsetAlignment - kStartingOffset%offsetAlignment)%offsetAlignment;
392 partialReadOffset + partialBufferRowBytes * kPartialHeight);
403 int expectedTransferCnt = 0;
404 gpu->
stats()->reset();
411 allowedRead.fColorType,
418 ++expectedTransferCnt;
425 const auto*
map =
reinterpret_cast<const char*
>(
buffer->map());
431 std::unique_ptr<char[]> transferData(
new char[kTexDims.
fHeight * fullBufferRowBytes]);
432 memcpy(transferData.get(),
map, fullBufferRowBytes * kTexDims.
fHeight);
439 auto error = std::function<ComparePixmapsErrorReporter>(
442 "Error at (%d %d) in transfer, color type: %s, diffs: (%f, %f, %f, %f)",
444 diffs[0], diffs[1], diffs[2], diffs[3]);
448 GrCPixmap( transferInfo, transferData.get(), fullBufferRowBytes),
458 allowedRead.fColorType,
465 ++expectedTransferCnt;
471 map =
reinterpret_cast<const char*
>(
buffer->map());
477 const char* bufferStart =
reinterpret_cast<const char*
>(
map) + partialReadOffset;
478 memcpy(transferData.get(), bufferStart, partialBufferRowBytes * kTexDims.
fHeight);
481 transferInfo = transferInfo.
makeWH(kPartialWidth, kPartialHeight);
482 const char* textureDataStart =
483 textureData.get() + textureDataRowBytes * kPartialTop + textureDataBpp * kPartialLeft;
484 textureDataInfo = textureDataInfo.
makeWH(kPartialWidth, kPartialHeight);
486 GrCPixmap(transferInfo , transferData.get(), partialBufferRowBytes),
492 (void)expectedTransferCnt;
500 if (!ctxInfo.directContext()->priv().caps()->transferFromBufferToTextureSupport()) {
537 if (!ctxInfo.directContext()->priv().caps()->transferFromSurfaceToBufferSupport()) {
static GrColor GrColorPackRGBA(unsigned r, unsigned g, unsigned b, unsigned a)
bool GrConvertPixels(const GrPixmap &dst, const GrCPixmap &src, bool flipY)
static constexpr GrColorFormatDesc GrGetColorTypeDesc(GrColorType ct)
static constexpr size_t GrColorTypeBytesPerPixel(GrColorType ct)
@ kDynamic_GrAccessPattern
static constexpr size_t SkAlignTo(size_t x, size_t alignment)
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
static bool left(const SkPoint &p0, const SkPoint &p1)
bool ComparePixels(const GrCPixmap &a, const GrCPixmap &b, const float tolRGBA[4], std::function< ComparePixmapsErrorReporter > &error)
#define REPORTER_ASSERT(r, cond,...)
void determine_tolerances(GrColorType a, GrColorType b, float tolerances[4])
void basic_transfer_from_test(skiatest::Reporter *reporter, const sk_gpu_test::ContextInfo &ctxInfo, GrColorType colorType, GrRenderable renderable)
void basic_transfer_to_test(skiatest::Reporter *reporter, GrDirectContext *dContext, GrColorType colorType, GrRenderable renderable)
DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS(TransferPixelsToTextureTest, reporter, ctxInfo, CtsEnforcement::kApiLevel_T)
bool read_pixels_from_texture(GrTexture *texture, GrColorType colorType, char *dst, float tolerances[4])
void fill_transfer_data(int left, int top, int width, int height, int rowBytes, GrColorType dstType, char *dst)
const GrCaps * caps() const
GrBackendFormat getDefaultBackendFormat(GrColorType, GrRenderable) const
uint32_t mapBufferFlags() const
GrResourceProvider * resourceProvider()
GrDirectContextPriv priv()
bool submitToGpu(GrSyncCpu sync)
bool transferPixelsFrom(GrSurface *surface, SkIRect rect, GrColorType surfaceColorType, GrColorType bufferColorType, sk_sp< GrGpuBuffer > transferBuffer, size_t offset)
bool transferPixelsTo(GrTexture *texture, SkIRect rect, GrColorType textureColorType, GrColorType bufferColorType, sk_sp< GrGpuBuffer > transferBuffer, size_t offset, size_t rowBytes)
GrImageInfo makeWH(int width, int height) const
GrColorType colorType() const
virtual GrBackendFormat backendFormat() const =0
SkISize dimensions() const
GrDirectContext * directContext() const
const uint8_t uint32_t uint32_t GError ** error
static constexpr uint32_t kBufferHeight
uint32_t uint32_t * format
static float max(float r, float g, float b)
static float min(float r, float g, float b)
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
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
SI auto map(std::index_sequence< I... >, Fn &&fn, const Args &... args) -> skvx::Vec< sizeof...(I), decltype(fn(args[0]...))>
size_t fOffsetAlignmentForTransferBuffer
static constexpr SkIRect MakeSize(const SkISize &size)
static constexpr SkIRect MakeWH(int32_t w, int32_t h)
static constexpr SkIRect MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h)
std::shared_ptr< const fml::Mapping > data