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

Side by Side Diff: content/renderer/pepper/pepper_compositor_host.cc

Issue 1145893009: Change transport dib API to not make copies of SharedMemoryHandle. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@shared_memory_pepper_rename
Patch Set: Comments from jbauman. 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 unified diff | Download patch
« no previous file with comments | « no previous file | content/renderer/pepper/pepper_video_source_host.cc » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/renderer/pepper/pepper_compositor_host.h" 5 #include "content/renderer/pepper/pepper_compositor_host.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/shared_memory.h" 10 #include "base/memory/shared_memory.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 return PP_ERROR_BADARGUMENT; 109 return PP_ERROR_BADARGUMENT;
110 } 110 }
111 111
112 // Make sure the source rect is not beyond the dimensions of the 112 // Make sure the source rect is not beyond the dimensions of the
113 // image. 113 // image.
114 if (!CheckPPFloatRect(new_layer->image->source_rect, 114 if (!CheckPPFloatRect(new_layer->image->source_rect,
115 desc.size.width, desc.size.height)) { 115 desc.size.width, desc.size.height)) {
116 return PP_ERROR_BADARGUMENT; 116 return PP_ERROR_BADARGUMENT;
117 } 117 }
118 118
119 base::SharedMemoryHandle handle; 119 base::SharedMemory* shm;
120 uint32_t byte_count; 120 uint32_t byte_count;
121 if (enter.object()->GetSharedMemory(&handle, &byte_count) != PP_OK) 121 if (enter.object()->GetSharedMemory(&shm, &byte_count) != PP_OK)
122 return PP_ERROR_FAILED; 122 return PP_ERROR_FAILED;
123 123
124 #if defined(OS_WIN) 124 #if defined(OS_WIN)
125 base::SharedMemoryHandle shm_handle; 125 base::SharedMemoryHandle shm_handle;
126 if (!::DuplicateHandle(::GetCurrentProcess(), handle, ::GetCurrentProcess(), 126 if (!::DuplicateHandle(::GetCurrentProcess(), shm->handle(),
127 &shm_handle, 0, FALSE, DUPLICATE_SAME_ACCESS)) { 127 ::GetCurrentProcess(), &shm_handle, 0, FALSE,
128 DUPLICATE_SAME_ACCESS)) {
128 return PP_ERROR_FAILED; 129 return PP_ERROR_FAILED;
129 } 130 }
130 #else 131 #else
131 base::SharedMemoryHandle shm_handle = 132 base::SharedMemoryHandle shm_handle =
132 base::SharedMemory::DeepCopyHandle(handle, false); 133 base::SharedMemory::DeepCopyHandle(shm->handle(), false);
133 #endif 134 #endif
134 image_shm->reset(new base::SharedMemory(shm_handle, true)); 135 image_shm->reset(new base::SharedMemory(shm_handle, true));
135 if (!(*image_shm)->Map(desc.stride * desc.size.height)) { 136 if (!(*image_shm)->Map(desc.stride * desc.size.height)) {
136 image_shm->reset(); 137 image_shm->reset();
137 return PP_ERROR_NOMEMORY; 138 return PP_ERROR_NOMEMORY;
138 } 139 }
139 return PP_OK; 140 return PP_OK;
140 } 141 }
141 142
142 return PP_ERROR_BADARGUMENT; 143 return PP_ERROR_BADARGUMENT;
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 411
411 // If the host is not bound to the instance, return PP_OK immediately. 412 // If the host is not bound to the instance, return PP_OK immediately.
412 if (!bound_instance_) 413 if (!bound_instance_)
413 return PP_OK; 414 return PP_OK;
414 415
415 commit_layers_reply_context_ = context->MakeReplyMessageContext(); 416 commit_layers_reply_context_ = context->MakeReplyMessageContext();
416 return PP_OK_COMPLETIONPENDING; 417 return PP_OK_COMPLETIONPENDING;
417 } 418 }
418 419
419 } // namespace content 420 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/renderer/pepper/pepper_video_source_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698