Flutter Engine
The Flutter Engine
third_party
skia
tests
DiscardableMemoryPoolTest.cpp
Go to the documentation of this file.
1
/*
2
* Copyright 2013 Google Inc.
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 "
include/core/SkRefCnt.h
"
9
#include "
include/private/chromium/SkDiscardableMemory.h
"
10
#include "
src/lazy/SkDiscardableMemoryPool.h
"
11
#include "
tests/Test.h
"
12
13
#include <memory>
14
15
DEF_TEST
(DiscardableMemoryPool,
reporter
) {
16
sk_sp<SkDiscardableMemoryPool>
pool
(
SkDiscardableMemoryPool::Make
(1));
17
pool
->setRAMBudget(3);
18
REPORTER_ASSERT
(
reporter
, 0 ==
pool
->getRAMUsed());
19
20
std::unique_ptr<SkDiscardableMemory> dm1(
pool
->create(100));
21
REPORTER_ASSERT
(
reporter
, dm1->data() !=
nullptr
);
22
REPORTER_ASSERT
(
reporter
, 100 ==
pool
->getRAMUsed());
23
dm1->unlock();
24
REPORTER_ASSERT
(
reporter
, 0 ==
pool
->getRAMUsed());
25
REPORTER_ASSERT
(
reporter
, !dm1->lock());
26
27
28
std::unique_ptr<SkDiscardableMemory> dm2(
pool
->create(200));
29
REPORTER_ASSERT
(
reporter
, 200 ==
pool
->getRAMUsed());
30
pool
->setRAMBudget(400);
31
dm2->unlock();
32
REPORTER_ASSERT
(
reporter
, 200 ==
pool
->getRAMUsed());
33
REPORTER_ASSERT
(
reporter
, dm2->lock());
34
dm2->unlock();
35
pool
->dumpPool();
36
REPORTER_ASSERT
(
reporter
, !dm2->lock());
37
REPORTER_ASSERT
(
reporter
, 0 ==
pool
->getRAMUsed());
38
}
pool
AutoreleasePool pool
Definition:
BazelBenchmarkTestRunner.cpp:313
DEF_TEST
DEF_TEST(DiscardableMemoryPool, reporter)
Definition:
DiscardableMemoryPoolTest.cpp:15
reporter
reporter
Definition:
FontMgrTest.cpp:39
SkDiscardableMemoryPool.h
SkDiscardableMemory.h
SkRefCnt.h
Test.h
REPORTER_ASSERT
#define REPORTER_ASSERT(r, cond,...)
Definition:
Test.h:286
SkDiscardableMemoryPool::Make
static sk_sp< SkDiscardableMemoryPool > Make(size_t size)
Definition:
SkDiscardableMemoryPool.cpp:233
sk_sp
Definition:
SkRefCnt.h:220
Generated on Sun Jun 23 2024 21:56:38 for Flutter Engine by
1.9.4