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 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
496 // visible in the compositor's context. | 496 // visible in the compositor's context. |
497 offscreen_contexts->Context3d()->flush(); | 497 offscreen_contexts->Context3d()->flush(); |
498 | 498 |
499 // Use the compositor's GL context again. | 499 // Use the compositor's GL context again. |
500 renderer->Context()->makeContextCurrent(); | 500 renderer->Context()->makeContextCurrent(); |
501 return source; | 501 return source; |
502 } | 502 } |
503 | 503 |
504 static SkBitmap ApplyImageFilter(GLRenderer* renderer, | 504 static SkBitmap ApplyImageFilter(GLRenderer* renderer, |
505 ContextProvider* offscreen_contexts, | 505 ContextProvider* offscreen_contexts, |
506 gfx::Point origin, | |
506 SkImageFilter* filter, | 507 SkImageFilter* filter, |
507 ScopedResource* source_texture_resource) { | 508 ScopedResource* source_texture_resource) { |
508 if (!filter) | 509 if (!filter) |
509 return SkBitmap(); | 510 return SkBitmap(); |
510 | 511 |
511 if (!offscreen_contexts || !offscreen_contexts->GrContext()) | 512 if (!offscreen_contexts || !offscreen_contexts->GrContext()) |
512 return SkBitmap(); | 513 return SkBitmap(); |
513 | 514 |
514 ResourceProvider::ScopedWriteLockGL lock(renderer->resource_provider(), | 515 ResourceProvider::ScopedWriteLockGL lock(renderer->resource_provider(), |
515 source_texture_resource->id()); | 516 source_texture_resource->id()); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
560 skia::AdoptRef(scratch_texture.detach()); | 561 skia::AdoptRef(scratch_texture.detach()); |
561 | 562 |
562 // Create a device and canvas using that backing store. | 563 // Create a device and canvas using that backing store. |
563 SkGpuDevice device(offscreen_contexts->GrContext(), backing_store.get()); | 564 SkGpuDevice device(offscreen_contexts->GrContext(), backing_store.get()); |
564 SkCanvas canvas(&device); | 565 SkCanvas canvas(&device); |
565 | 566 |
566 // Draw the source bitmap through the filter to the canvas. | 567 // Draw the source bitmap through the filter to the canvas. |
567 SkPaint paint; | 568 SkPaint paint; |
568 paint.setImageFilter(filter); | 569 paint.setImageFilter(filter); |
569 canvas.clear(SK_ColorTRANSPARENT); | 570 canvas.clear(SK_ColorTRANSPARENT); |
571 | |
572 // TODO(senorblanco): in addition to the origin translation here, the canvas | |
enne (OOO)
2013/08/29 17:11:37
Thanks for the TODO. Scale doesn't need to be sol
| |
573 // should also be scaled to accomodate device pixel ratio and pinch zoom. See | |
574 // crbug.com/281516 and crbug.com/281518. | |
575 canvas.translate(SkIntToScalar(-origin.x()), SkIntToScalar(-origin.y())); | |
570 canvas.drawSprite(source, 0, 0, &paint); | 576 canvas.drawSprite(source, 0, 0, &paint); |
571 | 577 |
572 // Flush skia context so that all the rendered stuff appears on the | 578 // Flush skia context so that all the rendered stuff appears on the |
573 // texture. | 579 // texture. |
574 offscreen_contexts->GrContext()->flush(); | 580 offscreen_contexts->GrContext()->flush(); |
575 | 581 |
576 // Flush the GL context so rendering results from this context are | 582 // Flush the GL context so rendering results from this context are |
577 // visible in the compositor's context. | 583 // visible in the compositor's context. |
578 offscreen_contexts->Context3d()->flush(); | 584 offscreen_contexts->Context3d()->flush(); |
579 | 585 |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
761 cf = skia::AdoptRef(colorfilter_rawptr); | 767 cf = skia::AdoptRef(colorfilter_rawptr); |
762 } | 768 } |
763 | 769 |
764 if (cf && cf->asColorMatrix(color_matrix) && !quad->filter->getInput(0)) { | 770 if (cf && cf->asColorMatrix(color_matrix) && !quad->filter->getInput(0)) { |
765 // We have a single color matrix as a filter; apply it locally | 771 // We have a single color matrix as a filter; apply it locally |
766 // in the compositor. | 772 // in the compositor. |
767 use_color_matrix = true; | 773 use_color_matrix = true; |
768 } else { | 774 } else { |
769 filter_bitmap = ApplyImageFilter(this, | 775 filter_bitmap = ApplyImageFilter(this, |
770 frame->offscreen_context_provider, | 776 frame->offscreen_context_provider, |
777 quad->rect.origin(), | |
771 quad->filter.get(), | 778 quad->filter.get(), |
772 contents_texture); | 779 contents_texture); |
773 } | 780 } |
774 } else if (!quad->filters.IsEmpty()) { | 781 } else if (!quad->filters.IsEmpty()) { |
775 FilterOperations optimized_filters = | 782 FilterOperations optimized_filters = |
776 RenderSurfaceFilters::Optimize(quad->filters); | 783 RenderSurfaceFilters::Optimize(quad->filters); |
777 | 784 |
778 if ((optimized_filters.size() == 1) && | 785 if ((optimized_filters.size() == 1) && |
779 (optimized_filters.at(0).type() == FilterOperation::COLOR_MATRIX)) { | 786 (optimized_filters.at(0).type() == FilterOperation::COLOR_MATRIX)) { |
780 memcpy( | 787 memcpy( |
(...skipping 2362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3143 std::string unique_context_name = base::StringPrintf( | 3150 std::string unique_context_name = base::StringPrintf( |
3144 "%s-Offscreen-%p", | 3151 "%s-Offscreen-%p", |
3145 Settings().compositor_name.c_str(), | 3152 Settings().compositor_name.c_str(), |
3146 context_); | 3153 context_); |
3147 offscreen_context_provider->Context3d()->pushGroupMarkerEXT( | 3154 offscreen_context_provider->Context3d()->pushGroupMarkerEXT( |
3148 unique_context_name.c_str()); | 3155 unique_context_name.c_str()); |
3149 } | 3156 } |
3150 | 3157 |
3151 | 3158 |
3152 } // namespace cc | 3159 } // namespace cc |
OLD | NEW |