Flutter Engine
The Flutter Engine
Enumerations | Functions
CachedDataTest.cpp File Reference
#include "include/core/SkRefCnt.h"
#include "include/core/SkTypes.h"
#include "include/private/base/SkMalloc.h"
#include "src/core/SkCachedData.h"
#include "src/lazy/SkDiscardableMemoryPool.h"
#include "tests/Test.h"
#include <cstring>

Go to the source code of this file.

Enumerations

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

Functions

static void check_data (skiatest::Reporter *reporter, SkCachedData *data, int refcnt, CachedState cacheState, LockedState lockedState)
 
static SkCachedDatamake_data (size_t size, SkDiscardableMemoryPool *pool)
 
static SkCachedDatatest_locking (skiatest::Reporter *reporter, size_t size, SkDiscardableMemoryPool *pool)
 
 DEF_TEST (CachedData, reporter)
 

Enumeration Type Documentation

◆ CachedState

Enumerator
kNotInCache 
kInCache 
kNotInCache 
kInCache 
kNotInCache 
kInCache 
kNotInCache 
kInCache 

Definition at line 24 of file CachedDataTest.cpp.

24 {
27};
@ kInCache
@ kNotInCache

◆ LockedState

Enumerator
kUnlocked 
kLocked 
kUnlocked 
kLocked 
kNotLocked 
kLocked 
kUnlocked 
kLocked 

Definition at line 19 of file CachedDataTest.cpp.

19 {
21 kLocked,
22};
@ 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 29 of file CachedDataTest.cpp.

30 {
31 REPORTER_ASSERT(reporter, data->testing_only_getRefCnt() == refcnt);
32 REPORTER_ASSERT(reporter, data->testing_only_isInCache() == (kInCache == cacheState));
33 REPORTER_ASSERT(reporter, data->testing_only_isLocked() == (lockedState == kLocked));
34}
reporter
Definition: FontMgrTest.cpp:39
#define REPORTER_ASSERT(r, cond,...)
Definition: Test.h:286
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

◆ DEF_TEST()

DEF_TEST ( CachedData  ,
reporter   
)

Definition at line 81 of file CachedDataTest.cpp.

81 {
83
84 for (int useDiscardable = 0; useDiscardable <= 1; ++useDiscardable) {
85 const size_t size = 100;
86
87 // test with client as last owner
88 SkCachedData* data = test_locking(reporter, size, useDiscardable ? pool.get() : nullptr);
90 data->detachFromCacheAndUnref();
92 data->unref();
93
94 // test with cache as last owner
95 data = test_locking(reporter, size, useDiscardable ? pool.get() : nullptr);
97 data->unref();
99 data->detachFromCacheAndUnref();
100 }
101}
AutoreleasePool pool
static void check_data(skiatest::Reporter *reporter, SkCachedData *data, int refcnt, CachedState cacheState, LockedState lockedState)
static SkCachedData * test_locking(skiatest::Reporter *reporter, size_t size, SkDiscardableMemoryPool *pool)
static sk_sp< SkDiscardableMemoryPool > Make(size_t size)
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

◆ make_data()

static SkCachedData * make_data ( size_t  size,
SkDiscardableMemoryPool pool 
)
static

Definition at line 36 of file CachedDataTest.cpp.

36 {
37 if (pool) {
38 SkDiscardableMemory* dm = pool->create(size);
39 // the pool "can" return null, but it shouldn't in these controlled conditions
41 return new SkCachedData(size, dm);
42 } else {
44 }
45}
#define SkASSERT_RELEASE(cond)
Definition: SkAssert.h:100
static void * sk_malloc_throw(size_t size)
Definition: SkMalloc.h:67

◆ test_locking()

static SkCachedData * test_locking ( skiatest::Reporter reporter,
size_t  size,
SkDiscardableMemoryPool pool 
)
static

Definition at line 48 of file CachedDataTest.cpp.

49 {
51
52 memset(data->writable_data(), 0x80, size); // just to use writable_data()
53
55
56 data->ref();
58 data->unref();
60
61 data->attachToCacheAndRef();
63
64 data->unref();
66
67 data->ref();
69
70 return data;
71}
static SkCachedData * make_data(size_t size, SkDiscardableMemoryPool *pool)