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

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

Issue 15001027: [Aura] Added Support for rendering software compositor frames as cc::TextureLayers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Passed(&foo) instead for Passed(foo.Pass()). Created 7 years, 6 months 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 | Annotate | Revision Log
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 "third_party/khronos/GLES2/gl2.h" 8 #include "third_party/khronos/GLES2/gl2.h"
9 9
10 namespace cc { 10 namespace cc {
11 11
12 TextureMailbox::TextureMailbox() 12 TextureMailbox::TextureMailbox()
13 : target_(GL_TEXTURE_2D), 13 : target_(GL_TEXTURE_2D),
14 sync_point_(0) { 14 sync_point_(0),
15 shared_memory_(NULL) {
15 } 16 }
16 17
17 TextureMailbox::TextureMailbox( 18 TextureMailbox::TextureMailbox(
18 const std::string& mailbox_name, 19 const std::string& mailbox_name,
19 const ReleaseCallback& mailbox_callback) 20 const ReleaseCallback& callback)
20 : callback_(mailbox_callback), 21 : callback_(callback),
21 target_(GL_TEXTURE_2D), 22 target_(GL_TEXTURE_2D),
22 sync_point_(0) { 23 sync_point_(0),
23 DCHECK(mailbox_name.empty() == mailbox_callback.is_null()); 24 shared_memory_(NULL) {
25 DCHECK(mailbox_name.empty() == callback.is_null());
24 if (!mailbox_name.empty()) { 26 if (!mailbox_name.empty()) {
25 CHECK(mailbox_name.size() == sizeof(name_.name)); 27 CHECK(mailbox_name.size() == sizeof(name_.name));
26 name_.SetName(reinterpret_cast<const int8*>(mailbox_name.data())); 28 name_.SetName(reinterpret_cast<const int8*>(mailbox_name.data()));
27 } 29 }
28 } 30 }
29 31
30 TextureMailbox::TextureMailbox( 32 TextureMailbox::TextureMailbox(
31 const gpu::Mailbox& mailbox_name, 33 const gpu::Mailbox& mailbox_name,
32 const ReleaseCallback& mailbox_callback) 34 const ReleaseCallback& callback)
33 : callback_(mailbox_callback), 35 : callback_(callback),
34 target_(GL_TEXTURE_2D), 36 target_(GL_TEXTURE_2D),
35 sync_point_(0) { 37 sync_point_(0),
36 DCHECK(mailbox_name.IsZero() == mailbox_callback.is_null()); 38 shared_memory_(NULL) {
39 DCHECK(mailbox_name.IsZero() == callback.is_null());
37 name_.SetName(mailbox_name.name); 40 name_.SetName(mailbox_name.name);
38 } 41 }
39 42
40 TextureMailbox::TextureMailbox( 43 TextureMailbox::TextureMailbox(
41 const gpu::Mailbox& mailbox_name, 44 const gpu::Mailbox& mailbox_name,
42 const ReleaseCallback& mailbox_callback, 45 const ReleaseCallback& callback,
43 unsigned sync_point) 46 unsigned sync_point)
44 : callback_(mailbox_callback), 47 : callback_(callback),
45 target_(GL_TEXTURE_2D), 48 target_(GL_TEXTURE_2D),
46 sync_point_(sync_point) { 49 sync_point_(sync_point),
47 DCHECK(mailbox_name.IsZero() == mailbox_callback.is_null()); 50 shared_memory_(NULL) {
51 DCHECK(mailbox_name.IsZero() == callback.is_null());
48 name_.SetName(mailbox_name.name); 52 name_.SetName(mailbox_name.name);
49 } 53 }
50 54
51 TextureMailbox::TextureMailbox( 55 TextureMailbox::TextureMailbox(
52 const gpu::Mailbox& mailbox_name, 56 const gpu::Mailbox& mailbox_name,
53 const ReleaseCallback& mailbox_callback, 57 const ReleaseCallback& callback,
54 unsigned texture_target, 58 unsigned texture_target,
55 unsigned sync_point) 59 unsigned sync_point)
56 : callback_(mailbox_callback), 60 : callback_(callback),
57 target_(texture_target), 61 target_(texture_target),
58 sync_point_(sync_point) { 62 sync_point_(sync_point),
59 DCHECK(mailbox_name.IsZero() == mailbox_callback.is_null()); 63 shared_memory_(NULL) {
64 DCHECK(mailbox_name.IsZero() == callback.is_null());
60 name_.SetName(mailbox_name.name); 65 name_.SetName(mailbox_name.name);
61 } 66 }
62 67
68 TextureMailbox::TextureMailbox(
69 base::SharedMemory* shared_memory,
70 gfx::Size size,
71 const ReleaseCallback& callback)
72 : callback_(callback),
73 target_(GL_TEXTURE_2D),
74 sync_point_(0),
75 shared_memory_(shared_memory),
76 shared_memory_size_(size) {
77 }
78
63 TextureMailbox::~TextureMailbox() { 79 TextureMailbox::~TextureMailbox() {
64 } 80 }
65 81
66 bool TextureMailbox::Equals(const gpu::Mailbox& other) const { 82 bool TextureMailbox::Equals(const TextureMailbox& other) const {
67 return !memcmp(data(), other.name, sizeof(name_.name)); 83 if (other.IsTexture())
84 return ContainsMailbox(other.name());
85 else if (other.IsSharedMemory())
86 return ContainsHandle(other.shared_memory_->handle());
87
88 DCHECK(!other.IsValid());
89 return !IsValid();
68 } 90 }
69 91
70 bool TextureMailbox::Equals(const TextureMailbox& other) const { 92 bool TextureMailbox::ContainsMailbox(const gpu::Mailbox& other) const {
71 return Equals(other.name()); 93 return IsTexture() && !memcmp(data(), other.name, sizeof(name_.name));
72 } 94 }
73 95
74 bool TextureMailbox::IsEmpty() const { 96 bool TextureMailbox::ContainsHandle(base::SharedMemoryHandle handle) const {
75 return name_.IsZero(); 97 return shared_memory_ && shared_memory_->handle() == handle;
76 } 98 }
77 99
78 void TextureMailbox::RunReleaseCallback(unsigned sync_point, 100 void TextureMailbox::RunReleaseCallback(unsigned sync_point,
79 bool lost_resource) const { 101 bool lost_resource) const {
80 if (!callback_.is_null()) 102 if (!callback_.is_null())
81 callback_.Run(sync_point, lost_resource); 103 callback_.Run(sync_point, lost_resource);
82 } 104 }
83 105
84 void TextureMailbox::SetName(const gpu::Mailbox& other) { 106 void TextureMailbox::SetName(const gpu::Mailbox& other) {
107 DCHECK(shared_memory_ == NULL);
85 name_.SetName(other.name); 108 name_.SetName(other.name);
86 } 109 }
87 110
111 TextureMailbox TextureMailbox::CopyWithNewCallback(
112 const ReleaseCallback& callback) const {
113 TextureMailbox result(*this);
114 result.callback_ = callback;
115 return result;
116 }
117
118 size_t TextureMailbox::shared_memory_size_in_bytes() const {
119 return 4 * shared_memory_size_.GetArea();
120 }
121
88 } // namespace cc 122 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/texture_mailbox.h ('k') | content/browser/android/in_process/synchronous_compositor_output_surface.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698