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

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

Issue 23060011: Pass the quad's rect (contents_rect) origin to skia image filters as an offset in the CTM. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Modify test to cover incorrect clipping offsets, and to use blue_yellow.png as a result. Created 7 years, 3 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 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 // visible in the compositor's context. 506 // visible in the compositor's context.
507 offscreen_contexts->Context3d()->flush(); 507 offscreen_contexts->Context3d()->flush();
508 508
509 // Use the compositor's GL context again. 509 // Use the compositor's GL context again.
510 renderer->Context()->makeContextCurrent(); 510 renderer->Context()->makeContextCurrent();
511 return source; 511 return source;
512 } 512 }
513 513
514 static SkBitmap ApplyImageFilter(GLRenderer* renderer, 514 static SkBitmap ApplyImageFilter(GLRenderer* renderer,
515 ContextProvider* offscreen_contexts, 515 ContextProvider* offscreen_contexts,
516 gfx::Point origin,
516 SkImageFilter* filter, 517 SkImageFilter* filter,
517 ScopedResource* source_texture_resource) { 518 ScopedResource* source_texture_resource) {
518 if (!filter) 519 if (!filter)
519 return SkBitmap(); 520 return SkBitmap();
520 521
521 if (!offscreen_contexts || !offscreen_contexts->GrContext()) 522 if (!offscreen_contexts || !offscreen_contexts->GrContext())
522 return SkBitmap(); 523 return SkBitmap();
523 524
524 ResourceProvider::ScopedWriteLockGL lock(renderer->resource_provider(), 525 ResourceProvider::ScopedWriteLockGL lock(renderer->resource_provider(),
525 source_texture_resource->id()); 526 source_texture_resource->id());
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 skia::AdoptRef(scratch_texture.detach()); 571 skia::AdoptRef(scratch_texture.detach());
571 572
572 // Create a device and canvas using that backing store. 573 // Create a device and canvas using that backing store.
573 SkGpuDevice device(offscreen_contexts->GrContext(), backing_store.get()); 574 SkGpuDevice device(offscreen_contexts->GrContext(), backing_store.get());
574 SkCanvas canvas(&device); 575 SkCanvas canvas(&device);
575 576
576 // Draw the source bitmap through the filter to the canvas. 577 // Draw the source bitmap through the filter to the canvas.
577 SkPaint paint; 578 SkPaint paint;
578 paint.setImageFilter(filter); 579 paint.setImageFilter(filter);
579 canvas.clear(SK_ColorTRANSPARENT); 580 canvas.clear(SK_ColorTRANSPARENT);
581 canvas.translate(SkIntToScalar(-origin.x()), SkIntToScalar(-origin.y()));
danakj 2013/08/29 02:07:16 Can you add a TODO here stating that the filter sh
Stephen White 2013/08/29 17:07:00 Done.
580 canvas.drawSprite(source, 0, 0, &paint); 582 canvas.drawSprite(source, 0, 0, &paint);
581 583
582 // Flush skia context so that all the rendered stuff appears on the 584 // Flush skia context so that all the rendered stuff appears on the
583 // texture. 585 // texture.
584 offscreen_contexts->GrContext()->flush(); 586 offscreen_contexts->GrContext()->flush();
585 587
586 // Flush the GL context so rendering results from this context are 588 // Flush the GL context so rendering results from this context are
587 // visible in the compositor's context. 589 // visible in the compositor's context.
588 offscreen_contexts->Context3d()->flush(); 590 offscreen_contexts->Context3d()->flush();
589 591
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 cf = skia::AdoptRef(colorfilter_rawptr); 773 cf = skia::AdoptRef(colorfilter_rawptr);
772 } 774 }
773 775
774 if (cf && cf->asColorMatrix(color_matrix) && !quad->filter->getInput(0)) { 776 if (cf && cf->asColorMatrix(color_matrix) && !quad->filter->getInput(0)) {
775 // We have a single color matrix as a filter; apply it locally 777 // We have a single color matrix as a filter; apply it locally
776 // in the compositor. 778 // in the compositor.
777 use_color_matrix = true; 779 use_color_matrix = true;
778 } else { 780 } else {
779 filter_bitmap = ApplyImageFilter(this, 781 filter_bitmap = ApplyImageFilter(this,
780 frame->offscreen_context_provider, 782 frame->offscreen_context_provider,
783 quad->rect.origin(),
781 quad->filter.get(), 784 quad->filter.get(),
782 contents_texture); 785 contents_texture);
783 } 786 }
784 } else if (!quad->filters.IsEmpty()) { 787 } else if (!quad->filters.IsEmpty()) {
785 FilterOperations optimized_filters = 788 FilterOperations optimized_filters =
786 RenderSurfaceFilters::Optimize(quad->filters); 789 RenderSurfaceFilters::Optimize(quad->filters);
787 790
788 if ((optimized_filters.size() == 1) && 791 if ((optimized_filters.size() == 1) &&
789 (optimized_filters.at(0).type() == FilterOperation::COLOR_MATRIX)) { 792 (optimized_filters.at(0).type() == FilterOperation::COLOR_MATRIX)) {
790 memcpy( 793 memcpy(
(...skipping 2362 matching lines...) Expand 10 before | Expand all | Expand 10 after
3153 std::string unique_context_name = base::StringPrintf( 3156 std::string unique_context_name = base::StringPrintf(
3154 "%s-Offscreen-%p", 3157 "%s-Offscreen-%p",
3155 Settings().compositor_name.c_str(), 3158 Settings().compositor_name.c_str(),
3156 context_); 3159 context_);
3157 offscreen_context_provider->Context3d()->pushGroupMarkerEXT( 3160 offscreen_context_provider->Context3d()->pushGroupMarkerEXT(
3158 unique_context_name.c_str()); 3161 unique_context_name.c_str());
3159 } 3162 }
3160 3163
3161 3164
3162 } // namespace cc 3165 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/trees/layer_tree_host_pixeltest_filters.cc » ('j') | cc/trees/layer_tree_host_pixeltest_filters.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698