Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Enumerations | Functions
YUVCacheTest.cpp File Reference
#include "include/core/SkImageInfo.h"
#include "include/core/SkPixmap.h"
#include "include/core/SkYUVAInfo.h"
#include "include/core/SkYUVAPixmaps.h"
#include "src/core/SkCachedData.h"
#include "src/core/SkResourceCache.h"
#include "src/core/SkYUVPlanesCache.h"
#include "tests/Test.h"
#include <cstdint>
#include <cstring>

Go to the source code of this file.

Enumerations

enum  LockedState { kUnlocked , kLocked }
 
enum  CachedState { kNotInCache , kInCache }
 

Functions

static void check_data (skiatest::Reporter *reporter, SkCachedData *data, int refcnt, CachedState cacheState, LockedState lockedState)
 
 DEF_TEST (YUVPlanesCache, reporter)
 

Enumeration Type Documentation

◆ CachedState

Enumerator
kNotInCache 
kInCache 

Definition at line 25 of file YUVCacheTest.cpp.

25 {
28};
@ kInCache
@ kNotInCache

◆ LockedState

Enumerator
kUnlocked 
kLocked 

Definition at line 20 of file YUVCacheTest.cpp.

20 {
22 kLocked,
23};
@ kUnlocked
@ kLocked

Function Documentation

◆ check_data()

static void check_data ( skiatest::Reporter reporter,
SkCachedData data,
int  refcnt,
CachedState  cacheState,
LockedState  lockedState 
)
static

Definition at line 30 of file YUVCacheTest.cpp.

31 {
32 REPORTER_ASSERT(reporter, data->testing_only_getRefCnt() == refcnt);
33 REPORTER_ASSERT(reporter, data->testing_only_isInCache() == (kInCache == cacheState));
34 bool isLocked = (data->data() != nullptr);
35 REPORTER_ASSERT(reporter, isLocked == (lockedState == kLocked));
36}
reporter
#define REPORTER_ASSERT(r, cond,...)
Definition Test.h:286
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switches.h:41

◆ DEF_TEST()

DEF_TEST ( YUVPlanesCache  ,
reporter   
)

Definition at line 38 of file YUVCacheTest.cpp.

38 {
40
41 SkYUVAInfo yuvaInfo({5, 5},
45 SkYUVAPixmapInfo yuvaPixmapInfo(yuvaInfo,
47 /*rowBytes[]*/ nullptr);
48 SkYUVAPixmaps yuvaPixmaps;
49 const uint32_t genID = 12345678;
50
51 SkCachedData* data = SkYUVPlanesCache::FindAndRef(genID, &yuvaPixmaps, &cache);
53
54 size_t size = yuvaPixmapInfo.computeTotalBytes();
55 data = cache.newCachedData(size);
56 memset(data->writable_data(), 0xff, size);
57
59 yuvaPixmapInfo.initPixmapsFromSingleAllocation(data->writable_data(), pmaps);
60 yuvaPixmaps = SkYUVAPixmaps::FromExternalPixmaps(yuvaInfo, pmaps);
61
62 SkYUVPlanesCache::Add(genID, data, yuvaPixmaps, &cache);
64
65 data->unref();
67
68 SkYUVAPixmaps yuvaPixmapsRead;
69 data = SkYUVPlanesCache::FindAndRef(genID, &yuvaPixmapsRead, &cache);
70
72 REPORTER_ASSERT(reporter, data->size() == size);
73 REPORTER_ASSERT(reporter, yuvaPixmapsRead.yuvaInfo() == yuvaPixmaps.yuvaInfo());
74
75 for (int i = 0; i < yuvaPixmaps.numPlanes(); ++i) {
76 REPORTER_ASSERT(reporter, yuvaPixmaps.plane(i).info() == yuvaPixmapsRead.plane(i).info());
77 REPORTER_ASSERT(reporter, yuvaPixmaps.plane(i).addr() == yuvaPixmapsRead.plane(i).addr());
78 REPORTER_ASSERT(reporter, yuvaPixmaps.plane(i).rowBytes() ==
79 yuvaPixmapsRead.plane(i).rowBytes());
80 }
81
83
84 cache.purgeAll();
86 data->unref();
87}
@ kRec601_Limited_SkYUVColorSpace
describes SDTV range
Definition SkImageInfo.h:70
static void check_data(skiatest::Reporter *reporter, SkCachedData *data, int refcnt, CachedState cacheState, LockedState lockedState)
size_t rowBytes() const
Definition SkPixmap.h:145
const SkImageInfo & info() const
Definition SkPixmap.h:135
const void * addr() const
Definition SkPixmap.h:153
@ kY_U_V
Plane 0: Y, Plane 1: U, Plane 2: V.
static constexpr int kMaxPlanes
Definition SkYUVAInfo.h:98
@ k420
1 set of UV values for each 2x2 block of Y values.
@ kUnorm8
8 bit unsigned normalized
const SkYUVAInfo & yuvaInfo() const
const SkPixmap & plane(int i) const
static SkYUVAPixmaps FromExternalPixmaps(const SkYUVAInfo &, const SkPixmap[kMaxPlanes])
int numPlanes() const
static void Add(uint32_t genID, SkCachedData *data, const SkYUVAPixmaps &pixmaps, SkResourceCache *localCache=nullptr)
static SkCachedData * FindAndRef(uint32_t genID, SkYUVAPixmaps *pixmaps, SkResourceCache *localCache=nullptr)
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 Enable an endless trace buffer The default is a ring buffer This is useful when very old events need to viewed For during application launch Memory usage will continue to grow indefinitely however Start app with an specific route defined on the framework flutter assets Path to the Flutter assets directory enable service port Allow the VM service to fallback to automatic port selection if binding to a specified port fails trace Trace early application lifecycle Automatically switches to an endless trace buffer trace skia Filters out all Skia trace event categories except those that are specified in this comma separated list dump skp on shader Automatically dump the skp that triggers new shader compilations This is useful for writing custom ShaderWarmUp to reduce jank By this is not enabled to reduce the overhead purge persistent cache
Definition switches.h:191
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
Definition switches.h:259