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

Side by Side Diff: cc/output/gl_renderer.cc

Issue 16968002: Move implementation of WebFilterOperations into cc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 months 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
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/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 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 432
433 GLC(Context(), Context()->lineWidth(quad->width)); 433 GLC(Context(), Context()->lineWidth(quad->width));
434 434
435 // The indices for the line are stored in the same array as the triangle 435 // The indices for the line are stored in the same array as the triangle
436 // indices. 436 // indices.
437 GLC(Context(), 437 GLC(Context(),
438 Context()->drawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_SHORT, 0)); 438 Context()->drawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_SHORT, 0));
439 } 439 }
440 440
441 static inline SkBitmap ApplyFilters(GLRenderer* renderer, 441 static inline SkBitmap ApplyFilters(GLRenderer* renderer,
442 const WebKit::WebFilterOperations& filters, 442 const FilterOperations& filters,
443 ScopedResource* source_texture_resource) { 443 ScopedResource* source_texture_resource) {
444 if (filters.isEmpty()) 444 if (filters.IsEmpty())
445 return SkBitmap(); 445 return SkBitmap();
446 446
447 ContextProvider* offscreen_contexts = 447 ContextProvider* offscreen_contexts =
448 renderer->resource_provider()->offscreen_context_provider(); 448 renderer->resource_provider()->offscreen_context_provider();
449 if (!offscreen_contexts || !offscreen_contexts->GrContext()) 449 if (!offscreen_contexts || !offscreen_contexts->GrContext())
450 return SkBitmap(); 450 return SkBitmap();
451 451
452 ResourceProvider::ScopedWriteLockGL lock(renderer->resource_provider(), 452 ResourceProvider::ScopedWriteLockGL lock(renderer->resource_provider(),
453 source_texture_resource->id()); 453 source_texture_resource->id());
454 454
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 // the current background pixels with the new filtered background. 580 // the current background pixels with the new filtered background.
581 // 6. Draw the contents of the quad over drop of the new background with 581 // 6. Draw the contents of the quad over drop of the new background with
582 // blending, as per usual. The filtered background pixels will show through 582 // blending, as per usual. The filtered background pixels will show through
583 // any non-opaque pixels in this draws. 583 // any non-opaque pixels in this draws.
584 // 584 //
585 // Pixel copies in this algorithm occur at steps 2, 3, 4, and 5. 585 // Pixel copies in this algorithm occur at steps 2, 3, 4, and 5.
586 586
587 // FIXME: When this algorithm changes, update 587 // FIXME: When this algorithm changes, update
588 // LayerTreeHost::PrioritizeTextures() accordingly. 588 // LayerTreeHost::PrioritizeTextures() accordingly.
589 589
590 const WebKit::WebFilterOperations& filters = quad->background_filters; 590 const FilterOperations& filters = quad->background_filters;
591 DCHECK(!filters.isEmpty()); 591 DCHECK(!filters.IsEmpty());
592 592
593 // FIXME: We only allow background filters on an opaque render surface because 593 // FIXME: We only allow background filters on an opaque render surface because
594 // other surfaces may contain translucent pixels, and the contents behind 594 // other surfaces may contain translucent pixels, and the contents behind
595 // those translucent pixels wouldn't have the filter applied. 595 // those translucent pixels wouldn't have the filter applied.
596 if (frame->current_render_pass->has_transparent_background) 596 if (frame->current_render_pass->has_transparent_background)
597 return scoped_ptr<ScopedResource>(); 597 return scoped_ptr<ScopedResource>();
598 DCHECK(!frame->current_texture); 598 DCHECK(!frame->current_texture);
599 599
600 // FIXME: Do a single readback for both the surface and replica and cache the 600 // FIXME: Do a single readback for both the surface and replica and cache the
601 // filtered results (once filter textures are not reused). 601 // filtered results (once filter textures are not reused).
602 gfx::Rect device_rect = gfx::ToEnclosingRect(MathUtil::MapClippedRect( 602 gfx::Rect device_rect = gfx::ToEnclosingRect(MathUtil::MapClippedRect(
603 contents_device_transform, SharedGeometryQuad().BoundingBox())); 603 contents_device_transform, SharedGeometryQuad().BoundingBox()));
604 604
605 int top, right, bottom, left; 605 int top, right, bottom, left;
606 filters.getOutsets(top, right, bottom, left); 606 filters.GetOutsets(&top, &right, &bottom, &left);
607 device_rect.Inset(-left, -top, -right, -bottom); 607 device_rect.Inset(-left, -top, -right, -bottom);
608 608
609 device_rect.Intersect(frame->current_render_pass->output_rect); 609 device_rect.Intersect(frame->current_render_pass->output_rect);
610 610
611 scoped_ptr<ScopedResource> device_background_texture = 611 scoped_ptr<ScopedResource> device_background_texture =
612 ScopedResource::create(resource_provider_); 612 ScopedResource::create(resource_provider_);
613 if (!GetFramebufferTexture(device_background_texture.get(), device_rect)) 613 if (!GetFramebufferTexture(device_background_texture.get(), device_rect))
614 return scoped_ptr<ScopedResource>(); 614 return scoped_ptr<ScopedResource>();
615 615
616 SkBitmap filtered_device_background = 616 SkBitmap filtered_device_background =
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 frame->window_matrix * frame->projection_matrix * quad_rect_matrix; 685 frame->window_matrix * frame->projection_matrix * quad_rect_matrix;
686 contents_device_transform.FlattenTo2d(); 686 contents_device_transform.FlattenTo2d();
687 687
688 // Can only draw surface if device matrix is invertible. 688 // Can only draw surface if device matrix is invertible.
689 gfx::Transform contents_device_transform_inverse( 689 gfx::Transform contents_device_transform_inverse(
690 gfx::Transform::kSkipInitialization); 690 gfx::Transform::kSkipInitialization);
691 if (!contents_device_transform.GetInverse(&contents_device_transform_inverse)) 691 if (!contents_device_transform.GetInverse(&contents_device_transform_inverse))
692 return; 692 return;
693 693
694 scoped_ptr<ScopedResource> background_texture; 694 scoped_ptr<ScopedResource> background_texture;
695 if (!quad->background_filters.isEmpty()) { 695 if (!quad->background_filters.IsEmpty()) {
696 // The pixels from the filtered background should completely replace the 696 // The pixels from the filtered background should completely replace the
697 // current pixel values. 697 // current pixel values.
698 bool disable_blending = blend_enabled(); 698 bool disable_blending = blend_enabled();
699 if (disable_blending) 699 if (disable_blending)
700 SetBlendEnabled(false); 700 SetBlendEnabled(false);
701 701
702 background_texture = DrawBackgroundFilters( 702 background_texture = DrawBackgroundFilters(
703 frame, 703 frame,
704 quad, 704 quad,
705 contents_device_transform, 705 contents_device_transform,
(...skipping 2266 matching lines...) Expand 10 before | Expand all | Expand 10 after
2972 // The Skia GPU backend requires a stencil buffer. See ReinitializeGrCanvas 2972 // The Skia GPU backend requires a stencil buffer. See ReinitializeGrCanvas
2973 // implementation. 2973 // implementation.
2974 return gr_context_ && context_->getContextAttributes().stencil; 2974 return gr_context_ && context_->getContextAttributes().stencil;
2975 } 2975 }
2976 2976
2977 bool GLRenderer::IsContextLost() { 2977 bool GLRenderer::IsContextLost() {
2978 return (context_->getGraphicsResetStatusARB() != GL_NO_ERROR); 2978 return (context_->getGraphicsResetStatusARB() != GL_NO_ERROR);
2979 } 2979 }
2980 2980
2981 } // namespace cc 2981 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698