Add ICU message format support
[chromium-blink-merge.git] / cc / resources / texture_mailbox.cc
blob7e4dd29708ccd4e61b3dafcc2306a4be1cdfccef
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
3 // found in the LICENSE file.
5 #include "cc/resources/texture_mailbox.h"
7 #include "base/logging.h"
8 #include "cc/resources/shared_bitmap.h"
10 namespace cc {
12 TextureMailbox::TextureMailbox() : shared_bitmap_(NULL) {
15 TextureMailbox::TextureMailbox(const gpu::MailboxHolder& mailbox_holder)
16 : mailbox_holder_(mailbox_holder),
17 shared_bitmap_(NULL),
18 allow_overlay_(false),
19 nearest_neighbor_(false) {
22 TextureMailbox::TextureMailbox(const gpu::Mailbox& mailbox,
23 uint32 target,
24 uint32 sync_point)
25 : mailbox_holder_(mailbox, target, sync_point),
26 shared_bitmap_(NULL),
27 allow_overlay_(false),
28 nearest_neighbor_(false) {
31 TextureMailbox::TextureMailbox(const gpu::Mailbox& mailbox,
32 uint32 target,
33 uint32 sync_point,
34 const gfx::Size& size_in_pixels,
35 bool allow_overlay)
36 : mailbox_holder_(mailbox, target, sync_point),
37 shared_bitmap_(nullptr),
38 size_in_pixels_(size_in_pixels),
39 allow_overlay_(allow_overlay),
40 nearest_neighbor_(false) {
41 DCHECK_IMPLIES(allow_overlay, !size_in_pixels.IsEmpty());
44 TextureMailbox::TextureMailbox(SharedBitmap* shared_bitmap,
45 const gfx::Size& size_in_pixels)
46 : shared_bitmap_(shared_bitmap),
47 size_in_pixels_(size_in_pixels),
48 allow_overlay_(false),
49 nearest_neighbor_(false) {
50 // If an embedder of cc gives an invalid TextureMailbox, we should crash
51 // here to identify the offender.
52 CHECK(SharedBitmap::VerifySizeInBytes(size_in_pixels_));
55 TextureMailbox::~TextureMailbox() {}
57 bool TextureMailbox::Equals(const TextureMailbox& other) const {
58 if (other.IsTexture()) {
59 return IsTexture() && !memcmp(mailbox_holder_.mailbox.name,
60 other.mailbox_holder_.mailbox.name,
61 sizeof(mailbox_holder_.mailbox.name));
62 } else if (other.IsSharedMemory()) {
63 return IsSharedMemory() && (shared_bitmap_ == other.shared_bitmap_);
66 DCHECK(!other.IsValid());
67 return !IsValid();
70 size_t TextureMailbox::SharedMemorySizeInBytes() const {
71 // UncheckedSizeInBytes is okay because we VerifySizeInBytes in the
72 // constructor and the field is immutable.
73 return SharedBitmap::UncheckedSizeInBytes(size_in_pixels_);
76 } // namespace cc