OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/renderer/gpu/mailbox_output_surface.h" | 5 #include "content/renderer/gpu/mailbox_output_surface.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "cc/output/compositor_frame.h" | 8 #include "cc/output/compositor_frame.h" |
9 #include "cc/output/compositor_frame_ack.h" | 9 #include "cc/output/compositor_frame_ack.h" |
10 #include "cc/output/gl_frame_data.h" | 10 #include "cc/output/gl_frame_data.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 is_backbuffer_discarded_ = false; | 61 is_backbuffer_discarded_ = false; |
62 | 62 |
63 GLES2Interface* gl = context_provider_->ContextGL(); | 63 GLES2Interface* gl = context_provider_->ContextGL(); |
64 | 64 |
65 if (!current_backing_.texture_id) { | 65 if (!current_backing_.texture_id) { |
66 // Find a texture of matching size to recycle. | 66 // Find a texture of matching size to recycle. |
67 while (!returned_textures_.empty()) { | 67 while (!returned_textures_.empty()) { |
68 TransferableFrame& texture = returned_textures_.front(); | 68 TransferableFrame& texture = returned_textures_.front(); |
69 if (texture.size == surface_size_) { | 69 if (texture.size == surface_size_) { |
70 current_backing_ = texture; | 70 current_backing_ = texture; |
71 if (current_backing_.sync_point) | 71 if (current_backing_.sync_token.HasData()) |
72 gl->WaitSyncPointCHROMIUM(current_backing_.sync_point); | 72 gl->WaitSyncTokenCHROMIUM(current_backing_.sync_token.GetConstData()); |
73 returned_textures_.pop(); | 73 returned_textures_.pop(); |
74 break; | 74 break; |
75 } | 75 } |
76 | 76 |
77 gl->DeleteTextures(1, &texture.texture_id); | 77 gl->DeleteTextures(1, &texture.texture_id); |
78 returned_textures_.pop(); | 78 returned_textures_.pop(); |
79 } | 79 } |
80 | 80 |
81 if (!current_backing_.texture_id) { | 81 if (!current_backing_.texture_id) { |
82 gl->GenTextures(1, ¤t_backing_.texture_id); | 82 gl->GenTextures(1, ¤t_backing_.texture_id); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 for (it = pending_textures_.begin(); it != pending_textures_.end(); it++) { | 166 for (it = pending_textures_.begin(); it != pending_textures_.end(); it++) { |
167 DCHECK(!it->mailbox.IsZero()); | 167 DCHECK(!it->mailbox.IsZero()); |
168 if (!memcmp(it->mailbox.name, | 168 if (!memcmp(it->mailbox.name, |
169 ack.gl_frame_data->mailbox.name, | 169 ack.gl_frame_data->mailbox.name, |
170 sizeof(it->mailbox.name))) { | 170 sizeof(it->mailbox.name))) { |
171 DCHECK(it->size == ack.gl_frame_data->size); | 171 DCHECK(it->size == ack.gl_frame_data->size); |
172 break; | 172 break; |
173 } | 173 } |
174 } | 174 } |
175 DCHECK(it != pending_textures_.end()); | 175 DCHECK(it != pending_textures_.end()); |
176 it->sync_point = ack.gl_frame_data->sync_point; | 176 it->sync_token = ack.gl_frame_data->sync_token; |
177 | 177 |
178 if (!is_backbuffer_discarded_) { | 178 if (!is_backbuffer_discarded_) { |
179 returned_textures_.push(*it); | 179 returned_textures_.push(*it); |
180 } else { | 180 } else { |
181 context_provider_->ContextGL()->DeleteTextures(1, &it->texture_id); | 181 context_provider_->ContextGL()->DeleteTextures(1, &it->texture_id); |
182 } | 182 } |
183 | 183 |
184 pending_textures_.erase(it); | 184 pending_textures_.erase(it); |
185 } else { | 185 } else { |
186 DCHECK(!pending_textures_.empty()); | 186 DCHECK(!pending_textures_.empty()); |
(...skipping 12 matching lines...) Expand all Loading... |
199 DCHECK(frame->gl_frame_data); | 199 DCHECK(frame->gl_frame_data); |
200 DCHECK(!surface_size_.IsEmpty()); | 200 DCHECK(!surface_size_.IsEmpty()); |
201 DCHECK(surface_size_ == current_backing_.size); | 201 DCHECK(surface_size_ == current_backing_.size); |
202 DCHECK(frame->gl_frame_data->size == current_backing_.size); | 202 DCHECK(frame->gl_frame_data->size == current_backing_.size); |
203 DCHECK(!current_backing_.mailbox.IsZero() || | 203 DCHECK(!current_backing_.mailbox.IsZero() || |
204 context_provider_->ContextGL()->GetGraphicsResetStatusKHR() != | 204 context_provider_->ContextGL()->GetGraphicsResetStatusKHR() != |
205 GL_NO_ERROR); | 205 GL_NO_ERROR); |
206 | 206 |
207 frame->gl_frame_data->mailbox = current_backing_.mailbox; | 207 frame->gl_frame_data->mailbox = current_backing_.mailbox; |
208 context_provider_->ContextGL()->Flush(); | 208 context_provider_->ContextGL()->Flush(); |
209 frame->gl_frame_data->sync_point = | 209 frame->gl_frame_data->sync_token = |
210 context_provider_->ContextGL()->InsertSyncPointCHROMIUM(); | 210 gpu::SyncToken(context_provider_->ContextGL()->InsertSyncPointCHROMIUM()); |
211 CompositorOutputSurface::SwapBuffers(frame); | 211 CompositorOutputSurface::SwapBuffers(frame); |
212 | 212 |
213 pending_textures_.push_back(current_backing_); | 213 pending_textures_.push_back(current_backing_); |
214 current_backing_ = TransferableFrame(); | 214 current_backing_ = TransferableFrame(); |
215 } | 215 } |
216 | 216 |
217 size_t MailboxOutputSurface::GetNumAcksPending() { | 217 size_t MailboxOutputSurface::GetNumAcksPending() { |
218 DCHECK(pending_textures_.size()); | 218 DCHECK(pending_textures_.size()); |
219 return pending_textures_.size() - 1; | 219 return pending_textures_.size() - 1; |
220 } | 220 } |
221 | 221 |
| 222 MailboxOutputSurface::TransferableFrame::TransferableFrame() : texture_id(0) {} |
| 223 |
| 224 MailboxOutputSurface::TransferableFrame::TransferableFrame( |
| 225 uint32 texture_id, |
| 226 const gpu::Mailbox& mailbox, |
| 227 const gfx::Size size) |
| 228 : texture_id(texture_id), mailbox(mailbox), size(size) {} |
| 229 |
222 } // namespace content | 230 } // namespace content |
OLD | NEW |