| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #include "cc/blink/web_external_bitmap_impl.h" | |
| 6 | |
| 7 #include <stdint.h> | |
| 8 | |
| 9 #include "cc/resources/shared_bitmap.h" | |
| 10 | |
| 11 namespace cc_blink { | |
| 12 | |
| 13 namespace { | |
| 14 | |
| 15 SharedBitmapAllocationFunction g_memory_allocator; | |
| 16 | |
| 17 } // namespace | |
| 18 | |
| 19 void SetSharedBitmapAllocationFunction( | |
| 20 SharedBitmapAllocationFunction allocator) { | |
| 21 g_memory_allocator = allocator; | |
| 22 } | |
| 23 | |
| 24 WebExternalBitmapImpl::WebExternalBitmapImpl() { | |
| 25 } | |
| 26 | |
| 27 WebExternalBitmapImpl::~WebExternalBitmapImpl() { | |
| 28 } | |
| 29 | |
| 30 void WebExternalBitmapImpl::setSize(blink::WebSize size) { | |
| 31 if (size != size_) { | |
| 32 shared_bitmap_ = g_memory_allocator(gfx::Size(size)); | |
| 33 size_ = size; | |
| 34 } | |
| 35 } | |
| 36 | |
| 37 blink::WebSize WebExternalBitmapImpl::size() { | |
| 38 return size_; | |
| 39 } | |
| 40 | |
| 41 uint8_t* WebExternalBitmapImpl::pixels() { | |
| 42 if (!shared_bitmap_) { | |
| 43 // crbug.com/520417: not sure why a non-null WebExternalBitmap is | |
| 44 // being passed to prepareMailbox when the shared_bitmap_ is null. | |
| 45 // Best hypothesis is that the bitmap is zero-sized. | |
| 46 DCHECK(size_.isEmpty()); | |
| 47 return nullptr; | |
| 48 } | |
| 49 return shared_bitmap_->pixels(); | |
| 50 } | |
| 51 | |
| 52 } // namespace cc_blink | |
| OLD | NEW |