blob: 682eba3ca2b49fa229f1f47401663d1e2e732948 [file] [log] [blame]
// 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 "base/containers/flat_set.h"
#include "gpu/command_buffer/common/mailbox.h"
#include "gpu/command_buffer/service/shared_image_backing.h"
#include "gpu/gpu_gles2_export.h"
namespace gpu {
class SharedImageRepresentationFactoryRef;
class GPU_GLES2_EXPORT SharedImageManager {
// Registers a SharedImageBacking with the manager and returns a
// SharedImageRepresentationFactoryRef which holds a ref on the SharedImage.
// The factory should delete this object to release the ref.
std::unique_ptr<SharedImageRepresentationFactoryRef> Register(
std::unique_ptr<SharedImageBacking> backing,
MemoryTypeTracker* ref);
// Marks the backing associated with a mailbox as context lost.
void OnContextLost(const Mailbox& mailbox);
// Indicates whether a mailbox is associated with a SharedImage.
bool IsSharedImage(const Mailbox& mailbox);
// Accessors which return a SharedImageRepresentation. Representations also
// take a ref on the mailbox, releasing it when the representation is
// destroyed.
std::unique_ptr<SharedImageRepresentationGLTexture> ProduceGLTexture(
const Mailbox& mailbox,
MemoryTypeTracker* ref);
ProduceGLTexturePassthrough(const Mailbox& mailbox, MemoryTypeTracker* ref);
std::unique_ptr<SharedImageRepresentationSkia> ProduceSkia(
const Mailbox& mailbox,
MemoryTypeTracker* ref);
// Called by SharedImageRepresentation in the destructor.
void OnRepresentationDestroyed(const Mailbox& mailbox,
SharedImageRepresentation* representation);
// Dump memory for the given mailbox.
void OnMemoryDump(const Mailbox& mailbox,
base::trace_event::ProcessMemoryDump* pmd,
int client_id,
uint64_t client_tracing_id);
base::flat_set<std::unique_ptr<SharedImageBacking>> images_;
} // namespace gpu