OLD | NEW |
---|---|
1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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/output/gl_renderer.h" | 5 #include "cc/output/gl_renderer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 2347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2358 gfx::Rect window_rect = MoveFromDrawToWindowSpace(rect); | 2358 gfx::Rect window_rect = MoveFromDrawToWindowSpace(rect); |
2359 DCHECK_GE(window_rect.x(), 0); | 2359 DCHECK_GE(window_rect.x(), 0); |
2360 DCHECK_GE(window_rect.y(), 0); | 2360 DCHECK_GE(window_rect.y(), 0); |
2361 DCHECK_LE(window_rect.right(), current_surface_size_.width()); | 2361 DCHECK_LE(window_rect.right(), current_surface_size_.width()); |
2362 DCHECK_LE(window_rect.bottom(), current_surface_size_.height()); | 2362 DCHECK_LE(window_rect.bottom(), current_surface_size_.height()); |
2363 | 2363 |
2364 if (!request->force_bitmap_result()) { | 2364 if (!request->force_bitmap_result()) { |
2365 bool own_mailbox = !request->has_texture_mailbox(); | 2365 bool own_mailbox = !request->has_texture_mailbox(); |
2366 | 2366 |
2367 GLuint texture_id = 0; | 2367 GLuint texture_id = 0; |
2368 gl_->GenTextures(1, &texture_id); | |
2369 | |
2370 gpu::Mailbox mailbox; | 2368 gpu::Mailbox mailbox; |
2371 if (own_mailbox) { | 2369 if (own_mailbox) { |
2372 GLC(gl_, gl_->GenMailboxCHROMIUM(mailbox.name)); | 2370 GLC(gl_, gl_->GenMailboxCHROMIUM(mailbox.name)); |
2373 } else { | 2371 gl_->GenTextures(1, &texture_id); |
2374 mailbox = request->texture_mailbox().mailbox(); | 2372 GLC(gl_, gl_->BindTexture(GL_TEXTURE_2D, texture_id)); |
2375 DCHECK_EQ(static_cast<unsigned>(GL_TEXTURE_2D), | |
2376 request->texture_mailbox().target()); | |
2377 DCHECK(!mailbox.IsZero()); | |
2378 unsigned incoming_sync_point = request->texture_mailbox().sync_point(); | |
2379 if (incoming_sync_point) | |
2380 GLC(gl_, gl_->WaitSyncPointCHROMIUM(incoming_sync_point)); | |
2381 } | |
2382 | 2373 |
2383 GLC(gl_, gl_->BindTexture(GL_TEXTURE_2D, texture_id)); | |
2384 if (own_mailbox) { | |
2385 GLC(gl_, | 2374 GLC(gl_, |
2386 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); | 2375 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); |
2387 GLC(gl_, | 2376 GLC(gl_, |
2388 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); | 2377 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); |
2389 GLC(gl_, | 2378 GLC(gl_, |
2390 gl_->TexParameteri( | 2379 gl_->TexParameteri( |
2391 GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); | 2380 GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); |
2392 GLC(gl_, | 2381 GLC(gl_, |
2393 gl_->TexParameteri( | 2382 gl_->TexParameteri( |
2394 GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)); | 2383 GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)); |
2395 GLC(gl_, gl_->ProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name)); | 2384 GLC(gl_, gl_->ProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name)); |
2396 } else { | 2385 } else { |
2397 GLC(gl_, gl_->ConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name)); | 2386 mailbox = request->texture_mailbox().mailbox(); |
2387 DCHECK_EQ(static_cast<unsigned>(GL_TEXTURE_2D), | |
2388 request->texture_mailbox().target()); | |
2389 DCHECK(!mailbox.IsZero()); | |
2390 unsigned incoming_sync_point = request->texture_mailbox().sync_point(); | |
2391 if (incoming_sync_point) | |
2392 GLC(gl_, gl_->WaitSyncPointCHROMIUM(incoming_sync_point)); | |
2393 | |
2394 texture_id = GLC( | |
2395 gl_, | |
2396 gl_->CreateAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name)); | |
2398 } | 2397 } |
2399 GetFramebufferTexture(texture_id, RGBA_8888, window_rect); | 2398 GetFramebufferTexture(texture_id, RGBA_8888, window_rect); |
2400 GLC(gl_, gl_->BindTexture(GL_TEXTURE_2D, 0)); | |
2401 | 2399 |
2402 unsigned sync_point = gl_->InsertSyncPointCHROMIUM(); | 2400 unsigned sync_point = gl_->InsertSyncPointCHROMIUM(); |
2403 TextureMailbox texture_mailbox(mailbox, GL_TEXTURE_2D, sync_point); | 2401 TextureMailbox texture_mailbox(mailbox, GL_TEXTURE_2D, sync_point); |
2404 | 2402 |
2405 scoped_ptr<SingleReleaseCallback> release_callback; | 2403 scoped_ptr<SingleReleaseCallback> release_callback; |
2406 if (own_mailbox) { | 2404 if (own_mailbox) { |
2405 GLC(gl_, gl_->BindTexture(GL_TEXTURE_2D, 0)); | |
danakj
2014/07/08 15:51:30
FWIW GetFramebufferTexture already binds/unbinds,
dshwang
2014/07/08 16:36:16
GetFramebufferTexture actually call BindTexture(GL
danakj
2014/07/08 16:40:25
I like having something here to show it's unbound
| |
2407 release_callback = texture_mailbox_deleter_->GetReleaseCallback( | 2406 release_callback = texture_mailbox_deleter_->GetReleaseCallback( |
2408 output_surface_->context_provider(), texture_id); | 2407 output_surface_->context_provider(), texture_id); |
2409 } else { | 2408 } else { |
2410 gl_->DeleteTextures(1, &texture_id); | 2409 gl_->DeleteTextures(1, &texture_id); |
2411 } | 2410 } |
2412 | 2411 |
2413 request->SendTextureResult( | 2412 request->SendTextureResult( |
2414 window_rect.size(), texture_mailbox, release_callback.Pass()); | 2413 window_rect.size(), texture_mailbox, release_callback.Pass()); |
2415 return; | 2414 return; |
2416 } | 2415 } |
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3165 context_support_->ScheduleOverlayPlane( | 3164 context_support_->ScheduleOverlayPlane( |
3166 overlay.plane_z_order, | 3165 overlay.plane_z_order, |
3167 overlay.transform, | 3166 overlay.transform, |
3168 pending_overlay_resources_.back()->texture_id(), | 3167 pending_overlay_resources_.back()->texture_id(), |
3169 overlay.display_rect, | 3168 overlay.display_rect, |
3170 overlay.uv_rect); | 3169 overlay.uv_rect); |
3171 } | 3170 } |
3172 } | 3171 } |
3173 | 3172 |
3174 } // namespace cc | 3173 } // namespace cc |
OLD | NEW |