Flutter Engine
The Flutter Engine
PipelineDataCacheTest.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2021 Google LLC
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#include "tests/Test.h"
9
16
17using namespace skgpu::graphite;
18
19DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS(PipelineDataCacheTest, reporter, context,
21 std::unique_ptr<Recorder> recorder = context->makeRecorder();
22
23 auto cache = recorder->priv().uniformDataCache();
24
25 REPORTER_ASSERT(reporter, cache->count() == 0);
26
27 static const int kSize = 16;
28
29 // Add a new unique UDB
30 static const char kMemory1[kSize] = {
31 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22
32 };
33 UniformDataBlock udb1(SkSpan(kMemory1, kSize));
34 const UniformDataBlock* id1;
35 {
36 id1 = cache->insert(udb1);
38 REPORTER_ASSERT(reporter, id1 != &udb1); // must be a separate address
39 REPORTER_ASSERT(reporter, *id1 == udb1); // but equal contents
40
41 REPORTER_ASSERT(reporter, cache->count() == 1);
42 }
43
44 // Try to add a duplicate UDB
45 {
46 static const char kMemory2[kSize] = {
47 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22
48 };
49 UniformDataBlock udb2(SkSpan(kMemory2, kSize));
50 const UniformDataBlock* id2 = cache->insert(udb2);
51 REPORTER_ASSERT(reporter, id2 == id1);
52
53 REPORTER_ASSERT(reporter, cache->count() == 1);
54 }
55
56 // Add a second new unique UDB
57 {
58 static const char kMemory3[kSize] = {
59 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21
60 };
61 UniformDataBlock udb3(SkSpan(kMemory3, kSize));
62 const UniformDataBlock* id3 = cache->insert(udb3);
64 REPORTER_ASSERT(reporter, id3 != id1);
65 REPORTER_ASSERT(reporter, *id3 == udb3);
66
67 REPORTER_ASSERT(reporter, cache->count() == 2);
68 }
69
70 // TODO(robertphillips): expand this test to exercise all the UDB comparison failure modes
71}
reporter
Definition: FontMgrTest.cpp:39
DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS(PipelineDataCacheTest, reporter, context, CtsEnforcement::kNextRelease)
SkSpan(Container &&) -> SkSpan< std::remove_pointer_t< decltype(std::data(std::declval< Container >()))> >
static constexpr bool SkToBool(const T &x)
Definition: SkTo.h:35
#define REPORTER_ASSERT(r, cond,...)
Definition: Test.h:286
constexpr int kSize
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