d90cd3b279
This reverts commit edf8449d2c
.
Change-Id: Ibeedd9965855b3ccfe44486d15307bf3da15fd9c
Reviewed-on: https://skia-review.googlesource.com/129516
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
39 lines
1.2 KiB
C++
39 lines
1.2 KiB
C++
/*
|
|
* Copyright 2013 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#include "SkDiscardableMemory.h"
|
|
#include "SkDiscardableMemoryPool.h"
|
|
#include "SkRefCnt.h"
|
|
#include "Test.h"
|
|
|
|
#include <memory>
|
|
|
|
DEF_TEST(DiscardableMemoryPool, reporter) {
|
|
sk_sp<SkDiscardableMemoryPool> pool(SkDiscardableMemoryPool::Make(1));
|
|
pool->setRAMBudget(3);
|
|
REPORTER_ASSERT(reporter, 0 == pool->getRAMUsed());
|
|
|
|
std::unique_ptr<SkDiscardableMemory> dm1(pool->create(100));
|
|
REPORTER_ASSERT(reporter, dm1->data() != nullptr);
|
|
REPORTER_ASSERT(reporter, 100 == pool->getRAMUsed());
|
|
dm1->unlock();
|
|
REPORTER_ASSERT(reporter, 0 == pool->getRAMUsed());
|
|
REPORTER_ASSERT(reporter, !dm1->lock());
|
|
|
|
|
|
std::unique_ptr<SkDiscardableMemory> dm2(pool->create(200));
|
|
REPORTER_ASSERT(reporter, 200 == pool->getRAMUsed());
|
|
pool->setRAMBudget(400);
|
|
dm2->unlock();
|
|
REPORTER_ASSERT(reporter, 200 == pool->getRAMUsed());
|
|
REPORTER_ASSERT(reporter, dm2->lock());
|
|
dm2->unlock();
|
|
pool->dumpPool();
|
|
REPORTER_ASSERT(reporter, !dm2->lock());
|
|
REPORTER_ASSERT(reporter, 0 == pool->getRAMUsed());
|
|
}
|