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

Unified Diff: gpu/command_buffer/client/mapped_memory.h

Issue 1168853002: Use mapped memory for uploading large textures. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Same fix for TexImage3D, also share uploading code. Created 5 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: gpu/command_buffer/client/mapped_memory.h
diff --git a/gpu/command_buffer/client/mapped_memory.h b/gpu/command_buffer/client/mapped_memory.h
index 10ac639929f3664a15d425c9b8fb82f46d331e1a..767bac7d0062ce3a0d7884c48e1c035950fe488f 100644
--- a/gpu/command_buffer/client/mapped_memory.h
+++ b/gpu/command_buffer/client/mapped_memory.h
@@ -199,6 +199,66 @@ class GPU_EXPORT MappedMemoryManager {
DISALLOW_COPY_AND_ASSIGN(MappedMemoryManager);
};
+// A class that will manage the lifetime of a mapped memory allocation
+class GPU_EXPORT ScopedMappedMemoryPtr {
+ public:
+ ScopedMappedMemoryPtr(
+ uint32_t size,
+ CommandBufferHelper* helper,
+ MappedMemoryManager* mapped_memory_manager)
+ : buffer_(NULL),
+ size_(0),
+ shm_id_(0),
+ shm_offset_(0),
+ flush_after_release_(false),
+ helper_(helper),
+ mapped_memory_manager_(mapped_memory_manager) {
+ Reset(size);
+ }
+
+ ~ScopedMappedMemoryPtr() {
+ Release();
+ }
+
+ bool valid() const {
+ return buffer_ != NULL;
+ }
+
+ void SetFlushAfterRelease(bool flush_after_release) {
+ flush_after_release_ = flush_after_release;
+ }
+
+ uint32_t size() const {
+ return size_;
+ }
+
+ int32_t shm_id() const {
+ return shm_id_;
+ }
+
+ uint32_t offset() const {
+ return shm_offset_;
+ }
+
+ void* address() const {
+ return buffer_;
+ }
+
+ void Release();
+
+ void Reset(uint32_t new_size);
+
+ private:
+ void* buffer_;
+ uint32_t size_;
+ int32_t shm_id_;
+ uint32_t shm_offset_;
+ bool flush_after_release_;
+ CommandBufferHelper* helper_;
+ MappedMemoryManager* mapped_memory_manager_;
+ DISALLOW_COPY_AND_ASSIGN(ScopedMappedMemoryPtr);
+};
+
} // namespace gpu
#endif // GPU_COMMAND_BUFFER_CLIENT_MAPPED_MEMORY_H_

Powered by Google App Engine
This is Rietveld 408576698