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

Side by Side Diff: gpu/ipc/in_process_command_buffer.cc

Issue 2531963002: gfx: Fix sending native ozone pixmaps from InProcessCommandBuffer. (Closed)
Patch Set: . Created 4 years 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 unified diff | Download patch
« no previous file with comments | « gpu/ipc/client/gpu_channel_host.cc ('k') | ui/gfx/gpu_memory_buffer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "gpu/ipc/in_process_command_buffer.h" 5 #include "gpu/ipc/in_process_command_buffer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <queue> 10 #include <queue>
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 101
102 class ScopedEvent { 102 class ScopedEvent {
103 public: 103 public:
104 explicit ScopedEvent(base::WaitableEvent* event) : event_(event) {} 104 explicit ScopedEvent(base::WaitableEvent* event) : event_(event) {}
105 ~ScopedEvent() { event_->Signal(); } 105 ~ScopedEvent() { event_->Signal(); }
106 106
107 private: 107 private:
108 base::WaitableEvent* event_; 108 base::WaitableEvent* event_;
109 }; 109 };
110 110
111 base::SharedMemoryHandle ShareToGpuThread(
112 base::SharedMemoryHandle source_handle) {
113 return base::SharedMemory::DuplicateHandle(source_handle);
114 }
115
116 gfx::GpuMemoryBufferHandle ShareGpuMemoryBufferToGpuThread(
117 const gfx::GpuMemoryBufferHandle& source_handle,
118 bool* requires_sync_point) {
119 switch (source_handle.type) {
120 case gfx::SHARED_MEMORY_BUFFER: {
121 gfx::GpuMemoryBufferHandle handle;
122 handle.type = gfx::SHARED_MEMORY_BUFFER;
123 handle.handle = ShareToGpuThread(source_handle.handle);
124 handle.offset = source_handle.offset;
125 handle.stride = source_handle.stride;
126 *requires_sync_point = false;
127 return handle;
128 }
129 case gfx::IO_SURFACE_BUFFER:
130 case gfx::OZONE_NATIVE_PIXMAP:
131 *requires_sync_point = true;
132 return source_handle;
133 default:
134 NOTREACHED();
135 return gfx::GpuMemoryBufferHandle();
136 }
137 }
138
139 scoped_refptr<InProcessCommandBuffer::Service> GetInitialService( 111 scoped_refptr<InProcessCommandBuffer::Service> GetInitialService(
140 const scoped_refptr<InProcessCommandBuffer::Service>& service) { 112 const scoped_refptr<InProcessCommandBuffer::Service>& service) {
141 if (service) 113 if (service)
142 return service; 114 return service;
143 115
144 // Call base::ThreadTaskRunnerHandle::IsSet() to ensure that it is 116 // Call base::ThreadTaskRunnerHandle::IsSet() to ensure that it is
145 // instantiated before we create the GPU thread, otherwise shutdown order will 117 // instantiated before we create the GPU thread, otherwise shutdown order will
146 // delete the ThreadTaskRunnerHandle before the GPU thread's message loop, 118 // delete the ThreadTaskRunnerHandle before the GPU thread's message loop,
147 // and when the message loop is shutdown, it will recreate 119 // and when the message loop is shutdown, it will recreate
148 // ThreadTaskRunnerHandle, which will re-add a new task to the, AtExitManager, 120 // ThreadTaskRunnerHandle, which will re-add a new task to the, AtExitManager,
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 int32_t new_id = next_image_id_.GetNext(); 710 int32_t new_id = next_image_id_.GetNext();
739 711
740 DCHECK(gpu::IsGpuMemoryBufferFormatSupported(gpu_memory_buffer->GetFormat(), 712 DCHECK(gpu::IsGpuMemoryBufferFormatSupported(gpu_memory_buffer->GetFormat(),
741 capabilities_)); 713 capabilities_));
742 DCHECK(gpu::IsImageFormatCompatibleWithGpuMemoryBufferFormat( 714 DCHECK(gpu::IsImageFormatCompatibleWithGpuMemoryBufferFormat(
743 internalformat, gpu_memory_buffer->GetFormat())); 715 internalformat, gpu_memory_buffer->GetFormat()));
744 716
745 // This handle is owned by the GPU thread and must be passed to it or it 717 // This handle is owned by the GPU thread and must be passed to it or it
746 // will leak. In otherwords, do not early out on error between here and the 718 // will leak. In otherwords, do not early out on error between here and the
747 // queuing of the CreateImage task below. 719 // queuing of the CreateImage task below.
748 bool requires_sync_point = false; 720 gfx::GpuMemoryBufferHandle handle =
749 gfx::GpuMemoryBufferHandle handle = ShareGpuMemoryBufferToGpuThread( 721 gfx::CloneHandleForIPC(gpu_memory_buffer->GetHandle());
750 gpu_memory_buffer->GetHandle(), &requires_sync_point); 722 bool requires_sync_point = handle.type == gfx::IO_SURFACE_BUFFER;
751 723
752 uint64_t fence_sync = 0; 724 uint64_t fence_sync = 0;
753 if (requires_sync_point) { 725 if (requires_sync_point) {
754 fence_sync = GenerateFenceSyncRelease(); 726 fence_sync = GenerateFenceSyncRelease();
755 727
756 // Previous fence syncs should be flushed already. 728 // Previous fence syncs should be flushed already.
757 DCHECK_EQ(fence_sync - 1, flushed_fence_sync_release_); 729 DCHECK_EQ(fence_sync - 1, flushed_fence_sync_release_);
758 } 730 }
759 731
760 QueueTask(false, base::Bind(&InProcessCommandBuffer::CreateImageOnGpuThread, 732 QueueTask(false, base::Bind(&InProcessCommandBuffer::CreateImageOnGpuThread,
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
1201 return wrapped_callback; 1173 return wrapped_callback;
1202 } 1174 }
1203 1175
1204 InProcessCommandBuffer::GpuTask::GpuTask(const base::Closure& callback, 1176 InProcessCommandBuffer::GpuTask::GpuTask(const base::Closure& callback,
1205 uint32_t order_number) 1177 uint32_t order_number)
1206 : callback(callback), order_number(order_number) {} 1178 : callback(callback), order_number(order_number) {}
1207 1179
1208 InProcessCommandBuffer::GpuTask::~GpuTask() {} 1180 InProcessCommandBuffer::GpuTask::~GpuTask() {}
1209 1181
1210 } // namespace gpu 1182 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/ipc/client/gpu_channel_host.cc ('k') | ui/gfx/gpu_memory_buffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698