OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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/blink/web_external_texture_layer_impl.h" | 5 #include "cc/blink/web_external_texture_layer_impl.h" |
6 | 6 |
7 #include "cc/blink/web_external_bitmap_impl.h" | 7 #include "cc/blink/web_external_bitmap_impl.h" |
8 #include "cc/blink/web_layer_impl.h" | 8 #include "cc/blink/web_layer_impl.h" |
9 #include "cc/layers/texture_layer.h" | 9 #include "cc/layers/texture_layer.h" |
10 #include "cc/resources/single_release_callback.h" | 10 #include "cc/resources/single_release_callback.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 if (!client_->prepareMailbox(&client_mailbox, bitmap)) { | 74 if (!client_->prepareMailbox(&client_mailbox, bitmap)) { |
75 if (bitmap) | 75 if (bitmap) |
76 free_bitmaps_.push_back(bitmap); | 76 free_bitmaps_.push_back(bitmap); |
77 return false; | 77 return false; |
78 } | 78 } |
79 gpu::Mailbox name; | 79 gpu::Mailbox name; |
80 name.SetName(client_mailbox.name); | 80 name.SetName(client_mailbox.name); |
81 if (bitmap) { | 81 if (bitmap) { |
82 *mailbox = cc::TextureMailbox(bitmap->shared_bitmap(), bitmap->size()); | 82 *mailbox = cc::TextureMailbox(bitmap->shared_bitmap(), bitmap->size()); |
83 } else { | 83 } else { |
| 84 gpu::SyncToken sync_token; |
| 85 static_assert(sizeof(sync_token) <= sizeof(client_mailbox.syncToken), |
| 86 "Size of web external sync token too small."); |
| 87 if (client_mailbox.validSyncToken) |
| 88 memcpy(&sync_token, client_mailbox.syncToken, sizeof(sync_token)); |
| 89 |
84 // TODO(achaulk): pass a valid size here if allowOverlay is set. | 90 // TODO(achaulk): pass a valid size here if allowOverlay is set. |
85 *mailbox = cc::TextureMailbox(name, GL_TEXTURE_2D, client_mailbox.syncPoint, | 91 *mailbox = cc::TextureMailbox(name, GL_TEXTURE_2D, client_mailbox.syncPoint, |
86 gfx::Size(), client_mailbox.allowOverlay); | 92 sync_token, gfx::Size(), |
| 93 client_mailbox.allowOverlay); |
87 } | 94 } |
88 mailbox->set_nearest_neighbor(client_mailbox.nearestNeighbor); | 95 mailbox->set_nearest_neighbor(client_mailbox.nearestNeighbor); |
89 | 96 |
90 if (mailbox->IsValid()) { | 97 if (mailbox->IsValid()) { |
91 *release_callback = cc::SingleReleaseCallback::Create( | 98 *release_callback = cc::SingleReleaseCallback::Create( |
92 base::Bind(&WebExternalTextureLayerImpl::DidReleaseMailbox, | 99 base::Bind(&WebExternalTextureLayerImpl::DidReleaseMailbox, |
93 this->AsWeakPtr(), | 100 this->AsWeakPtr(), |
94 client_mailbox, | 101 client_mailbox, |
95 bitmap)); | 102 bitmap)); |
96 } | 103 } |
97 | 104 |
98 return true; | 105 return true; |
99 } | 106 } |
100 | 107 |
101 WebExternalBitmapImpl* WebExternalTextureLayerImpl::AllocateBitmap() { | 108 WebExternalBitmapImpl* WebExternalTextureLayerImpl::AllocateBitmap() { |
102 if (!free_bitmaps_.empty()) { | 109 if (!free_bitmaps_.empty()) { |
103 WebExternalBitmapImpl* result = free_bitmaps_.back(); | 110 WebExternalBitmapImpl* result = free_bitmaps_.back(); |
104 free_bitmaps_.weak_erase(free_bitmaps_.end() - 1); | 111 free_bitmaps_.weak_erase(free_bitmaps_.end() - 1); |
105 return result; | 112 return result; |
106 } | 113 } |
107 return new WebExternalBitmapImpl; | 114 return new WebExternalBitmapImpl; |
108 } | 115 } |
109 | 116 |
110 // static | 117 // static |
111 void WebExternalTextureLayerImpl::DidReleaseMailbox( | 118 void WebExternalTextureLayerImpl::DidReleaseMailbox( |
112 base::WeakPtr<WebExternalTextureLayerImpl> layer, | 119 base::WeakPtr<WebExternalTextureLayerImpl> layer, |
113 const blink::WebExternalTextureMailbox& mailbox, | 120 const blink::WebExternalTextureMailbox& mailbox, |
114 WebExternalBitmapImpl* bitmap, | 121 WebExternalBitmapImpl* bitmap, |
115 unsigned sync_point, | 122 unsigned sync_point, |
| 123 const gpu::SyncToken& sync_token, |
116 bool lost_resource) { | 124 bool lost_resource) { |
117 DCHECK(layer); | 125 DCHECK(layer); |
118 blink::WebExternalTextureMailbox available_mailbox; | 126 blink::WebExternalTextureMailbox available_mailbox; |
| 127 static_assert(sizeof(sync_token) <= sizeof(available_mailbox.syncToken), |
| 128 "Size of web external sync token too small."); |
119 memcpy(available_mailbox.name, mailbox.name, sizeof(available_mailbox.name)); | 129 memcpy(available_mailbox.name, mailbox.name, sizeof(available_mailbox.name)); |
120 available_mailbox.syncPoint = sync_point; | 130 available_mailbox.syncPoint = sync_point; |
| 131 memcpy(available_mailbox.syncToken, sync_token.GetConstData(), |
| 132 sizeof(sync_token)); |
| 133 available_mailbox.validSyncToken = sync_token.HasData(); |
121 if (bitmap) | 134 if (bitmap) |
122 layer->free_bitmaps_.push_back(bitmap); | 135 layer->free_bitmaps_.push_back(bitmap); |
123 layer->client_->mailboxReleased(available_mailbox, lost_resource); | 136 layer->client_->mailboxReleased(available_mailbox, lost_resource); |
124 } | 137 } |
125 | 138 |
126 } // namespace cc_blink | 139 } // namespace cc_blink |
OLD | NEW |