Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(413)

Side by Side Diff: cc/resources/texture_mailbox.cc

Issue 812543002: Update from https://crrev.com/308331 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/resources/texture_mailbox.h ('k') | cc/resources/tile_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "cc/resources/texture_mailbox.h" 5 #include "cc/resources/texture_mailbox.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "cc/resources/shared_bitmap.h" 8 #include "cc/resources/shared_bitmap.h"
9 9
10 namespace cc { 10 namespace cc {
11 11
12 TextureMailbox::TextureMailbox() : shared_memory_(NULL) {} 12 TextureMailbox::TextureMailbox() : shared_bitmap_(NULL) {
13 }
13 14
14 TextureMailbox::TextureMailbox(const gpu::MailboxHolder& mailbox_holder) 15 TextureMailbox::TextureMailbox(const gpu::MailboxHolder& mailbox_holder)
15 : mailbox_holder_(mailbox_holder), 16 : mailbox_holder_(mailbox_holder),
16 shared_memory_(NULL), 17 shared_bitmap_(NULL),
17 allow_overlay_(false), 18 allow_overlay_(false),
18 nearest_neighbor_(false) {} 19 nearest_neighbor_(false) {
20 }
19 21
20 TextureMailbox::TextureMailbox(const gpu::Mailbox& mailbox, 22 TextureMailbox::TextureMailbox(const gpu::Mailbox& mailbox,
21 uint32 target, 23 uint32 target,
22 uint32 sync_point) 24 uint32 sync_point)
23 : mailbox_holder_(mailbox, target, sync_point), 25 : mailbox_holder_(mailbox, target, sync_point),
24 shared_memory_(NULL), 26 shared_bitmap_(NULL),
25 allow_overlay_(false), 27 allow_overlay_(false),
26 nearest_neighbor_(false) {} 28 nearest_neighbor_(false) {
29 }
27 30
28 TextureMailbox::TextureMailbox(base::SharedMemory* shared_memory, 31 TextureMailbox::TextureMailbox(SharedBitmap* shared_bitmap,
29 const gfx::Size& size) 32 const gfx::Size& size)
30 : shared_memory_(shared_memory), 33 : shared_bitmap_(shared_bitmap),
31 shared_memory_size_(size), 34 shared_memory_size_(size),
32 allow_overlay_(false), 35 allow_overlay_(false),
33 nearest_neighbor_(false) { 36 nearest_neighbor_(false) {
34 // If an embedder of cc gives an invalid TextureMailbox, we should crash 37 // If an embedder of cc gives an invalid TextureMailbox, we should crash
35 // here to identify the offender. 38 // here to identify the offender.
36 CHECK(SharedBitmap::VerifySizeInBytes(shared_memory_size_)); 39 CHECK(SharedBitmap::VerifySizeInBytes(shared_memory_size_));
37 } 40 }
38 41
39 TextureMailbox::~TextureMailbox() {} 42 TextureMailbox::~TextureMailbox() {}
40 43
41 bool TextureMailbox::Equals(const TextureMailbox& other) const { 44 bool TextureMailbox::Equals(const TextureMailbox& other) const {
42 if (other.IsTexture()) { 45 if (other.IsTexture()) {
43 return IsTexture() && !memcmp(mailbox_holder_.mailbox.name, 46 return IsTexture() && !memcmp(mailbox_holder_.mailbox.name,
44 other.mailbox_holder_.mailbox.name, 47 other.mailbox_holder_.mailbox.name,
45 sizeof(mailbox_holder_.mailbox.name)); 48 sizeof(mailbox_holder_.mailbox.name));
46 } else if (other.IsSharedMemory()) { 49 } else if (other.IsSharedMemory()) {
47 return IsSharedMemory() && 50 return IsSharedMemory() && (shared_bitmap_ == other.shared_bitmap_);
48 shared_memory_->handle() == other.shared_memory_->handle();
49 } 51 }
50 52
51 DCHECK(!other.IsValid()); 53 DCHECK(!other.IsValid());
52 return !IsValid(); 54 return !IsValid();
53 } 55 }
54 56
55 size_t TextureMailbox::SharedMemorySizeInBytes() const { 57 size_t TextureMailbox::SharedMemorySizeInBytes() const {
56 // UncheckedSizeInBytes is okay because we VerifySizeInBytes in the 58 // UncheckedSizeInBytes is okay because we VerifySizeInBytes in the
57 // constructor and the field is immutable. 59 // constructor and the field is immutable.
58 return SharedBitmap::UncheckedSizeInBytes(shared_memory_size_); 60 return SharedBitmap::UncheckedSizeInBytes(shared_memory_size_);
59 } 61 }
60 62
61 } // namespace cc 63 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/texture_mailbox.h ('k') | cc/resources/tile_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698