OLD | NEW |
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 "third_party/khronos/GLES2/gl2.h" | 8 #include "third_party/khronos/GLES2/gl2.h" |
9 | 9 |
10 namespace cc { | 10 namespace cc { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 base::SharedMemory* shared_memory, | 69 base::SharedMemory* shared_memory, |
70 gfx::Size size, | 70 gfx::Size size, |
71 const ReleaseCallback& callback) | 71 const ReleaseCallback& callback) |
72 : callback_(callback), | 72 : callback_(callback), |
73 target_(GL_TEXTURE_2D), | 73 target_(GL_TEXTURE_2D), |
74 sync_point_(0), | 74 sync_point_(0), |
75 shared_memory_(shared_memory), | 75 shared_memory_(shared_memory), |
76 shared_memory_size_(size) { | 76 shared_memory_size_(size) { |
77 } | 77 } |
78 | 78 |
| 79 TextureMailbox::TextureMailbox( |
| 80 SkBitmap bitmap, |
| 81 gfx::Size size, |
| 82 const ReleaseCallback& callback) |
| 83 : callback_(callback), |
| 84 target_(GL_TEXTURE_2D), |
| 85 sync_point_(0), |
| 86 bitmap_(bitmap), |
| 87 shared_memory_size_(size) { |
| 88 } |
| 89 |
79 TextureMailbox::~TextureMailbox() { | 90 TextureMailbox::~TextureMailbox() { |
80 } | 91 } |
81 | 92 |
82 bool TextureMailbox::Equals(const TextureMailbox& other) const { | 93 bool TextureMailbox::Equals(const TextureMailbox& other) const { |
83 if (other.IsTexture()) | 94 if (other.IsTexture()) |
84 return ContainsMailbox(other.name()); | 95 return ContainsMailbox(other.name()); |
85 else if (other.IsSharedMemory()) | 96 else if (other.IsSharedMemory()) |
86 return ContainsHandle(other.shared_memory_->handle()); | 97 return ContainsHandle(other.shared_memory_->handle()); |
| 98 else if (other.IsBitmap()) |
| 99 return other.bitmap_.getPixels() == bitmap_.getPixels(); |
87 | 100 |
88 DCHECK(!other.IsValid()); | 101 DCHECK(!other.IsValid()); |
89 return !IsValid(); | 102 return !IsValid(); |
90 } | 103 } |
91 | 104 |
92 bool TextureMailbox::ContainsMailbox(const gpu::Mailbox& other) const { | 105 bool TextureMailbox::ContainsMailbox(const gpu::Mailbox& other) const { |
93 return IsTexture() && !memcmp(data(), other.name, sizeof(name_.name)); | 106 return IsTexture() && !memcmp(data(), other.name, sizeof(name_.name)); |
94 } | 107 } |
95 | 108 |
96 bool TextureMailbox::ContainsHandle(base::SharedMemoryHandle handle) const { | 109 bool TextureMailbox::ContainsHandle(base::SharedMemoryHandle handle) const { |
(...skipping 16 matching lines...) Expand all Loading... |
113 TextureMailbox result(*this); | 126 TextureMailbox result(*this); |
114 result.callback_ = callback; | 127 result.callback_ = callback; |
115 return result; | 128 return result; |
116 } | 129 } |
117 | 130 |
118 size_t TextureMailbox::shared_memory_size_in_bytes() const { | 131 size_t TextureMailbox::shared_memory_size_in_bytes() const { |
119 return 4 * shared_memory_size_.GetArea(); | 132 return 4 * shared_memory_size_.GetArea(); |
120 } | 133 } |
121 | 134 |
122 } // namespace cc | 135 } // namespace cc |
OLD | NEW |