OLD | NEW |
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 "webkit/renderer/compositor_bindings/web_external_bitmap_impl.h" | 5 #include "content/renderer/compositor_bindings/web_external_bitmap_impl.h" |
6 | 6 |
7 #include "base/memory/shared_memory.h" | 7 #include "base/memory/shared_memory.h" |
8 | 8 |
9 namespace webkit { | 9 namespace content { |
10 | 10 |
11 namespace { | 11 namespace { |
12 | 12 |
13 SharedMemoryAllocationFunction g_memory_allocator; | 13 SharedMemoryAllocationFunction g_memory_allocator; |
14 | 14 |
15 } // namespace | 15 } // namespace |
16 | 16 |
17 void SetSharedMemoryAllocationFunction( | 17 void SetSharedMemoryAllocationFunction( |
18 SharedMemoryAllocationFunction allocator) { | 18 SharedMemoryAllocationFunction allocator) { |
19 g_memory_allocator = allocator; | 19 g_memory_allocator = allocator; |
20 } | 20 } |
21 | 21 |
22 WebExternalBitmapImpl::WebExternalBitmapImpl() {} | 22 WebExternalBitmapImpl::WebExternalBitmapImpl() { |
| 23 } |
23 | 24 |
24 WebExternalBitmapImpl::~WebExternalBitmapImpl() {} | 25 WebExternalBitmapImpl::~WebExternalBitmapImpl() { |
| 26 } |
25 | 27 |
26 void WebExternalBitmapImpl::setSize(blink::WebSize size) { | 28 void WebExternalBitmapImpl::setSize(blink::WebSize size) { |
27 if (size != size_) { | 29 if (size != size_) { |
28 size_t byte_size = size.width * size.height * 4; | 30 size_t byte_size = size.width * size.height * 4; |
29 shared_memory_ = g_memory_allocator(byte_size); | 31 shared_memory_ = g_memory_allocator(byte_size); |
30 if (shared_memory_) | 32 if (shared_memory_) |
31 shared_memory_->Map(byte_size); | 33 shared_memory_->Map(byte_size); |
32 size_ = size; | 34 size_ = size; |
33 } | 35 } |
34 } | 36 } |
35 | 37 |
36 blink::WebSize WebExternalBitmapImpl::size() { | 38 blink::WebSize WebExternalBitmapImpl::size() { |
37 return size_; | 39 return size_; |
38 } | 40 } |
39 | 41 |
40 uint8* WebExternalBitmapImpl::pixels() { | 42 uint8* WebExternalBitmapImpl::pixels() { |
41 return static_cast<uint8*>(shared_memory_->memory()); | 43 return static_cast<uint8*>(shared_memory_->memory()); |
42 } | 44 } |
43 | 45 |
44 } // namespace webkit | 46 } // namespace content |
OLD | NEW |