Copy webkit's test_expectations* files over to content.
[chromium-blink-merge.git] / cc / blink / web_external_bitmap_impl.cc
bloba101079019080baf1697b451b31ac8c6d161237d
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
3 // found in the LICENSE file.
5 #include "cc/blink/web_external_bitmap_impl.h"
7 #include "base/memory/shared_memory.h"
9 namespace cc_blink {
11 namespace {
13 SharedMemoryAllocationFunction g_memory_allocator;
15 } // namespace
17 void SetSharedMemoryAllocationFunction(
18 SharedMemoryAllocationFunction allocator) {
19 g_memory_allocator = allocator;
22 WebExternalBitmapImpl::WebExternalBitmapImpl() {
25 WebExternalBitmapImpl::~WebExternalBitmapImpl() {
28 void WebExternalBitmapImpl::setSize(blink::WebSize size) {
29 if (size != size_) {
30 size_t byte_size = size.width * size.height * 4;
31 shared_memory_ = g_memory_allocator(byte_size);
32 if (shared_memory_)
33 shared_memory_->Map(byte_size);
34 size_ = size;
38 blink::WebSize WebExternalBitmapImpl::size() {
39 return size_;
42 uint8* WebExternalBitmapImpl::pixels() {
43 return static_cast<uint8*>(shared_memory_->memory());
46 } // namespace cc_blink