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( ...@@ -263,10 +263,8 @@ void DisplayResourceProvider::DeleteAndReturnUnusedResourcesToChild(
viz::ResourceId child_id = resource.id_in_child; viz::ResourceId child_id = resource.id_in_child;
DCHECK(child_info->child_to_parent_map.count(child_id)); DCHECK(child_info->child_to_parent_map.count(child_id));
bool is_lost = resource.lost || bool is_lost = (resource.is_gpu_resource_type() && lost_context_provider_);
(resource.is_gpu_resource_type() && lost_context_provider_); if (resource.lock_for_read_count > 0 || resource.locked_for_external_use) {
if (resource.exported_count > 0 || resource.lock_for_read_count > 0 ||
resource.locked_for_external_use) {
if (style != FOR_SHUTDOWN) { if (style != FOR_SHUTDOWN) {
// Defer this resource deletion. // Defer this resource deletion.
resource.marked_for_deletion = true; resource.marked_for_deletion = true;
...@@ -393,17 +391,15 @@ void DisplayResourceProvider::ReceiveFromChild( ...@@ -393,17 +391,15 @@ void DisplayResourceProvider::ReceiveFromChild(
DCHECK(IsBitmapFormatSupported(it->format)); DCHECK(IsBitmapFormatSupported(it->format));
resource = InsertResource( resource = InsertResource(
local_id, local_id,
viz::internal::Resource(it->size, viz::internal::Resource::DELEGATED, viz::internal::Resource(it->size, viz::ResourceType::kBitmap,
viz::ResourceType::kBitmap, it->format, it->format, it->color_space));
it->color_space));
resource->has_shared_bitmap_id = true; resource->has_shared_bitmap_id = true;
resource->shared_bitmap_id = it->mailbox_holder.mailbox; resource->shared_bitmap_id = it->mailbox_holder.mailbox;
} else { } else {
resource = InsertResource( resource = InsertResource(
local_id, local_id,
viz::internal::Resource(it->size, viz::internal::Resource::DELEGATED, viz::internal::Resource(it->size, viz::ResourceType::kTexture,
viz::ResourceType::kTexture, it->format, it->format, it->color_space));
it->color_space));
resource->target = it->mailbox_holder.texture_target; resource->target = it->mailbox_holder.texture_target;
resource->filter = it->filter; resource->filter = it->filter;
resource->original_filter = it->filter; resource->original_filter = it->filter;
...@@ -488,8 +484,7 @@ GLenum DisplayResourceProvider::BindForSampling(viz::ResourceId resource_id, ...@@ -488,8 +484,7 @@ GLenum DisplayResourceProvider::BindForSampling(viz::ResourceId resource_id,
bool DisplayResourceProvider::InUse(viz::ResourceId id) { bool DisplayResourceProvider::InUse(viz::ResourceId id) {
viz::internal::Resource* resource = GetResource(id); viz::internal::Resource* resource = GetResource(id);
return resource->lock_for_read_count > 0 || resource->lost || return resource->lock_for_read_count > 0 || resource->locked_for_external_use;
resource->locked_for_external_use;
} }
DisplayResourceProvider::ScopedReadLockGL::ScopedReadLockGL( DisplayResourceProvider::ScopedReadLockGL::ScopedReadLockGL(
...@@ -519,15 +514,12 @@ const viz::internal::Resource* DisplayResourceProvider::LockForRead( ...@@ -519,15 +514,12 @@ const viz::internal::Resource* DisplayResourceProvider::LockForRead(
if (!resource) if (!resource)
return nullptr; return nullptr;
DCHECK_EQ(resource->exported_count, 0);
// Mailbox sync_tokens must be processed by a call to WaitSyncToken() prior to // Mailbox sync_tokens must be processed by a call to WaitSyncToken() prior to
// calling LockForRead(). // calling LockForRead().
DCHECK_NE(viz::internal::Resource::NEEDS_WAIT, DCHECK_NE(viz::internal::Resource::NEEDS_WAIT,
resource->synchronization_state()); resource->synchronization_state());
if (resource->is_gpu_resource_type() && !resource->gl_id) { if (resource->is_gpu_resource_type() && !resource->gl_id) {
DCHECK(resource->origin != viz::internal::Resource::INTERNAL);
DCHECK(!resource->mailbox.IsZero()); DCHECK(!resource->mailbox.IsZero());
GLES2Interface* gl = ContextGL(); GLES2Interface* gl = ContextGL();
...@@ -569,7 +561,6 @@ void DisplayResourceProvider::UnlockForRead(viz::ResourceId id) { ...@@ -569,7 +561,6 @@ void DisplayResourceProvider::UnlockForRead(viz::ResourceId id) {
viz::internal::Resource* resource = &it->second; viz::internal::Resource* resource = &it->second;
DCHECK_GT(resource->lock_for_read_count, 0); DCHECK_GT(resource->lock_for_read_count, 0);
DCHECK_EQ(resource->exported_count, 0);
resource->lock_for_read_count--; resource->lock_for_read_count--;
TryReleaseResource(it); TryReleaseResource(it);
} }
...@@ -582,7 +573,6 @@ viz::ResourceMetadata DisplayResourceProvider::LockForExternalUse( ...@@ -582,7 +573,6 @@ viz::ResourceMetadata DisplayResourceProvider::LockForExternalUse(
viz::internal::Resource* resource = &it->second; viz::internal::Resource* resource = &it->second;
viz::ResourceMetadata metadata; viz::ResourceMetadata metadata;
DCHECK_EQ(resource->exported_count, 0);
// Make sure there is no outstanding LockForExternalUse without calling // Make sure there is no outstanding LockForExternalUse without calling
// UnlockForExternalUse. // UnlockForExternalUse.
DCHECK(!resource->locked_for_external_use); DCHECK(!resource->locked_for_external_use);
......
...@@ -89,20 +89,6 @@ void ResourceProvider::DeleteResourceInternal(ResourceMap::iterator it, ...@@ -89,20 +89,6 @@ void ResourceProvider::DeleteResourceInternal(ResourceMap::iterator it,
DeleteStyle style) { DeleteStyle style) {
TRACE_EVENT0("cc", "ResourceProvider::DeleteResourceInternal"); TRACE_EVENT0("cc", "ResourceProvider::DeleteResourceInternal");
viz::internal::Resource* resource = &it->second; 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) { if (resource->gl_id) {
GLES2Interface* gl = ContextGL(); GLES2Interface* gl = ContextGL();
...@@ -249,11 +235,9 @@ bool ResourceProvider::OnMemoryDump( ...@@ -249,11 +235,9 @@ bool ResourceProvider::OnMemoryDump(
DCHECK(!shared_memory_guid.is_empty() || !guid.empty()); DCHECK(!shared_memory_guid.is_empty() || !guid.empty());
const int kImportanceForInteral = 2; // The client that owns the resource will use a higher importance (2), and
const int kImportanceForExternal = 1; // the GPU service will use a lower one (0).
int importance = resource.origin == viz::internal::Resource::INTERNAL const int importance = 1;
? kImportanceForInteral
: kImportanceForExternal;
if (!shared_memory_guid.is_empty()) { if (!shared_memory_guid.is_empty()) {
pmd->CreateSharedMemoryOwnershipEdge(dump->guid(), shared_memory_guid, pmd->CreateSharedMemoryOwnershipEdge(dump->guid(), shared_memory_guid,
importance); importance);
......
...@@ -11,12 +11,10 @@ namespace viz { ...@@ -11,12 +11,10 @@ namespace viz {
namespace internal { namespace internal {
Resource::Resource(const gfx::Size& size, Resource::Resource(const gfx::Size& size,
Origin origin,
ResourceType type, ResourceType type,
ResourceFormat format, ResourceFormat format,
const gfx::ColorSpace& color_space) const gfx::ColorSpace& color_space)
: locked_for_external_use(false), : locked_for_external_use(false),
lost(false),
marked_for_deletion(false), marked_for_deletion(false),
read_lock_fences_enabled(false), read_lock_fences_enabled(false),
has_shared_bitmap_id(false), has_shared_bitmap_id(false),
...@@ -26,7 +24,6 @@ Resource::Resource(const gfx::Size& size, ...@@ -26,7 +24,6 @@ Resource::Resource(const gfx::Size& size,
wants_promotion_hint(false), wants_promotion_hint(false),
#endif #endif
size(size), size(size),
origin(origin),
type(type), type(type),
format(format), format(format),
color_space(color_space) { color_space(color_space) {
......
...@@ -35,7 +35,6 @@ namespace internal { ...@@ -35,7 +35,6 @@ namespace internal {
// for client and service libraries and should not be used directly from // for client and service libraries and should not be used directly from
// external client code. // external client code.
struct VIZ_COMMON_EXPORT Resource { struct VIZ_COMMON_EXPORT Resource {
enum Origin { INTERNAL, DELEGATED };
enum SynchronizationState { enum SynchronizationState {
// The LOCALLY_USED state is the state each resource defaults to when // The LOCALLY_USED state is the state each resource defaults to when
// constructed or modified or read. This state indicates that the // constructed or modified or read. This state indicates that the
...@@ -67,7 +66,6 @@ struct VIZ_COMMON_EXPORT Resource { ...@@ -67,7 +66,6 @@ struct VIZ_COMMON_EXPORT Resource {
}; };
Resource(const gfx::Size& size, Resource(const gfx::Size& size,
Origin origin,
ResourceType type, ResourceType type,
ResourceFormat format, ResourceFormat format,
const gfx::ColorSpace& color_space); const gfx::ColorSpace& color_space);
...@@ -104,9 +102,6 @@ struct VIZ_COMMON_EXPORT Resource { ...@@ -104,9 +102,6 @@ struct VIZ_COMMON_EXPORT Resource {
// Bitfield flags. ====== // Bitfield flags. ======
// When true, the resource is currently being used externally. // When true, the resource is currently being used externally.
bool locked_for_external_use : 1; 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. // When the resource should be deleted until it is actually reaped.
bool marked_for_deletion : 1; bool marked_for_deletion : 1;
// Tracks if a gpu fence needs to be used for reading a GpuMemoryBuffer- // Tracks if a gpu fence needs to be used for reading a GpuMemoryBuffer-
...@@ -150,7 +145,6 @@ struct VIZ_COMMON_EXPORT Resource { ...@@ -150,7 +145,6 @@ struct VIZ_COMMON_EXPORT Resource {
// of the resource. // of the resource.
int lock_for_read_count = 0; int lock_for_read_count = 0;
int imported_count = 0; int imported_count = 0;
int exported_count = 0;
// A fence used for accessing a GpuMemoryBuffer-backed or texture-backed // A fence used for accessing a GpuMemoryBuffer-backed or texture-backed
// resource for reading, that ensures any writing done to the resource has // resource for reading, that ensures any writing done to the resource has
// been completed. This is implemented and used to implement transferring // been completed. This is implemented and used to implement transferring
...@@ -159,10 +153,6 @@ struct VIZ_COMMON_EXPORT Resource { ...@@ -159,10 +153,6 @@ struct VIZ_COMMON_EXPORT Resource {
scoped_refptr<ResourceFence> read_lock_fence; scoped_refptr<ResourceFence> read_lock_fence;
// Size of the resource in pixels. // Size of the resource in pixels.
gfx::Size size; 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. // The texture target for GpuMemoryBuffer- and texture-backed resources.
GLenum target = GL_TEXTURE_2D; GLenum target = GL_TEXTURE_2D;
// The min/mag filter of the resource when it was given to/created by the // 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