OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ppb_image_data_impl.h" | 5 #include "content/renderer/pepper/ppb_image_data_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 width_ = width; | 140 width_ = width; |
141 height_ = height; | 141 height_ = height; |
142 uint32_t buffer_size = width_ * height_ * 4; | 142 uint32_t buffer_size = width_ * height_ * 4; |
143 std::unique_ptr<base::SharedMemory> shared_memory = | 143 std::unique_ptr<base::SharedMemory> shared_memory = |
144 RenderThread::Get()->HostAllocateSharedMemoryBuffer(buffer_size); | 144 RenderThread::Get()->HostAllocateSharedMemoryBuffer(buffer_size); |
145 if (!shared_memory) | 145 if (!shared_memory) |
146 return false; | 146 return false; |
147 | 147 |
148 // The TransportDIB is always backed by shared memory, so give the shared | 148 // The TransportDIB is always backed by shared memory, so give the shared |
149 // memory handle to it. | 149 // memory handle to it. |
150 base::SharedMemoryHandle handle; | 150 base::SharedMemoryHandle handle = shared_memory->handle().Duplicate(); |
151 if (!shared_memory->GiveToProcess(base::GetCurrentProcessHandle(), &handle)) | 151 shared_memory->Unmap(); |
| 152 shared_memory->Close(); |
| 153 if (!handle.IsValid()) |
152 return false; | 154 return false; |
153 | 155 |
154 dib_.reset(TransportDIB::CreateWithHandle(handle)); | 156 dib_.reset(TransportDIB::CreateWithHandle(handle)); |
155 | 157 |
156 return !!dib_; | 158 return !!dib_; |
157 } | 159 } |
158 | 160 |
159 bool ImageDataPlatformBackend::IsMapped() const { | 161 bool ImageDataPlatformBackend::IsMapped() const { |
160 return !!mapped_canvas_.get(); | 162 return !!mapped_canvas_.get(); |
161 } | 163 } |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 return skia_canvas_.get(); | 267 return skia_canvas_.get(); |
266 } | 268 } |
267 | 269 |
268 SkBitmap ImageDataSimpleBackend::GetMappedBitmap() const { | 270 SkBitmap ImageDataSimpleBackend::GetMappedBitmap() const { |
269 if (!IsMapped()) | 271 if (!IsMapped()) |
270 return SkBitmap(); | 272 return SkBitmap(); |
271 return skia_bitmap_; | 273 return skia_bitmap_; |
272 } | 274 } |
273 | 275 |
274 } // namespace content | 276 } // namespace content |
OLD | NEW |