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 2320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2331 gfx::Rect rect, scoped_ptr<CopyOutputRequest> request) { | 2331 gfx::Rect rect, scoped_ptr<CopyOutputRequest> request) { |
2332 DCHECK(!request->IsEmpty()); | 2332 DCHECK(!request->IsEmpty()); |
2333 if (request->IsEmpty()) | 2333 if (request->IsEmpty()) |
2334 return; | 2334 return; |
2335 if (rect.IsEmpty()) | 2335 if (rect.IsEmpty()) |
2336 return; | 2336 return; |
2337 | 2337 |
2338 gfx::Rect window_rect = MoveFromDrawToWindowSpace(rect); | 2338 gfx::Rect window_rect = MoveFromDrawToWindowSpace(rect); |
2339 | 2339 |
2340 if (!request->force_bitmap_result()) { | 2340 if (!request->force_bitmap_result()) { |
| 2341 bool own_mailbox = !request->has_texture_mailbox(); |
| 2342 |
2341 unsigned int texture_id = context_->createTexture(); | 2343 unsigned int texture_id = context_->createTexture(); |
2342 GLC(context_, context_->bindTexture(GL_TEXTURE_2D, texture_id)); | |
2343 GLC(context_, context_->texParameteri( | |
2344 GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); | |
2345 GLC(context_, context_->texParameteri( | |
2346 GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); | |
2347 GLC(context_, context_->texParameteri( | |
2348 GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); | |
2349 GLC(context_, context_->texParameteri( | |
2350 GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)); | |
2351 GetFramebufferTexture(texture_id, RGBA_8888, window_rect); | |
2352 | 2344 |
2353 gpu::Mailbox mailbox; | 2345 gpu::Mailbox mailbox; |
2354 unsigned sync_point = 0; | 2346 if (own_mailbox) { |
2355 GLC(context_, context_->genMailboxCHROMIUM(mailbox.name)); | 2347 GLC(context_, context_->genMailboxCHROMIUM(mailbox.name)); |
2356 if (mailbox.IsZero()) { | 2348 if (mailbox.IsZero()) { |
2357 context_->deleteTexture(texture_id); | 2349 context_->deleteTexture(texture_id); |
2358 request->SendEmptyResult(); | 2350 request->SendEmptyResult(); |
2359 return; | 2351 return; |
| 2352 } |
| 2353 } else { |
| 2354 mailbox = request->texture_mailbox().name(); |
| 2355 DCHECK_EQ(static_cast<unsigned>(GL_TEXTURE_2D), |
| 2356 request->texture_mailbox().target()); |
| 2357 DCHECK(!mailbox.IsZero()); |
| 2358 unsigned incoming_sync_point = request->texture_mailbox().sync_point(); |
| 2359 if (incoming_sync_point) |
| 2360 GLC(context_, context_->waitSyncPoint(incoming_sync_point)); |
2360 } | 2361 } |
2361 | 2362 |
2362 GLC(context_, context_->bindTexture(GL_TEXTURE_2D, texture_id)); | 2363 GLC(context_, context_->bindTexture(GL_TEXTURE_2D, texture_id)); |
2363 GLC(context_, context_->produceTextureCHROMIUM( | 2364 if (own_mailbox) { |
2364 GL_TEXTURE_2D, mailbox.name)); | 2365 GLC(context_, |
| 2366 context_->texParameteri( |
| 2367 GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); |
| 2368 GLC(context_, |
| 2369 context_->texParameteri( |
| 2370 GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); |
| 2371 GLC(context_, |
| 2372 context_->texParameteri( |
| 2373 GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); |
| 2374 GLC(context_, |
| 2375 context_->texParameteri( |
| 2376 GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)); |
| 2377 GLC(context_, |
| 2378 context_->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name)); |
| 2379 } else { |
| 2380 GLC(context_, |
| 2381 context_->consumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name)); |
| 2382 } |
| 2383 GetFramebufferTexture(texture_id, RGBA_8888, window_rect); |
2365 GLC(context_, context_->bindTexture(GL_TEXTURE_2D, 0)); | 2384 GLC(context_, context_->bindTexture(GL_TEXTURE_2D, 0)); |
2366 sync_point = context_->insertSyncPoint(); | 2385 |
| 2386 unsigned sync_point = context_->insertSyncPoint(); |
2367 TextureMailbox texture_mailbox(mailbox, GL_TEXTURE_2D, sync_point); | 2387 TextureMailbox texture_mailbox(mailbox, GL_TEXTURE_2D, sync_point); |
2368 scoped_ptr<SingleReleaseCallback> release_callback = | 2388 |
2369 texture_mailbox_deleter_->GetReleaseCallback( | 2389 scoped_ptr<SingleReleaseCallback> release_callback; |
2370 output_surface_->context_provider(), texture_id); | 2390 if (own_mailbox) { |
| 2391 release_callback = texture_mailbox_deleter_->GetReleaseCallback( |
| 2392 output_surface_->context_provider(), texture_id); |
| 2393 } else { |
| 2394 context_->deleteTexture(texture_id); |
| 2395 } |
| 2396 |
2371 request->SendTextureResult(window_rect.size(), | 2397 request->SendTextureResult(window_rect.size(), |
2372 texture_mailbox, | 2398 texture_mailbox, |
2373 release_callback.Pass()); | 2399 release_callback.Pass()); |
2374 return; | 2400 return; |
2375 } | 2401 } |
2376 | 2402 |
2377 DCHECK(request->force_bitmap_result()); | 2403 DCHECK(request->force_bitmap_result()); |
2378 | 2404 |
2379 scoped_ptr<SkBitmap> bitmap(new SkBitmap); | 2405 scoped_ptr<SkBitmap> bitmap(new SkBitmap); |
2380 bitmap->setConfig(SkBitmap::kARGB_8888_Config, | 2406 bitmap->setConfig(SkBitmap::kARGB_8888_Config, |
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3159 // The Skia GPU backend requires a stencil buffer. See ReinitializeGrCanvas | 3185 // The Skia GPU backend requires a stencil buffer. See ReinitializeGrCanvas |
3160 // implementation. | 3186 // implementation. |
3161 return gr_context_ && context_->getContextAttributes().stencil; | 3187 return gr_context_ && context_->getContextAttributes().stencil; |
3162 } | 3188 } |
3163 | 3189 |
3164 bool GLRenderer::IsContextLost() { | 3190 bool GLRenderer::IsContextLost() { |
3165 return output_surface_->context_provider()->IsContextLost(); | 3191 return output_surface_->context_provider()->IsContextLost(); |
3166 } | 3192 } |
3167 | 3193 |
3168 } // namespace cc | 3194 } // namespace cc |
OLD | NEW |