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

Unified Diff: cc/resources/resource_provider.h

Issue 1951193002: cc: Add mailbox support to ResourceProvider write locks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@worker_context_stream
Patch Set: cleanup tasks if ordering barrier fails Created 4 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
Index: cc/resources/resource_provider.h
diff --git a/cc/resources/resource_provider.h b/cc/resources/resource_provider.h
index 8a09f1c6b03939734c4238fc9a456aa6d97bbd0f..6b95b05fab1c4a0a72b6ff0b244b3af02d7c8c60 100644
--- a/cc/resources/resource_provider.h
+++ b/cc/resources/resource_provider.h
@@ -216,23 +216,23 @@ class CC_EXPORT ResourceProvider
public:
ScopedReadLockGL(ResourceProvider* resource_provider,
ResourceId resource_id);
- virtual ~ScopedReadLockGL();
+ ~ScopedReadLockGL();
- unsigned texture_id() const { return resource_->gl_id; }
- GLenum target() const { return resource_->target; }
- const gfx::Size& texture_size() const { return resource_->size; }
+ unsigned texture_id() const { return texture_id_; }
+ GLenum target() const { return target_; }
+ const gfx::Size& size() const { return size_; }
- protected:
+ private:
ResourceProvider* resource_provider_;
ResourceId resource_id_;
-
- private:
- const ResourceProvider::Resource* resource_;
+ unsigned texture_id_;
+ GLenum target_;
+ gfx::Size size_;
DISALLOW_COPY_AND_ASSIGN(ScopedReadLockGL);
};
- class CC_EXPORT ScopedSamplerGL : public ScopedReadLockGL {
+ class CC_EXPORT ScopedSamplerGL {
public:
ScopedSamplerGL(ResourceProvider* resource_provider,
ResourceId resource_id,
@@ -241,11 +241,13 @@ class CC_EXPORT ResourceProvider
ResourceId resource_id,
GLenum unit,
GLenum filter);
- ~ScopedSamplerGL() override;
+ ~ScopedSamplerGL();
+ unsigned texture_id() const { return resource_lock_.texture_id(); }
GLenum target() const { return target_; }
private:
+ ScopedReadLockGL resource_lock_;
GLenum unit_;
GLenum target_;
@@ -255,26 +257,74 @@ class CC_EXPORT ResourceProvider
class CC_EXPORT ScopedWriteLockGL {
public:
ScopedWriteLockGL(ResourceProvider* resource_provider,
- ResourceId resource_id);
+ ResourceId resource_id,
+ bool create_mailbox);
~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_; }
+
+ const TextureMailbox& mailbox() const { return mailbox_; }
- void UpdateResourceSyncToken(const gpu::SyncToken& sync_token) {
- set_sync_token_ = true;
+ void set_sync_token(const gpu::SyncToken& sync_token) {
sync_token_ = sync_token;
}
+ void set_synchronized(bool synchronized) { synchronized_ = synchronized; }
+
private:
ResourceProvider* resource_provider_;
- ResourceProvider::Resource* resource_;
+ ResourceId resource_id_;
unsigned texture_id_;
- bool set_sync_token_;
+ GLenum target_;
+ ResourceFormat format_;
+ gfx::Size size_;
+ TextureMailbox mailbox_;
gpu::SyncToken sync_token_;
+ bool synchronized_;
+ base::ThreadChecker thread_checker_;
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,
@@ -307,7 +357,7 @@ class CC_EXPORT ResourceProvider
private:
ResourceProvider* resource_provider_;
- ResourceProvider::Resource* resource_;
+ ResourceId resource_id_;
SkBitmap sk_bitmap_;
base::ThreadChecker thread_checker_;
@@ -324,7 +374,9 @@ class CC_EXPORT ResourceProvider
private:
ResourceProvider* resource_provider_;
- ResourceProvider::Resource* resource_;
+ ResourceId resource_id_;
+ ResourceFormat format_;
+ gfx::Size size_;
std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer_;
base::ThreadChecker thread_checker_;
@@ -337,56 +389,27 @@ class CC_EXPORT ResourceProvider
ResourceId resource_id);
~ScopedReadLockGpuMemoryBuffer();
+ ResourceId resource_id() const { return resource_id_; }
+
// This may return nullptr.
- gfx::GpuMemoryBuffer* GetGpuMemoryBuffer() const;
+ gfx::GpuMemoryBuffer* gpu_memory_buffer() const {
+ return gpu_memory_buffer_;
+ }
// This returns the GL texture that is backed by a GL image bound to the
// resource's GpuMemoryBuffer.
- unsigned GetTextureId() const;
-
- ResourceId GetResourceId() const;
+ unsigned texture_id() const { return texture_id_; }
private:
ResourceProvider* resource_provider_;
ResourceId resource_id_;
- const ResourceProvider::Resource* resource_;
+ gfx::GpuMemoryBuffer* gpu_memory_buffer_;
+ unsigned texture_id_;
base::ThreadChecker thread_checker_;
DISALLOW_COPY_AND_ASSIGN(ScopedReadLockGpuMemoryBuffer);
};
- class CC_EXPORT ScopedWriteLockGr {
- public:
- ScopedWriteLockGr(ResourceProvider* resource_provider,
- ResourceId resource_id);
- ~ScopedWriteLockGr();
-
- void InitSkSurface(GrContext* gr_context,
- bool use_distance_field_text,
- bool can_use_lcd_text,
- int msaa_sample_count);
- void ReleaseSkSurface();
-
- SkSurface* sk_surface() { return sk_surface_.get(); }
-
- gfx::Size GetResourceSize() const { return resource_->size; }
-
- void UpdateResourceSyncToken(const gpu::SyncToken& sync_token) {
- set_sync_token_ = true;
- sync_token_ = sync_token;
- }
-
- private:
- ResourceProvider* resource_provider_;
- ResourceProvider::Resource* resource_;
- base::ThreadChecker thread_checker_;
- sk_sp<SkSurface> sk_surface_;
- bool set_sync_token_;
- gpu::SyncToken sync_token_;
-
- DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockGr);
- };
-
class Fence : public base::RefCounted<Fence> {
public:
Fence() {}

Powered by Google App Engine
This is Rietveld 408576698