Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Unified Diff: cc/resources/resource_provider.h

Issue 2885533002: cc: Allocate resources on worker context.
Patch Set: rebase Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/resources/resource_format.cc ('k') | cc/resources/resource_provider.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/resource_provider.h
diff --git a/cc/resources/resource_provider.h b/cc/resources/resource_provider.h
index 238cc13c33ff19ee3cba3096432129e1a06d98a0..8fdbd39ae23093fc9b6981e1d0886dd4ea23f734 100644
--- a/cc/resources/resource_provider.h
+++ b/cc/resources/resource_provider.h
@@ -205,7 +205,8 @@ class CC_EXPORT ResourceProvider
// NOTE: if the sync_token is set on any TransferableResource, this will
// wait on it.
void ReceiveFromChild(
- int child, const TransferableResourceArray& transferable_resources);
+ int child,
+ const TransferableResourceArray& transferable_resources);
// Once a set of resources have been received, they may or may not be used.
// This declares what set of resources are currently in use from the child,
@@ -247,6 +248,7 @@ class CC_EXPORT ResourceProvider
private:
ResourceProvider* resource_provider_;
ResourceId resource_id_;
+
unsigned texture_id_;
GLenum target_;
gfx::Size size_;
@@ -284,81 +286,57 @@ class CC_EXPORT ResourceProvider
public:
ScopedWriteLockGL(ResourceProvider* resource_provider,
ResourceId resource_id,
- bool create_mailbox);
+ bool async_worker_context_enabled);
~ScopedWriteLockGL();
unsigned texture_id() const { return texture_id_; }
GLenum target() const { return target_; }
ResourceFormat format() const { return format_; }
const gfx::Size& size() const { return size_; }
+
// Will return the invalid color space unless
// |enable_color_correct_rasterization| is true.
const gfx::ColorSpace& color_space_for_raster() const {
- return color_space_;
+ return color_space_for_raster_;
}
- const TextureMailbox& mailbox() const { return mailbox_; }
-
void set_sync_token(const gpu::SyncToken& sync_token) {
+ set_sync_token_ = true;
sync_token_ = sync_token;
- has_sync_token_ = true;
}
- void set_synchronized(bool synchronized) { synchronized_ = synchronized; }
+ // Creates a texture id, allocating if necessary, on the given context. The
+ // texture id must be deleted by the caller.
+ unsigned ConsumeTexture(gpu::gles2::GLES2Interface* gl);
private:
ResourceProvider* resource_provider_;
ResourceId resource_id_;
+ bool async_worker_context_enabled_;
+
+ ResourceType type_;
unsigned texture_id_;
+ std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer_;
+ gfx::BufferUsage usage_;
+ unsigned image_id_;
+ unsigned bound_image_id_;
+ bool dirty_image_;
GLenum target_;
ResourceFormat format_;
gfx::Size size_;
- TextureMailbox mailbox_;
+ gfx::ColorSpace color_space_;
+ gfx::ColorSpace color_space_for_raster_;
+ TextureHint hint_;
+ bool allocated_;
+ gpu::Mailbox mailbox_;
gpu::SyncToken sync_token_;
- bool has_sync_token_;
- bool synchronized_;
+ bool set_sync_token_;
+
base::ThreadChecker thread_checker_;
- gfx::ColorSpace color_space_;
DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockGL);
};
- class CC_EXPORT ScopedTextureProvider {
- public:
- ScopedTextureProvider(gpu::gles2::GLES2Interface* gl,
- ScopedWriteLockGL* resource_lock,
- bool use_mailbox);
- ~ScopedTextureProvider();
-
- unsigned texture_id() const { return texture_id_; }
-
- private:
- gpu::gles2::GLES2Interface* gl_;
- bool use_mailbox_;
- unsigned texture_id_;
-
- DISALLOW_COPY_AND_ASSIGN(ScopedTextureProvider);
- };
-
- class CC_EXPORT ScopedSkSurfaceProvider {
- public:
- ScopedSkSurfaceProvider(ContextProvider* context_provider,
- ScopedWriteLockGL* resource_lock,
- bool use_mailbox,
- bool use_distance_field_text,
- bool can_use_lcd_text,
- int msaa_sample_count);
- ~ScopedSkSurfaceProvider();
-
- SkSurface* sk_surface() { return sk_surface_.get(); }
-
- private:
- ScopedTextureProvider texture_provider_;
- sk_sp<SkSurface> sk_surface_;
-
- DISALLOW_COPY_AND_ASSIGN(ScopedSkSurfaceProvider);
- };
-
class CC_EXPORT ScopedReadLockSoftware {
public:
ScopedReadLockSoftware(ResourceProvider* resource_provider,
@@ -415,8 +393,9 @@ class CC_EXPORT ResourceProvider
private:
ResourceProvider* resource_provider_;
ResourceId resource_id_;
- SkBitmap sk_bitmap_;
gfx::ColorSpace color_space_;
+ SkBitmap sk_bitmap_;
+
base::ThreadChecker thread_checker_;
DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockSoftware);
@@ -437,11 +416,14 @@ class CC_EXPORT ResourceProvider
private:
ResourceProvider* resource_provider_;
ResourceId resource_id_;
+
+ gfx::Size size_;
ResourceFormat format_;
gfx::BufferUsage usage_;
- gfx::Size size_;
- std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer_;
gfx::ColorSpace color_space_;
+
+ std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer_;
+
base::ThreadChecker thread_checker_;
DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockGpuMemoryBuffer);
@@ -663,17 +645,16 @@ class CC_EXPORT ResourceProvider
unsigned bound_image_id;
TextureHint hint;
ResourceType type;
-
// GpuMemoryBuffer resource allocation needs to know how the resource will
// be used.
gfx::BufferUsage usage;
- // This is the the actual format of the underlaying GpuMemoryBuffer, if any,
- // and might not correspond to ResourceFormat. This format is needed to
- // scanout the buffer as HW overlay.
+ // TODO(sunnyps): Unused. To be removed in a followup cleanup CL.
gfx::BufferFormat buffer_format;
// Resource format is the format as seen from the compositor and might not
// correspond to buffer_format (e.g: A resouce that was created from a YUV
- // buffer could be seen as RGB from the compositor/GL.)
+ // buffer could be seen as RGB from the compositor/GL.) The format of the
+ // underlying GpuMemoryBuffer, if any, may be different and can be obtained
+ // from |ResourceProvider::GetBufferFormat|.
ResourceFormat format;
SharedBitmapId shared_bitmap_id;
SharedBitmap* shared_bitmap;
@@ -724,9 +705,6 @@ class CC_EXPORT ResourceProvider
void PopulateSkBitmapWithResource(SkBitmap* sk_bitmap,
const Resource* resource);
- void CreateMailboxAndBindResource(gpu::gles2::GLES2Interface* gl,
- Resource* resource);
-
void TransferResource(Resource* source,
ResourceId id,
TransferableResource* resource);
@@ -739,11 +717,39 @@ class CC_EXPORT ResourceProvider
DeleteStyle style,
const ResourceIdArray& unused);
void DestroyChildInternal(ChildMap::iterator it, DeleteStyle style);
+
void LazyCreate(Resource* resource);
+
+ void LazyCreateMailbox(Resource* resource);
+
void LazyAllocate(Resource* resource);
+
+ void AllocateGLTexture(gpu::gles2::GLES2Interface* gl,
+ unsigned gl_id,
+ GLenum target,
+ const gfx::Size& size,
+ ResourceFormat format,
+ TextureHint hint);
+
+ std::unique_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBuffer(
+ const gfx::Size& size,
+ ResourceFormat format,
+ gfx::BufferUsage usage,
+ gfx::ColorSpace color_space);
+
+ void SetGpuMemoryBuffer(
+ Resource* resource,
+ std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer);
+
+ unsigned CreateImage(gpu::gles2::GLES2Interface* gl,
+ gfx::GpuMemoryBuffer* gpu_memory_buffer,
+ const gfx::Size& size,
+ ResourceFormat format);
+
void LazyCreateImage(Resource* resource);
void BindImageForSampling(Resource* resource);
+
// Binds the given GL resource to a texture target for sampling using the
// specified filter for both minification and magnification. Returns the
// texture target used. The resource must be locked for reading.
« no previous file with comments | « cc/resources/resource_format.cc ('k') | cc/resources/resource_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698