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 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "ui/surface/transport_dib.h" | 22 #include "ui/surface/transport_dib.h" |
23 | 23 |
24 using ppapi::thunk::PPB_ImageData_API; | 24 using ppapi::thunk::PPB_ImageData_API; |
25 | 25 |
26 namespace content { | 26 namespace content { |
27 | 27 |
28 namespace { | 28 namespace { |
29 // Returns true if the ImageData shared memory should be allocated in the | 29 // Returns true if the ImageData shared memory should be allocated in the |
30 // browser process for the current platform. | 30 // browser process for the current platform. |
31 bool IsBrowserAllocated() { | 31 bool IsBrowserAllocated() { |
32 #if defined(OS_POSIX) && !defined(TOOLKIT_GTK) && !defined(OS_ANDROID) | 32 #if defined(OS_POSIX) && !defined(OS_ANDROID) |
33 // On the Mac, shared memory has to be created in the browser in order to | 33 // On the Mac, shared memory has to be created in the browser in order to |
34 // work in the sandbox. | 34 // work in the sandbox. |
35 return true; | 35 return true; |
36 #endif | 36 #endif |
37 return false; | 37 return false; |
38 } | 38 } |
39 } // namespace | 39 } // namespace |
40 | 40 |
41 PPB_ImageData_Impl::PPB_ImageData_Impl(PP_Instance instance, | 41 PPB_ImageData_Impl::PPB_ImageData_Impl(PP_Instance instance, |
42 PPB_ImageData_Shared::ImageDataType type) | 42 PPB_ImageData_Shared::ImageDataType type) |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 // be around once it's mapped. Chrome's TransportDIB isn't currently | 236 // be around once it's mapped. Chrome's TransportDIB isn't currently |
237 // unmappable without freeing it, but this may be something we want to support | 237 // unmappable without freeing it, but this may be something we want to support |
238 // in the future to save some memory. | 238 // in the future to save some memory. |
239 } | 239 } |
240 | 240 |
241 int32_t ImageDataPlatformBackend::GetSharedMemory(int* handle, | 241 int32_t ImageDataPlatformBackend::GetSharedMemory(int* handle, |
242 uint32_t* byte_count) { | 242 uint32_t* byte_count) { |
243 *byte_count = dib_->size(); | 243 *byte_count = dib_->size(); |
244 #if defined(OS_WIN) | 244 #if defined(OS_WIN) |
245 *handle = reinterpret_cast<intptr_t>(dib_->handle()); | 245 *handle = reinterpret_cast<intptr_t>(dib_->handle()); |
246 #elif defined(TOOLKIT_GTK) | |
247 *handle = static_cast<intptr_t>(dib_->handle()); | |
248 #else | 246 #else |
249 *handle = static_cast<intptr_t>(dib_->handle().fd); | 247 *handle = static_cast<intptr_t>(dib_->handle().fd); |
250 #endif | 248 #endif |
251 | 249 |
252 return PP_OK; | 250 return PP_OK; |
253 } | 251 } |
254 | 252 |
255 skia::PlatformCanvas* ImageDataPlatformBackend::GetPlatformCanvas() { | 253 skia::PlatformCanvas* ImageDataPlatformBackend::GetPlatformCanvas() { |
256 return mapped_canvas_.get(); | 254 return mapped_canvas_.get(); |
257 } | 255 } |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 return skia_canvas_.get(); | 333 return skia_canvas_.get(); |
336 } | 334 } |
337 | 335 |
338 const SkBitmap* ImageDataSimpleBackend::GetMappedBitmap() const { | 336 const SkBitmap* ImageDataSimpleBackend::GetMappedBitmap() const { |
339 if (!IsMapped()) | 337 if (!IsMapped()) |
340 return NULL; | 338 return NULL; |
341 return &skia_bitmap_; | 339 return &skia_bitmap_; |
342 } | 340 } |
343 | 341 |
344 } // namespace content | 342 } // namespace content |
OLD | NEW |