#include "cc/raster/staging_buffer_pool.h"
#include <memory>
#include <string>
#include <utility>
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/ranges/algorithm.h"
#include "base/strings/stringprintf.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "base/trace_event/memory_dump_manager.h"
#include "cc/base/container_util.h"
#include "components/viz/common/gpu/raster_context_provider.h"
#include "components/viz/common/resources/resource_sizes.h"
#include "gpu/command_buffer/client/context_support.h"
#include "gpu/command_buffer/client/raster_interface.h"
#include "gpu/command_buffer/client/shared_image_interface.h"
#include "third_party/khronos/GLES2/gl2.h"
#include "third_party/khronos/GLES2/gl2ext.h"
MemoryAllocatorDump;
MemoryAllocatorDumpGuid;
MemoryDumpLevelOfDetail;
namespace cc {
namespace {
const int kCheckForQueryResultAvailableTickRateMs = …;
const int kMaxCheckForQueryResultAvailableAttempts = …;
const int kStagingBufferExpirationDelayMs = …;
bool CheckForQueryResult(gpu::raster::RasterInterface* ri, GLuint query_id) { … }
void WaitForQueryResult(gpu::raster::RasterInterface* ri, GLuint query_id) { … }
}
StagingBuffer::StagingBuffer(const gfx::Size& size,
viz::SharedImageFormat format)
: … { … }
StagingBuffer::~StagingBuffer() { … }
void StagingBuffer::DestroyGLResources(gpu::raster::RasterInterface* ri,
gpu::SharedImageInterface* sii) { … }
void StagingBuffer::OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd,
viz::SharedImageFormat dump_format,
bool in_free_list) const { … }
StagingBufferPool::StagingBufferPool(
scoped_refptr<base::SequencedTaskRunner> task_runner,
viz::RasterContextProvider* worker_context_provider,
bool use_partial_raster,
int max_staging_buffer_usage_in_bytes)
: … { … }
StagingBufferPool::~StagingBufferPool() { … }
void StagingBufferPool::Shutdown() { … }
void StagingBufferPool::ReleaseStagingBuffer(
std::unique_ptr<StagingBuffer> staging_buffer) { … }
bool StagingBufferPool::OnMemoryDump(
const base::trace_event::MemoryDumpArgs& args,
base::trace_event::ProcessMemoryDump* pmd) { … }
void StagingBufferPool::AddStagingBuffer(const StagingBuffer* staging_buffer,
viz::SharedImageFormat format) { … }
void StagingBufferPool::RemoveStagingBuffer(
const StagingBuffer* staging_buffer) { … }
void StagingBufferPool::MarkStagingBufferAsFree(
const StagingBuffer* staging_buffer) { … }
void StagingBufferPool::MarkStagingBufferAsBusy(
const StagingBuffer* staging_buffer) { … }
std::unique_ptr<StagingBuffer> StagingBufferPool::AcquireStagingBuffer(
const gfx::Size& size,
viz::SharedImageFormat format,
uint64_t previous_content_id) { … }
base::TimeTicks StagingBufferPool::GetUsageTimeForLRUBuffer() { … }
void StagingBufferPool::ScheduleReduceMemoryUsage() { … }
void StagingBufferPool::ReduceMemoryUsage() { … }
void StagingBufferPool::ReleaseBuffersNotUsedSince(base::TimeTicks time) { … }
void StagingBufferPool::OnMemoryPressure(
base::MemoryPressureListener::MemoryPressureLevel level) { … }
}