Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: cc/gl_renderer.cc

Issue 11413106: cc: Make RenderPass into a struct-like class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/direct_renderer.cc ('k') | cc/gl_renderer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/gl_renderer.h" 5 #include "cc/gl_renderer.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/string_split.h" 9 #include "base/string_split.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 } 194 }
195 195
196 void GLRenderer::viewportChanged() 196 void GLRenderer::viewportChanged()
197 { 197 {
198 m_isViewportChanged = true; 198 m_isViewportChanged = true;
199 } 199 }
200 200
201 void GLRenderer::clearFramebuffer(DrawingFrame& frame) 201 void GLRenderer::clearFramebuffer(DrawingFrame& frame)
202 { 202 {
203 // On DEBUG builds, opaque render passes are cleared to blue to easily see r egions that were not drawn on the screen. 203 // On DEBUG builds, opaque render passes are cleared to blue to easily see r egions that were not drawn on the screen.
204 if (frame.currentRenderPass->hasTransparentBackground()) 204 if (frame.currentRenderPass->has_transparent_background)
205 GLC(m_context, m_context->clearColor(0, 0, 0, 0)); 205 GLC(m_context, m_context->clearColor(0, 0, 0, 0));
206 else 206 else
207 GLC(m_context, m_context->clearColor(0, 0, 1, 1)); 207 GLC(m_context, m_context->clearColor(0, 0, 1, 1));
208 208
209 #ifdef NDEBUG 209 #ifdef NDEBUG
210 if (frame.currentRenderPass->hasTransparentBackground()) 210 if (frame.currentRenderPass->has_transparent_background)
211 #endif 211 #endif
212 m_context->clear(GL_COLOR_BUFFER_BIT); 212 m_context->clear(GL_COLOR_BUFFER_BIT);
213 } 213 }
214 214
215 void GLRenderer::beginDrawingFrame(DrawingFrame& frame) 215 void GLRenderer::beginDrawingFrame(DrawingFrame& frame)
216 { 216 {
217 // FIXME: Remove this once framebuffer is automatically recreated on first u se 217 // FIXME: Remove this once framebuffer is automatically recreated on first u se
218 ensureFramebuffer(); 218 ensureFramebuffer();
219 219
220 if (viewportSize().IsEmpty()) 220 if (viewportSize().IsEmpty())
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 // 448 //
449 // Pixel copies in this algorithm occur at steps 2, 3, 4, and 5. 449 // Pixel copies in this algorithm occur at steps 2, 3, 4, and 5.
450 450
451 // FIXME: When this algorithm changes, update LayerTreeHost::prioritizeTextu res() accordingly. 451 // FIXME: When this algorithm changes, update LayerTreeHost::prioritizeTextu res() accordingly.
452 452
453 if (filters.isEmpty()) 453 if (filters.isEmpty())
454 return scoped_ptr<ScopedResource>(); 454 return scoped_ptr<ScopedResource>();
455 455
456 // FIXME: We only allow background filters on an opaque render surface becau se other surfaces may contain 456 // FIXME: We only allow background filters on an opaque render surface becau se other surfaces may contain
457 // translucent pixels, and the contents behind those translucent pixels woul dn't have the filter applied. 457 // translucent pixels, and the contents behind those translucent pixels woul dn't have the filter applied.
458 if (frame.currentRenderPass->hasTransparentBackground()) 458 if (frame.currentRenderPass->has_transparent_background)
459 return scoped_ptr<ScopedResource>(); 459 return scoped_ptr<ScopedResource>();
460 DCHECK(!frame.currentTexture); 460 DCHECK(!frame.currentTexture);
461 461
462 // FIXME: Do a single readback for both the surface and replica and cache th e filtered results (once filter textures are not reused). 462 // FIXME: Do a single readback for both the surface and replica and cache th e filtered results (once filter textures are not reused).
463 gfx::Rect deviceRect = gfx::ToEnclosingRect(MathUtil::mapClippedRect(content sDeviceTransform, sharedGeometryQuad().BoundingBox())); 463 gfx::Rect deviceRect = gfx::ToEnclosingRect(MathUtil::mapClippedRect(content sDeviceTransform, sharedGeometryQuad().BoundingBox()));
464 464
465 int top, right, bottom, left; 465 int top, right, bottom, left;
466 filters.getOutsets(top, right, bottom, left); 466 filters.getOutsets(top, right, bottom, left);
467 deviceRect.Inset(-left, -top, -right, -bottom); 467 deviceRect.Inset(-left, -top, -right, -bottom);
468 468
469 deviceRect.Intersect(frame.currentRenderPass->outputRect()); 469 deviceRect.Intersect(frame.currentRenderPass->output_rect);
470 470
471 scoped_ptr<ScopedResource> deviceBackgroundTexture = ScopedResource::create( m_resourceProvider); 471 scoped_ptr<ScopedResource> deviceBackgroundTexture = ScopedResource::create( m_resourceProvider);
472 if (!getFramebufferTexture(deviceBackgroundTexture.get(), deviceRect)) 472 if (!getFramebufferTexture(deviceBackgroundTexture.get(), deviceRect))
473 return scoped_ptr<ScopedResource>(); 473 return scoped_ptr<ScopedResource>();
474 474
475 SkBitmap filteredDeviceBackground = applyFilters(this, filters, deviceBackgr oundTexture.get(), m_client->hasImplThread()); 475 SkBitmap filteredDeviceBackground = applyFilters(this, filters, deviceBackgr oundTexture.get(), m_client->hasImplThread());
476 if (!filteredDeviceBackground.getTexture()) 476 if (!filteredDeviceBackground.getTexture())
477 return scoped_ptr<ScopedResource>(); 477 return scoped_ptr<ScopedResource>();
478 478
479 GrTexture* texture = reinterpret_cast<GrTexture*>(filteredDeviceBackground.g etTexture()); 479 GrTexture* texture = reinterpret_cast<GrTexture*>(filteredDeviceBackground.g etTexture());
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 WebTransformationMatrix quadRectMatrix; 516 WebTransformationMatrix quadRectMatrix;
517 quadRectTransform(&quadRectMatrix, quad->quadTransform(), quad->rect); 517 quadRectTransform(&quadRectMatrix, quad->quadTransform(), quad->rect);
518 WebTransformationMatrix contentsDeviceTransform = (frame.windowMatrix * fram e.projectionMatrix * quadRectMatrix).to2dTransform(); 518 WebTransformationMatrix contentsDeviceTransform = (frame.windowMatrix * fram e.projectionMatrix * quadRectMatrix).to2dTransform();
519 519
520 // Can only draw surface if device matrix is invertible. 520 // Can only draw surface if device matrix is invertible.
521 if (!contentsDeviceTransform.isInvertible()) 521 if (!contentsDeviceTransform.isInvertible())
522 return; 522 return;
523 523
524 WebTransformationMatrix contentsDeviceTransformInverse = contentsDeviceTrans form.inverse(); 524 WebTransformationMatrix contentsDeviceTransformInverse = contentsDeviceTrans form.inverse();
525 scoped_ptr<ScopedResource> backgroundTexture = drawBackgroundFilters( 525 scoped_ptr<ScopedResource> backgroundTexture = drawBackgroundFilters(
526 frame, quad, renderPass->backgroundFilters(), 526 frame, quad, renderPass->background_filters,
527 contentsDeviceTransform, contentsDeviceTransformInverse); 527 contentsDeviceTransform, contentsDeviceTransformInverse);
528 528
529 // FIXME: Cache this value so that we don't have to do it for both the surfa ce and its replica. 529 // FIXME: Cache this value so that we don't have to do it for both the surfa ce and its replica.
530 // Apply filters to the contents texture. 530 // Apply filters to the contents texture.
531 SkBitmap filterBitmap; 531 SkBitmap filterBitmap;
532 if (renderPass->filter()) { 532 if (renderPass->filter) {
533 filterBitmap = applyImageFilter(this, renderPass->filter(), contentsText ure, m_client->hasImplThread()); 533 filterBitmap = applyImageFilter(this, renderPass->filter, contentsTextur e, m_client->hasImplThread());
534 } else { 534 } else {
535 filterBitmap = applyFilters(this, renderPass->filters(), contentsTexture , m_client->hasImplThread()); 535 filterBitmap = applyFilters(this, renderPass->filters, contentsTexture, m_client->hasImplThread());
536 } 536 }
537 scoped_ptr<ResourceProvider::ScopedReadLockGL> contentsResourceLock; 537 scoped_ptr<ResourceProvider::ScopedReadLockGL> contentsResourceLock;
538 unsigned contentsTextureId = 0; 538 unsigned contentsTextureId = 0;
539 if (filterBitmap.getTexture()) { 539 if (filterBitmap.getTexture()) {
540 GrTexture* texture = reinterpret_cast<GrTexture*>(filterBitmap.getTextur e()); 540 GrTexture* texture = reinterpret_cast<GrTexture*>(filterBitmap.getTextur e());
541 contentsTextureId = texture->getTextureHandle(); 541 contentsTextureId = texture->getTextureHandle();
542 } else { 542 } else {
543 contentsResourceLock = make_scoped_ptr(new ResourceProvider::ScopedReadL ockGL(m_resourceProvider, contentsTexture->id())); 543 contentsResourceLock = make_scoped_ptr(new ResourceProvider::ScopedReadL ockGL(m_resourceProvider, contentsTexture->id()));
544 contentsTextureId = contentsResourceLock->textureId(); 544 contentsTextureId = contentsResourceLock->textureId();
545 } 545 }
(...skipping 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after
1611 1611
1612 releaseRenderPassTextures(); 1612 releaseRenderPassTextures();
1613 } 1613 }
1614 1614
1615 bool GLRenderer::isContextLost() 1615 bool GLRenderer::isContextLost()
1616 { 1616 {
1617 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); 1617 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR);
1618 } 1618 }
1619 1619
1620 } // namespace cc 1620 } // namespace cc
OLDNEW
« no previous file with comments | « cc/direct_renderer.cc ('k') | cc/gl_renderer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698