Linux: Depend on liberation-fonts package for RPMs.
[chromium-blink-merge.git] / cc / blink / web_external_bitmap_impl.cc
blob2301896027b9a0b7f113f3e0a2c64b42f0f4c71b
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 "cc/resources/shared_bitmap.h"
9 namespace cc_blink {
11 namespace {
13 SharedBitmapAllocationFunction g_memory_allocator;
15 } // namespace
17 void SetSharedBitmapAllocationFunction(
18 SharedBitmapAllocationFunction allocator) {
19 g_memory_allocator = allocator;
22 WebExternalBitmapImpl::WebExternalBitmapImpl() {
25 WebExternalBitmapImpl::~WebExternalBitmapImpl() {
28 void WebExternalBitmapImpl::setSize(blink::WebSize size) {
29 if (size != size_) {
30 shared_bitmap_ = g_memory_allocator(gfx::Size(size));
31 size_ = size;
35 blink::WebSize WebExternalBitmapImpl::size() {
36 return size_;
39 uint8* WebExternalBitmapImpl::pixels() {
40 if (!shared_bitmap_) {
41 // crbug.com/520417: not sure why a non-null WebExternalBitmap is
42 // being passed to prepareMailbox when the shared_bitmap_ is null.
43 // Best hypothesis is that the bitmap is zero-sized.
44 DCHECK(size_.isEmpty());
45 return nullptr;
47 return shared_bitmap_->pixels();
50 } // namespace cc_blink