Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Enumerations | Functions
MaskCacheTest.cpp File Reference
#include "include/core/SkBlurTypes.h"
#include "include/core/SkRRect.h"
#include "include/core/SkRect.h"
#include "include/core/SkScalar.h"
#include "src/base/SkTLazy.h"
#include "src/core/SkCachedData.h"
#include "src/core/SkMask.h"
#include "src/core/SkMaskCache.h"
#include "src/core/SkResourceCache.h"
#include "tests/Test.h"
#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 (RRectMaskCache, reporter)
 
 DEF_TEST (RectsMaskCache, reporter)
 

Enumeration Type Documentation

◆ CachedState

Enumerator
kNotInCache 
kInCache 

Definition at line 26 of file MaskCacheTest.cpp.

26 {
29};
@ kInCache
@ kNotInCache

◆ LockedState

Enumerator
kUnlocked 
kLocked 

Definition at line 21 of file MaskCacheTest.cpp.

21 {
23 kLocked,
24};
@ 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 31 of file MaskCacheTest.cpp.

32 {
33 REPORTER_ASSERT(reporter, data->testing_only_getRefCnt() == refcnt);
34 REPORTER_ASSERT(reporter, data->testing_only_isInCache() == (kInCache == cacheState));
35 bool isLocked = (data->data() != nullptr);
36 REPORTER_ASSERT(reporter, isLocked == (lockedState == kLocked));
37}
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() [1/2]

DEF_TEST ( RectsMaskCache  ,
reporter   
)

Definition at line 76 of file MaskCacheTest.cpp.

76 {
78
79 SkScalar sigma = 0.8f;
80 SkRect rect = SkRect::MakeWH(100, 100);
81 SkRect rects[2] = {rect};
83 SkTLazy<SkMask> lazyMask;
84
85 SkCachedData* data = SkMaskCache::FindAndRef(sigma, style, rects, 1, &lazyMask, &cache);
86 REPORTER_ASSERT(reporter, nullptr == data);
87 REPORTER_ASSERT(reporter, !lazyMask.isValid());
88
89 size_t size = 256;
90 data = cache.newCachedData(size);
91 memset(data->writable_data(), 0xff, size);
92 SkMask mask(nullptr, SkIRect::MakeXYWH(0, 0, 100, 100), 100, SkMask::kBW_Format);
93 SkMaskCache::Add(sigma, style, rects, 1, mask, data, &cache);
95
96 data->unref();
98
99 lazyMask.reset();
100 data = SkMaskCache::FindAndRef(sigma, style, rects, 1, &lazyMask, &cache);
102 REPORTER_ASSERT(reporter, data->size() == size);
103 REPORTER_ASSERT(reporter, lazyMask->fBounds.top() == 0 && lazyMask->fBounds.bottom() == 100);
104 REPORTER_ASSERT(reporter, data->data() == static_cast<const void*>(lazyMask->fImage));
106
107 cache.purgeAll();
109 data->unref();
110}
static void check_data(skiatest::Reporter *reporter, SkCachedData *data, int refcnt, CachedState cacheState, LockedState lockedState)
SkBlurStyle
Definition SkBlurTypes.h:11
@ kNormal_SkBlurStyle
fuzzy inside and outside
Definition SkBlurTypes.h:12
static void Add(SkScalar sigma, SkBlurStyle style, const SkRRect &rrect, const SkMask &mask, SkCachedData *data, SkResourceCache *localCache=nullptr)
static SkCachedData * FindAndRef(SkScalar sigma, SkBlurStyle style, const SkRRect &rrect, SkTLazy< SkMask > *mask, SkResourceCache *localCache=nullptr)
void reset()
Definition SkTLazy.h:69
bool isValid() const
Definition SkTLazy.h:77
float SkScalar
Definition extension.cpp:12
sk_sp< SkBlender > blender SkRect rect
Definition SkRecords.h:350
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
static constexpr SkIRect MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h)
Definition SkRect.h:104
@ kBW_Format
1bit per pixel mask (e.g. monochrome)
Definition SkMask.h:27
static constexpr SkRect MakeWH(float w, float h)
Definition SkRect.h:609

◆ DEF_TEST() [2/2]

DEF_TEST ( RRectMaskCache  ,
reporter   
)

Definition at line 39 of file MaskCacheTest.cpp.

39 {
41
42 SkScalar sigma = 0.8f;
43 SkRect rect = SkRect::MakeWH(100, 100);
45 rrect.setRectXY(rect, 30, 30);
47 SkTLazy<SkMask> lazyMask;
48
49 SkCachedData* data = SkMaskCache::FindAndRef(sigma, style, rrect, &lazyMask, &cache);
50 REPORTER_ASSERT(reporter, nullptr == data);
51 REPORTER_ASSERT(reporter, !lazyMask.isValid());
52
53 size_t size = 256;
54 data = cache.newCachedData(size);
55 memset(data->writable_data(), 0xff, size);
56 SkMask mask(nullptr, SkIRect::MakeXYWH(0, 0, 100, 100), 100, SkMask::kBW_Format);
57 SkMaskCache::Add(sigma, style, rrect, mask, data, &cache);
59
60 data->unref();
62
63 lazyMask.reset();
64 data = SkMaskCache::FindAndRef(sigma, style, rrect, &lazyMask, &cache);
66 REPORTER_ASSERT(reporter, data->size() == size);
67 REPORTER_ASSERT(reporter, lazyMask->fBounds.top() == 0 && lazyMask->fBounds.bottom() == 100);
68 REPORTER_ASSERT(reporter, data->data() == static_cast<const void*>(lazyMask->fImage));
70
71 cache.purgeAll();
73 data->unref();
74}
void setRectXY(const SkRect &rect, SkScalar xRad, SkScalar yRad)
Definition SkRRect.cpp:52
SkRRect rrect
Definition SkRecords.h:232