| 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 2356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2367 make_scoped_ptr(new ResourceProvider::ScopedWriteLockGL( | 2367 make_scoped_ptr(new ResourceProvider::ScopedWriteLockGL( |
| 2368 resource_provider_, texture->id())); | 2368 resource_provider_, texture->id())); |
| 2369 unsigned texture_id = current_framebuffer_lock_->texture_id(); | 2369 unsigned texture_id = current_framebuffer_lock_->texture_id(); |
| 2370 GLC(context_, | 2370 GLC(context_, |
| 2371 context_->framebufferTexture2D( | 2371 context_->framebufferTexture2D( |
| 2372 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture_id, 0)); | 2372 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture_id, 0)); |
| 2373 | 2373 |
| 2374 DCHECK(context_->checkFramebufferStatus(GL_FRAMEBUFFER) == | 2374 DCHECK(context_->checkFramebufferStatus(GL_FRAMEBUFFER) == |
| 2375 GL_FRAMEBUFFER_COMPLETE || IsContextLost()); | 2375 GL_FRAMEBUFFER_COMPLETE || IsContextLost()); |
| 2376 | 2376 |
| 2377 InitializeMatrices(frame, framebuffer_rect, false); | 2377 InitializeMatrices(frame, gfx::Vector2d(), framebuffer_rect, false); |
| 2378 SetDrawViewportSize(framebuffer_rect.size()); | 2378 SetDrawViewport(gfx::Rect(framebuffer_rect.size())); |
| 2379 | 2379 |
| 2380 return true; | 2380 return true; |
| 2381 } | 2381 } |
| 2382 | 2382 |
| 2383 void GLRenderer::SetScissorTestRect(gfx::Rect scissor_rect) { | 2383 void GLRenderer::SetScissorTestRect(gfx::Rect scissor_rect) { |
| 2384 EnsureScissorTestEnabled(); | 2384 EnsureScissorTestEnabled(); |
| 2385 | 2385 |
| 2386 // Don't unnecessarily ask the context to change the scissor, because it | 2386 // Don't unnecessarily ask the context to change the scissor, because it |
| 2387 // may cause undesired GPU pipeline flushes. | 2387 // may cause undesired GPU pipeline flushes. |
| 2388 if (scissor_rect == scissor_rect_) | 2388 if (scissor_rect == scissor_rect_) |
| 2389 return; | 2389 return; |
| 2390 | 2390 |
| 2391 scissor_rect_ = scissor_rect; | 2391 scissor_rect_ = scissor_rect; |
| 2392 FlushTextureQuadCache(); | 2392 FlushTextureQuadCache(); |
| 2393 GLC(context_, | 2393 GLC(context_, |
| 2394 context_->scissor(scissor_rect.x(), | 2394 context_->scissor(scissor_rect.x(), |
| 2395 scissor_rect.y(), | 2395 scissor_rect.y(), |
| 2396 scissor_rect.width(), | 2396 scissor_rect.width(), |
| 2397 scissor_rect.height())); | 2397 scissor_rect.height())); |
| 2398 } | 2398 } |
| 2399 | 2399 |
| 2400 void GLRenderer::SetDrawViewportSize(gfx::Size viewport_size) { | 2400 void GLRenderer::SetDrawViewport(gfx::Rect viewport) { |
| 2401 current_framebuffer_size_ = viewport_size; | 2401 current_framebuffer_size_ = viewport.size(); |
| 2402 GLC(context_, | 2402 GLC(context_, context_->viewport(viewport.x(), |
| 2403 context_->viewport(0, 0, viewport_size.width(), viewport_size.height())); | 2403 viewport.y(), |
| 2404 viewport.width(), |
| 2405 viewport.height())); |
| 2404 } | 2406 } |
| 2405 | 2407 |
| 2406 bool GLRenderer::MakeContextCurrent() { return context_->makeContextCurrent(); } | 2408 bool GLRenderer::MakeContextCurrent() { return context_->makeContextCurrent(); } |
| 2407 | 2409 |
| 2408 bool GLRenderer::InitializeSharedObjects() { | 2410 bool GLRenderer::InitializeSharedObjects() { |
| 2409 TRACE_EVENT0("cc", "GLRenderer::InitializeSharedObjects"); | 2411 TRACE_EVENT0("cc", "GLRenderer::InitializeSharedObjects"); |
| 2410 MakeContextCurrent(); | 2412 MakeContextCurrent(); |
| 2411 | 2413 |
| 2412 // Create an FBO for doing offscreen rendering. | 2414 // Create an FBO for doing offscreen rendering. |
| 2413 GLC(context_, offscreen_framebuffer_id_ = context_->createFramebuffer()); | 2415 GLC(context_, offscreen_framebuffer_id_ = context_->createFramebuffer()); |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2912 // The Skia GPU backend requires a stencil buffer. See ReinitializeGrCanvas | 2914 // The Skia GPU backend requires a stencil buffer. See ReinitializeGrCanvas |
| 2913 // implementation. | 2915 // implementation. |
| 2914 return gr_context_ && context_->getContextAttributes().stencil; | 2916 return gr_context_ && context_->getContextAttributes().stencil; |
| 2915 } | 2917 } |
| 2916 | 2918 |
| 2917 bool GLRenderer::IsContextLost() { | 2919 bool GLRenderer::IsContextLost() { |
| 2918 return (context_->getGraphicsResetStatusARB() != GL_NO_ERROR); | 2920 return (context_->getGraphicsResetStatusARB() != GL_NO_ERROR); |
| 2919 } | 2921 } |
| 2920 | 2922 |
| 2921 } // namespace cc | 2923 } // namespace cc |
| OLD | NEW |