| 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 423 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 434 | 434 | 
| 435   GLC(Context(), Context()->lineWidth(quad->width)); | 435   GLC(Context(), Context()->lineWidth(quad->width)); | 
| 436 | 436 | 
| 437   // The indices for the line are stored in the same array as the triangle | 437   // The indices for the line are stored in the same array as the triangle | 
| 438   // indices. | 438   // indices. | 
| 439   GLC(Context(), | 439   GLC(Context(), | 
| 440       Context()->drawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_SHORT, 0)); | 440       Context()->drawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_SHORT, 0)); | 
| 441 } | 441 } | 
| 442 | 442 | 
| 443 static inline SkBitmap ApplyFilters(GLRenderer* renderer, | 443 static inline SkBitmap ApplyFilters(GLRenderer* renderer, | 
| 444                                     const WebKit::WebFilterOperations& filters, | 444                                     const FilterOperations& filters, | 
| 445                                     ScopedResource* source_texture_resource) { | 445                                     ScopedResource* source_texture_resource) { | 
| 446   if (filters.isEmpty()) | 446   if (filters.IsEmpty()) | 
| 447     return SkBitmap(); | 447     return SkBitmap(); | 
| 448 | 448 | 
| 449   ContextProvider* offscreen_contexts = | 449   ContextProvider* offscreen_contexts = | 
| 450       renderer->resource_provider()->offscreen_context_provider(); | 450       renderer->resource_provider()->offscreen_context_provider(); | 
| 451   if (!offscreen_contexts || !offscreen_contexts->GrContext()) | 451   if (!offscreen_contexts || !offscreen_contexts->GrContext()) | 
| 452     return SkBitmap(); | 452     return SkBitmap(); | 
| 453 | 453 | 
| 454   ResourceProvider::ScopedWriteLockGL lock(renderer->resource_provider(), | 454   ResourceProvider::ScopedWriteLockGL lock(renderer->resource_provider(), | 
| 455                                            source_texture_resource->id()); | 455                                            source_texture_resource->id()); | 
| 456 | 456 | 
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 582   // the current background pixels with the new filtered background. | 582   // the current background pixels with the new filtered background. | 
| 583   // 6. Draw the contents of the quad over drop of the new background with | 583   // 6. Draw the contents of the quad over drop of the new background with | 
| 584   // blending, as per usual. The filtered background pixels will show through | 584   // blending, as per usual. The filtered background pixels will show through | 
| 585   // any non-opaque pixels in this draws. | 585   // any non-opaque pixels in this draws. | 
| 586   // | 586   // | 
| 587   // Pixel copies in this algorithm occur at steps 2, 3, 4, and 5. | 587   // Pixel copies in this algorithm occur at steps 2, 3, 4, and 5. | 
| 588 | 588 | 
| 589   // FIXME: When this algorithm changes, update | 589   // FIXME: When this algorithm changes, update | 
| 590   // LayerTreeHost::PrioritizeTextures() accordingly. | 590   // LayerTreeHost::PrioritizeTextures() accordingly. | 
| 591 | 591 | 
| 592   const WebKit::WebFilterOperations& filters = quad->background_filters; | 592   const FilterOperations& filters = quad->background_filters; | 
| 593   DCHECK(!filters.isEmpty()); | 593   DCHECK(!filters.IsEmpty()); | 
| 594 | 594 | 
| 595   // FIXME: We only allow background filters on an opaque render surface because | 595   // FIXME: We only allow background filters on an opaque render surface because | 
| 596   // other surfaces may contain translucent pixels, and the contents behind | 596   // other surfaces may contain translucent pixels, and the contents behind | 
| 597   // those translucent pixels wouldn't have the filter applied. | 597   // those translucent pixels wouldn't have the filter applied. | 
| 598   if (frame->current_render_pass->has_transparent_background) | 598   if (frame->current_render_pass->has_transparent_background) | 
| 599     return scoped_ptr<ScopedResource>(); | 599     return scoped_ptr<ScopedResource>(); | 
| 600   DCHECK(!frame->current_texture); | 600   DCHECK(!frame->current_texture); | 
| 601 | 601 | 
| 602   // FIXME: Do a single readback for both the surface and replica and cache the | 602   // FIXME: Do a single readback for both the surface and replica and cache the | 
| 603   // filtered results (once filter textures are not reused). | 603   // filtered results (once filter textures are not reused). | 
| 604   gfx::Rect window_rect = gfx::ToEnclosingRect(MathUtil::MapClippedRect( | 604   gfx::Rect window_rect = gfx::ToEnclosingRect(MathUtil::MapClippedRect( | 
| 605       contents_device_transform, SharedGeometryQuad().BoundingBox())); | 605       contents_device_transform, SharedGeometryQuad().BoundingBox())); | 
| 606 | 606 | 
| 607   int top, right, bottom, left; | 607   int top, right, bottom, left; | 
| 608   filters.getOutsets(top, right, bottom, left); | 608   filters.GetOutsets(&top, &right, &bottom, &left); | 
| 609   window_rect.Inset(-left, -top, -right, -bottom); | 609   window_rect.Inset(-left, -top, -right, -bottom); | 
| 610 | 610 | 
| 611   window_rect.Intersect( | 611   window_rect.Intersect( | 
| 612       MoveFromDrawToWindowSpace(frame->current_render_pass->output_rect)); | 612       MoveFromDrawToWindowSpace(frame->current_render_pass->output_rect)); | 
| 613 | 613 | 
| 614   scoped_ptr<ScopedResource> device_background_texture = | 614   scoped_ptr<ScopedResource> device_background_texture = | 
| 615       ScopedResource::create(resource_provider_); | 615       ScopedResource::create(resource_provider_); | 
| 616   if (!device_background_texture->Allocate(window_rect.size(), | 616   if (!device_background_texture->Allocate(window_rect.size(), | 
| 617                                            GL_RGB, | 617                                            GL_RGB, | 
| 618                                            ResourceProvider::TextureUsageAny)) { | 618                                            ResourceProvider::TextureUsageAny)) { | 
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 697       frame->window_matrix * frame->projection_matrix * quad_rect_matrix; | 697       frame->window_matrix * frame->projection_matrix * quad_rect_matrix; | 
| 698   contents_device_transform.FlattenTo2d(); | 698   contents_device_transform.FlattenTo2d(); | 
| 699 | 699 | 
| 700   // Can only draw surface if device matrix is invertible. | 700   // Can only draw surface if device matrix is invertible. | 
| 701   gfx::Transform contents_device_transform_inverse( | 701   gfx::Transform contents_device_transform_inverse( | 
| 702       gfx::Transform::kSkipInitialization); | 702       gfx::Transform::kSkipInitialization); | 
| 703   if (!contents_device_transform.GetInverse(&contents_device_transform_inverse)) | 703   if (!contents_device_transform.GetInverse(&contents_device_transform_inverse)) | 
| 704     return; | 704     return; | 
| 705 | 705 | 
| 706   scoped_ptr<ScopedResource> background_texture; | 706   scoped_ptr<ScopedResource> background_texture; | 
| 707   if (!quad->background_filters.isEmpty()) { | 707   if (!quad->background_filters.IsEmpty()) { | 
| 708     // The pixels from the filtered background should completely replace the | 708     // The pixels from the filtered background should completely replace the | 
| 709     // current pixel values. | 709     // current pixel values. | 
| 710     bool disable_blending = blend_enabled(); | 710     bool disable_blending = blend_enabled(); | 
| 711     if (disable_blending) | 711     if (disable_blending) | 
| 712       SetBlendEnabled(false); | 712       SetBlendEnabled(false); | 
| 713 | 713 | 
| 714     background_texture = DrawBackgroundFilters( | 714     background_texture = DrawBackgroundFilters( | 
| 715         frame, | 715         frame, | 
| 716         quad, | 716         quad, | 
| 717         contents_device_transform, | 717         contents_device_transform, | 
| (...skipping 2311 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3029   // The Skia GPU backend requires a stencil buffer.  See ReinitializeGrCanvas | 3029   // The Skia GPU backend requires a stencil buffer.  See ReinitializeGrCanvas | 
| 3030   // implementation. | 3030   // implementation. | 
| 3031   return gr_context_ && context_->getContextAttributes().stencil; | 3031   return gr_context_ && context_->getContextAttributes().stencil; | 
| 3032 } | 3032 } | 
| 3033 | 3033 | 
| 3034 bool GLRenderer::IsContextLost() { | 3034 bool GLRenderer::IsContextLost() { | 
| 3035   return (context_->getGraphicsResetStatusARB() != GL_NO_ERROR); | 3035   return (context_->getGraphicsResetStatusARB() != GL_NO_ERROR); | 
| 3036 } | 3036 } | 
| 3037 | 3037 | 
| 3038 }  // namespace cc | 3038 }  // namespace cc | 
| OLD | NEW | 
|---|