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 2348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2359 if (rect.IsEmpty()) | 2359 if (rect.IsEmpty()) |
2360 return; | 2360 return; |
2361 | 2361 |
2362 gfx::Rect window_rect = MoveFromDrawToWindowSpace(rect); | 2362 gfx::Rect window_rect = MoveFromDrawToWindowSpace(rect); |
2363 DCHECK_GE(window_rect.x(), 0); | 2363 DCHECK_GE(window_rect.x(), 0); |
2364 DCHECK_GE(window_rect.y(), 0); | 2364 DCHECK_GE(window_rect.y(), 0); |
2365 DCHECK_LE(window_rect.right(), current_surface_size_.width()); | 2365 DCHECK_LE(window_rect.right(), current_surface_size_.width()); |
2366 DCHECK_LE(window_rect.bottom(), current_surface_size_.height()); | 2366 DCHECK_LE(window_rect.bottom(), current_surface_size_.height()); |
2367 | 2367 |
2368 if (!request->force_bitmap_result()) { | 2368 if (!request->force_bitmap_result()) { |
2369 gpu::Mailbox mailbox; | |
2370 scoped_ptr<SingleReleaseCallback> release_callback; | |
2369 bool own_mailbox = !request->has_texture_mailbox(); | 2371 bool own_mailbox = !request->has_texture_mailbox(); |
2372 if (own_mailbox) { | |
2373 GLuint texture_id = 0; | |
2374 gl_->GenTextures(1, &texture_id); | |
2375 GLC(gl_, gl_->BindTexture(GL_TEXTURE_2D, texture_id)); | |
2370 | 2376 |
2371 GLuint texture_id = 0; | |
2372 gl_->GenTextures(1, &texture_id); | |
2373 | |
2374 gpu::Mailbox mailbox; | |
2375 if (own_mailbox) { | |
2376 GLC(gl_, gl_->GenMailboxCHROMIUM(mailbox.name)); | |
2377 } else { | |
2378 mailbox = request->texture_mailbox().mailbox(); | |
2379 DCHECK_EQ(static_cast<unsigned>(GL_TEXTURE_2D), | |
2380 request->texture_mailbox().target()); | |
2381 DCHECK(!mailbox.IsZero()); | |
2382 unsigned incoming_sync_point = request->texture_mailbox().sync_point(); | |
2383 if (incoming_sync_point) | |
2384 GLC(gl_, gl_->WaitSyncPointCHROMIUM(incoming_sync_point)); | |
2385 } | |
2386 | |
2387 GLC(gl_, gl_->BindTexture(GL_TEXTURE_2D, texture_id)); | |
2388 if (own_mailbox) { | |
2389 GLC(gl_, | 2377 GLC(gl_, |
2390 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); | 2378 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); |
2391 GLC(gl_, | 2379 GLC(gl_, |
2392 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); | 2380 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); |
2393 GLC(gl_, | 2381 GLC(gl_, |
2394 gl_->TexParameteri( | 2382 gl_->TexParameteri( |
2395 GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); | 2383 GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); |
2396 GLC(gl_, | 2384 GLC(gl_, |
2397 gl_->TexParameteri( | 2385 gl_->TexParameteri( |
2398 GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)); | 2386 GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)); |
2387 GLC(gl_, gl_->GenMailboxCHROMIUM(mailbox.name)); | |
2399 GLC(gl_, gl_->ProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name)); | 2388 GLC(gl_, gl_->ProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name)); |
2389 | |
2390 GetFramebufferTexture(texture_id, RGBA_8888, window_rect); | |
danakj
2014/07/07 16:47:06
I liked that this call wasn't duplicated, only cod
| |
2391 GLC(gl_, gl_->BindTexture(GL_TEXTURE_2D, 0)); | |
2392 | |
2393 release_callback = texture_mailbox_deleter_->GetReleaseCallback( | |
2394 output_surface_->context_provider(), texture_id); | |
2400 } else { | 2395 } else { |
2401 GLC(gl_, gl_->ConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name)); | 2396 mailbox = request->texture_mailbox().mailbox(); |
2397 DCHECK_EQ(static_cast<unsigned>(GL_TEXTURE_2D), | |
2398 request->texture_mailbox().target()); | |
2399 DCHECK(!mailbox.IsZero()); | |
2400 unsigned incoming_sync_point = request->texture_mailbox().sync_point(); | |
2401 if (incoming_sync_point) | |
2402 GLC(gl_, gl_->WaitSyncPointCHROMIUM(incoming_sync_point)); | |
2403 | |
2404 GLuint texture_id = GLC( | |
2405 gl_, | |
2406 gl_->CreateAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name)); | |
2407 | |
2408 GetFramebufferTexture(texture_id, RGBA_8888, window_rect); | |
2409 | |
2410 gl_->DeleteTextures(1, &texture_id); | |
2402 } | 2411 } |
2403 GetFramebufferTexture(texture_id, RGBA_8888, window_rect); | |
2404 GLC(gl_, gl_->BindTexture(GL_TEXTURE_2D, 0)); | |
2405 | 2412 |
2406 unsigned sync_point = gl_->InsertSyncPointCHROMIUM(); | 2413 unsigned sync_point = gl_->InsertSyncPointCHROMIUM(); |
2407 TextureMailbox texture_mailbox(mailbox, GL_TEXTURE_2D, sync_point); | 2414 TextureMailbox texture_mailbox(mailbox, GL_TEXTURE_2D, sync_point); |
2408 | |
2409 scoped_ptr<SingleReleaseCallback> release_callback; | |
2410 if (own_mailbox) { | |
2411 release_callback = texture_mailbox_deleter_->GetReleaseCallback( | |
2412 output_surface_->context_provider(), texture_id); | |
2413 } else { | |
2414 gl_->DeleteTextures(1, &texture_id); | |
2415 } | |
2416 | |
2417 request->SendTextureResult( | 2415 request->SendTextureResult( |
2418 window_rect.size(), texture_mailbox, release_callback.Pass()); | 2416 window_rect.size(), texture_mailbox, release_callback.Pass()); |
2419 return; | 2417 return; |
2420 } | 2418 } |
2421 | 2419 |
2422 DCHECK(request->force_bitmap_result()); | 2420 DCHECK(request->force_bitmap_result()); |
2423 | 2421 |
2424 scoped_ptr<PendingAsyncReadPixels> pending_read(new PendingAsyncReadPixels); | 2422 scoped_ptr<PendingAsyncReadPixels> pending_read(new PendingAsyncReadPixels); |
2425 pending_read->copy_request = request.Pass(); | 2423 pending_read->copy_request = request.Pass(); |
2426 pending_async_read_pixels_.insert(pending_async_read_pixels_.begin(), | 2424 pending_async_read_pixels_.insert(pending_async_read_pixels_.begin(), |
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3169 context_support_->ScheduleOverlayPlane( | 3167 context_support_->ScheduleOverlayPlane( |
3170 overlay.plane_z_order, | 3168 overlay.plane_z_order, |
3171 overlay.transform, | 3169 overlay.transform, |
3172 pending_overlay_resources_.back()->texture_id(), | 3170 pending_overlay_resources_.back()->texture_id(), |
3173 overlay.display_rect, | 3171 overlay.display_rect, |
3174 overlay.uv_rect); | 3172 overlay.uv_rect); |
3175 } | 3173 } |
3176 } | 3174 } |
3177 | 3175 |
3178 } // namespace cc | 3176 } // namespace cc |
OLD | NEW |