Commit 3477c6da authored by Khushal's avatar Khushal Committed by Commit Bot

cc/gpu: Use same budget for transfer cache and discardable textures.

Transfer cache is the OOPR equivalent of a shared image cache for all
renderers. Make sure it uses the same budget. Also cleanup for transfer
cache entry types which are not used anymore.

R=ericrk@chromium.org

Bug: 903775
Change-Id: I48741f1c8385eb64cf1a9f34f06a63673ee3d7c3
Reviewed-on: https://chromium-review.googlesource.com/c/1330763Reviewed-by: default avatarEric Karl <ericrk@chromium.org>
Commit-Queue: Khushal <khushalsagar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#607080}
parent b5469b5b
......@@ -59,8 +59,6 @@ cc_component("paint") {
"paint_recorder.h",
"paint_shader.cc",
"paint_shader.h",
"path_transfer_cache_entry.cc",
"path_transfer_cache_entry.h",
"raw_memory_transfer_cache_entry.cc",
"raw_memory_transfer_cache_entry.h",
"record_paint_canvas.cc",
......@@ -79,8 +77,6 @@ cc_component("paint") {
"skottie_wrapper.h",
"solid_color_analyzer.cc",
"solid_color_analyzer.h",
"textblob_transfer_cache_entry.cc",
"textblob_transfer_cache_entry.h",
"transfer_cache_deserialize_helper.h",
"transfer_cache_entry.cc",
"transfer_cache_entry.h",
......
......@@ -14,9 +14,7 @@
#include "cc/paint/paint_image_builder.h"
#include "cc/paint/paint_op_buffer.h"
#include "cc/paint/paint_shader.h"
#include "cc/paint/path_transfer_cache_entry.h"
#include "cc/paint/shader_transfer_cache_entry.h"
#include "cc/paint/textblob_transfer_cache_entry.h"
#include "cc/paint/transfer_cache_deserialize_helper.h"
#include "third_party/skia/include/core/SkPath.h"
#include "third_party/skia/include/core/SkRRect.h"
......
......@@ -11,7 +11,6 @@
#include "cc/paint/paint_flags.h"
#include "cc/paint/paint_op_buffer_serializer.h"
#include "cc/paint/paint_shader.h"
#include "cc/paint/path_transfer_cache_entry.h"
#include "cc/paint/transfer_cache_serialize_helper.h"
#include "third_party/skia/include/core/SkSerialProcs.h"
#include "third_party/skia/include/core/SkTextBlob.h"
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cc/paint/path_transfer_cache_entry.h"
namespace cc {
ClientPathTransferCacheEntry::ClientPathTransferCacheEntry(const SkPath& path)
: path_(path) {
size_ = path_.writeToMemory(nullptr);
}
ClientPathTransferCacheEntry::~ClientPathTransferCacheEntry() = default;
uint32_t ClientPathTransferCacheEntry::Id() const {
return path_.getGenerationID();
}
size_t ClientPathTransferCacheEntry::SerializedSize() const {
return size_;
}
bool ClientPathTransferCacheEntry::Serialize(base::span<uint8_t> data) const {
DCHECK_GE(data.size(), size_);
size_t bytes_written = path_.writeToMemory(data.data());
DCHECK_LE(bytes_written, size_);
return true;
}
ServicePathTransferCacheEntry::ServicePathTransferCacheEntry() = default;
ServicePathTransferCacheEntry::~ServicePathTransferCacheEntry() = default;
size_t ServicePathTransferCacheEntry::CachedSize() const {
return size_;
}
bool ServicePathTransferCacheEntry::Deserialize(
GrContext* context,
base::span<const uint8_t> data) {
size_t read_bytes = path_.readFromMemory(data.data(), data.size());
// Invalid path.
if (read_bytes == 0)
return false;
if (read_bytes > data.size())
return false;
size_ = read_bytes;
return true;
}
} // namespace cc
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CC_PAINT_PATH_TRANSFER_CACHE_ENTRY_H_
#define CC_PAINT_PATH_TRANSFER_CACHE_ENTRY_H_
#include "base/containers/span.h"
#include "cc/paint/paint_export.h"
#include "cc/paint/transfer_cache_entry.h"
#include "third_party/skia/include/core/SkPath.h"
namespace cc {
class CC_PAINT_EXPORT ClientPathTransferCacheEntry
: public ClientTransferCacheEntryBase<TransferCacheEntryType::kPath> {
public:
explicit ClientPathTransferCacheEntry(const SkPath& path);
~ClientPathTransferCacheEntry() final;
uint32_t Id() const final;
size_t SerializedSize() const final;
bool Serialize(base::span<uint8_t> data) const final;
private:
SkPath path_;
size_t size_ = 0u;
};
class CC_PAINT_EXPORT ServicePathTransferCacheEntry
: public ServiceTransferCacheEntryBase<TransferCacheEntryType::kPath> {
public:
ServicePathTransferCacheEntry();
~ServicePathTransferCacheEntry() final;
size_t CachedSize() const final;
bool Deserialize(GrContext* context, base::span<const uint8_t> data) final;
const SkPath& path() const { return path_; }
private:
SkPath path_;
size_t size_ = 0;
};
} // namespace cc
#endif // CC_PAINT_PATH_TRANSFER_CACHE_ENTRY_H_
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cc/paint/textblob_transfer_cache_entry.h"
namespace cc {
ServiceTextBlobTransferCacheEntry::ServiceTextBlobTransferCacheEntry(
sk_sp<SkTextBlob> blob,
size_t size)
: blob_(std::move(blob)), size_(size) {}
ServiceTextBlobTransferCacheEntry::~ServiceTextBlobTransferCacheEntry() =
default;
size_t ServiceTextBlobTransferCacheEntry::CachedSize() const {
return size_;
}
bool ServiceTextBlobTransferCacheEntry::Deserialize(
GrContext* context,
base::span<const uint8_t> data) {
NOTREACHED();
return false;
}
} // namespace cc
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CC_PAINT_TEXTBLOB_TRANSFER_CACHE_ENTRY_H_
#define CC_PAINT_TEXTBLOB_TRANSFER_CACHE_ENTRY_H_
#include "cc/paint/paint_export.h"
#include "cc/paint/transfer_cache_entry.h"
#include "third_party/skia/include/core/SkTextBlob.h"
namespace cc {
class CC_PAINT_EXPORT ServiceTextBlobTransferCacheEntry
: public ServiceTransferCacheEntryBase<TransferCacheEntryType::kTextBlob> {
public:
ServiceTextBlobTransferCacheEntry(sk_sp<SkTextBlob> blob, size_t size);
~ServiceTextBlobTransferCacheEntry() final;
size_t CachedSize() const final;
bool Deserialize(GrContext* context, base::span<const uint8_t> data) final;
const sk_sp<SkTextBlob>& blob() const { return blob_; }
private:
sk_sp<SkTextBlob> blob_;
const size_t size_;
};
} // namespace cc
#endif // CC_PAINT_TEXTBLOB_TRANSFER_CACHE_ENTRY_H_
......@@ -9,7 +9,6 @@
#include "base/logging.h"
#include "cc/paint/color_space_transfer_cache_entry.h"
#include "cc/paint/image_transfer_cache_entry.h"
#include "cc/paint/path_transfer_cache_entry.h"
#include "cc/paint/raw_memory_transfer_cache_entry.h"
#include "cc/paint/shader_transfer_cache_entry.h"
......@@ -24,10 +23,7 @@ std::unique_ptr<ServiceTransferCacheEntry> ServiceTransferCacheEntry::Create(
return std::make_unique<ServiceImageTransferCacheEntry>();
case TransferCacheEntryType::kColorSpace:
return std::make_unique<ServiceColorSpaceTransferCacheEntry>();
case TransferCacheEntryType::kPath:
return std::make_unique<ServicePathTransferCacheEntry>();
case TransferCacheEntryType::kShader:
case TransferCacheEntryType::kTextBlob:
// ServiceShader/TextBlobTransferCache is only created via
// CreateLocalEntry and is never serialized/deserialized.
return nullptr;
......
......@@ -23,11 +23,9 @@ enum class TransferCacheEntryType : uint32_t {
kRawMemory,
kImage,
kColorSpace,
kPath,
kShader,
kTextBlob,
// Add new entries above this line, make sure to update kLast.
kLast = kTextBlob,
kLast = kShader,
};
// An interface used on the client to serialize a transfer cache entry
......
......@@ -12,6 +12,7 @@
#include "base/threading/thread_task_runner_handle.h"
#include "base/trace_event/memory_dump_manager.h"
#include "cc/paint/image_transfer_cache_entry.h"
#include "gpu/command_buffer/service/service_discardable_manager.h"
#include "third_party/skia/include/gpu/GrBackendSurface.h"
#include "ui/gl/trace_util.h"
......@@ -22,16 +23,6 @@ namespace {
// unbounded handle growth with tiny entries.
static size_t kMaxCacheEntries = 2000;
size_t ServiceTransferCacheSizeLimit() {
size_t memory_usage = 128 * 1024 * 1024;
if (base::SysInfo::IsLowEndDevice()) {
// Based on the 512KB limit used for discardable images in non-OOP-R, but
// gives an extra 256KB to allow for additional (non-image) cache items.
memory_usage = 768 * 1024;
}
return memory_usage;
}
// TODO(ericrk): Move this into ServiceImageTransferCacheEntry - here for now
// due to ui/gl dependency.
void DumpMemoryForImageTransferCacheEntry(
......@@ -78,7 +69,7 @@ ServiceTransferCache::CacheEntryInternal::operator=(
ServiceTransferCache::ServiceTransferCache()
: entries_(EntryCache::NO_AUTO_EVICT),
cache_size_limit_(ServiceTransferCacheSizeLimit()),
cache_size_limit_(DiscardableCacheSizeLimit()),
max_cache_entries_(kMaxCacheEntries) {
// In certain cases, ThreadTaskRunnerHandle isn't set (Android Webview).
// Don't register a dump provider in these cases.
......@@ -193,7 +184,7 @@ void ServiceTransferCache::PurgeMemory(
}
EnforceLimits();
cache_size_limit_ = ServiceTransferCacheSizeLimit();
cache_size_limit_ = DiscardableCacheSizeLimit();
}
bool ServiceTransferCache::OnMemoryDump(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment