Commit 5432155f authored by Antoine Labour's avatar Antoine Labour Committed by Commit Bot

Remove INTERNAL viz::internal::Resources

All Resources are now always DELEGATED, so remove functionality
associated with INTERNAL resources (and Resource::Origin).

Bug: 738190
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I1edfa175dadb4a50608f03097196af11bf02144a
Reviewed-on: https://chromium-review.googlesource.com/1023377
Commit-Queue: Antoine Labour <piman@chromium.org>
Reviewed-by: default avatardanakj <danakj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553462}
parent 1893a97d
......@@ -263,10 +263,8 @@ void DisplayResourceProvider::DeleteAndReturnUnusedResourcesToChild(
viz::ResourceId child_id = resource.id_in_child;
DCHECK(child_info->child_to_parent_map.count(child_id));
bool is_lost = resource.lost ||
(resource.is_gpu_resource_type() && lost_context_provider_);
if (resource.exported_count > 0 || resource.lock_for_read_count > 0 ||
resource.locked_for_external_use) {
bool is_lost = (resource.is_gpu_resource_type() && lost_context_provider_);
if (resource.lock_for_read_count > 0 || resource.locked_for_external_use) {
if (style != FOR_SHUTDOWN) {
// Defer this resource deletion.
resource.marked_for_deletion = true;
......@@ -393,17 +391,15 @@ void DisplayResourceProvider::ReceiveFromChild(
DCHECK(IsBitmapFormatSupported(it->format));
resource = InsertResource(
local_id,
viz::internal::Resource(it->size, viz::internal::Resource::DELEGATED,
viz::ResourceType::kBitmap, it->format,
it->color_space));
viz::internal::Resource(it->size, viz::ResourceType::kBitmap,
it->format, it->color_space));
resource->has_shared_bitmap_id = true;
resource->shared_bitmap_id = it->mailbox_holder.mailbox;
} else {
resource = InsertResource(
local_id,
viz::internal::Resource(it->size, viz::internal::Resource::DELEGATED,
viz::ResourceType::kTexture, it->format,
it->color_space));
viz::internal::Resource(it->size, viz::ResourceType::kTexture,
it->format, it->color_space));
resource->target = it->mailbox_holder.texture_target;
resource->filter = it->filter;
resource->original_filter = it->filter;
......@@ -488,8 +484,7 @@ GLenum DisplayResourceProvider::BindForSampling(viz::ResourceId resource_id,
bool DisplayResourceProvider::InUse(viz::ResourceId id) {
viz::internal::Resource* resource = GetResource(id);
return resource->lock_for_read_count > 0 || resource->lost ||
resource->locked_for_external_use;
return resource->lock_for_read_count > 0 || resource->locked_for_external_use;
}
DisplayResourceProvider::ScopedReadLockGL::ScopedReadLockGL(
......@@ -519,15 +514,12 @@ const viz::internal::Resource* DisplayResourceProvider::LockForRead(
if (!resource)
return nullptr;
DCHECK_EQ(resource->exported_count, 0);
// Mailbox sync_tokens must be processed by a call to WaitSyncToken() prior to
// calling LockForRead().
DCHECK_NE(viz::internal::Resource::NEEDS_WAIT,
resource->synchronization_state());
if (resource->is_gpu_resource_type() && !resource->gl_id) {
DCHECK(resource->origin != viz::internal::Resource::INTERNAL);
DCHECK(!resource->mailbox.IsZero());
GLES2Interface* gl = ContextGL();
......@@ -569,7 +561,6 @@ void DisplayResourceProvider::UnlockForRead(viz::ResourceId id) {
viz::internal::Resource* resource = &it->second;
DCHECK_GT(resource->lock_for_read_count, 0);
DCHECK_EQ(resource->exported_count, 0);
resource->lock_for_read_count--;
TryReleaseResource(it);
}
......@@ -582,7 +573,6 @@ viz::ResourceMetadata DisplayResourceProvider::LockForExternalUse(
viz::internal::Resource* resource = &it->second;
viz::ResourceMetadata metadata;
DCHECK_EQ(resource->exported_count, 0);
// Make sure there is no outstanding LockForExternalUse without calling
// UnlockForExternalUse.
DCHECK(!resource->locked_for_external_use);
......
......@@ -89,20 +89,6 @@ void ResourceProvider::DeleteResourceInternal(ResourceMap::iterator it,
DeleteStyle style) {
TRACE_EVENT0("cc", "ResourceProvider::DeleteResourceInternal");
viz::internal::Resource* resource = &it->second;
DCHECK(resource->exported_count == 0 || style != NORMAL);
// Exported resources are lost on shutdown.
bool exported_resource_lost =
style == FOR_SHUTDOWN && resource->exported_count > 0;
// GPU resources are lost when context is lost.
bool gpu_resource_lost =
resource->is_gpu_resource_type() && lost_context_provider_;
bool lost_resource =
resource->lost || exported_resource_lost || gpu_resource_lost;
// Wait on sync token before deleting resources we own.
if (!lost_resource && resource->origin == viz::internal::Resource::INTERNAL)
WaitSyncTokenInternal(resource);
if (resource->gl_id) {
GLES2Interface* gl = ContextGL();
......@@ -249,11 +235,9 @@ bool ResourceProvider::OnMemoryDump(
DCHECK(!shared_memory_guid.is_empty() || !guid.empty());
const int kImportanceForInteral = 2;
const int kImportanceForExternal = 1;
int importance = resource.origin == viz::internal::Resource::INTERNAL
? kImportanceForInteral
: kImportanceForExternal;
// The client that owns the resource will use a higher importance (2), and
// the GPU service will use a lower one (0).
const int importance = 1;
if (!shared_memory_guid.is_empty()) {
pmd->CreateSharedMemoryOwnershipEdge(dump->guid(), shared_memory_guid,
importance);
......
......@@ -11,12 +11,10 @@ namespace viz {
namespace internal {
Resource::Resource(const gfx::Size& size,
Origin origin,
ResourceType type,
ResourceFormat format,
const gfx::ColorSpace& color_space)
: locked_for_external_use(false),
lost(false),
marked_for_deletion(false),
read_lock_fences_enabled(false),
has_shared_bitmap_id(false),
......@@ -26,7 +24,6 @@ Resource::Resource(const gfx::Size& size,
wants_promotion_hint(false),
#endif
size(size),
origin(origin),
type(type),
format(format),
color_space(color_space) {
......
......@@ -35,7 +35,6 @@ namespace internal {
// for client and service libraries and should not be used directly from
// external client code.
struct VIZ_COMMON_EXPORT Resource {
enum Origin { INTERNAL, DELEGATED };
enum SynchronizationState {
// The LOCALLY_USED state is the state each resource defaults to when
// constructed or modified or read. This state indicates that the
......@@ -67,7 +66,6 @@ struct VIZ_COMMON_EXPORT Resource {
};
Resource(const gfx::Size& size,
Origin origin,
ResourceType type,
ResourceFormat format,
const gfx::ColorSpace& color_space);
......@@ -104,9 +102,6 @@ struct VIZ_COMMON_EXPORT Resource {
// Bitfield flags. ======
// When true, the resource is currently being used externally.
bool locked_for_external_use : 1;
// When true the resource can not be used and must only be deleted. This is
// passed along to the |release_callback|.
bool lost : 1;
// When the resource should be deleted until it is actually reaped.
bool marked_for_deletion : 1;
// Tracks if a gpu fence needs to be used for reading a GpuMemoryBuffer-
......@@ -150,7 +145,6 @@ struct VIZ_COMMON_EXPORT Resource {
// of the resource.
int lock_for_read_count = 0;
int imported_count = 0;
int exported_count = 0;
// A fence used for accessing a GpuMemoryBuffer-backed or texture-backed
// resource for reading, that ensures any writing done to the resource has
// been completed. This is implemented and used to implement transferring
......@@ -159,10 +153,6 @@ struct VIZ_COMMON_EXPORT Resource {
scoped_refptr<ResourceFence> read_lock_fence;
// Size of the resource in pixels.
gfx::Size size;
// Where the resource was originally allocated. Either internally by the
// ResourceProvider instance, or in a client and given to the ResourceProvider
// via IPC.
Origin origin = INTERNAL;
// The texture target for GpuMemoryBuffer- and texture-backed resources.
GLenum target = GL_TEXTURE_2D;
// The min/mag filter of the resource when it was given to/created by the
......
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