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

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

Issue 191123002: Implement hidpi and pinch-zoom scaling of filter params in cc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove TODO Created 6 years, 9 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
« no previous file with comments | « cc/layers/render_surface_impl.cc ('k') | cc/output/renderer_pixeltest.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/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 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 GLC(gl_, gl_->LineWidth(quad->width)); 482 GLC(gl_, gl_->LineWidth(quad->width));
483 483
484 // The indices for the line are stored in the same array as the triangle 484 // The indices for the line are stored in the same array as the triangle
485 // indices. 485 // indices.
486 GLC(gl_, gl_->DrawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_SHORT, 0)); 486 GLC(gl_, gl_->DrawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_SHORT, 0));
487 } 487 }
488 488
489 static SkBitmap ApplyImageFilter(GLRenderer* renderer, 489 static SkBitmap ApplyImageFilter(GLRenderer* renderer,
490 ContextProvider* offscreen_contexts, 490 ContextProvider* offscreen_contexts,
491 const gfx::Point& origin, 491 const gfx::Point& origin,
492 const gfx::Vector2dF& scale,
492 SkImageFilter* filter, 493 SkImageFilter* filter,
493 ScopedResource* source_texture_resource) { 494 ScopedResource* source_texture_resource) {
494 if (!filter) 495 if (!filter)
495 return SkBitmap(); 496 return SkBitmap();
496 497
497 if (!offscreen_contexts || !offscreen_contexts->GrContext()) 498 if (!offscreen_contexts || !offscreen_contexts->GrContext())
498 return SkBitmap(); 499 return SkBitmap();
499 500
500 ResourceProvider::ScopedWriteLockGL lock(renderer->resource_provider(), 501 ResourceProvider::ScopedWriteLockGL lock(renderer->resource_provider(),
501 source_texture_resource->id()); 502 source_texture_resource->id());
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 546
546 // Create a device and canvas using that backing store. 547 // Create a device and canvas using that backing store.
547 SkGpuDevice device(offscreen_contexts->GrContext(), backing_store.get()); 548 SkGpuDevice device(offscreen_contexts->GrContext(), backing_store.get());
548 SkCanvas canvas(&device); 549 SkCanvas canvas(&device);
549 550
550 // Draw the source bitmap through the filter to the canvas. 551 // Draw the source bitmap through the filter to the canvas.
551 SkPaint paint; 552 SkPaint paint;
552 paint.setImageFilter(filter); 553 paint.setImageFilter(filter);
553 canvas.clear(SK_ColorTRANSPARENT); 554 canvas.clear(SK_ColorTRANSPARENT);
554 555
555 // TODO(senorblanco): in addition to the origin translation here, the canvas
556 // should also be scaled to accomodate device pixel ratio and pinch zoom. See
557 // crbug.com/281516 and crbug.com/281518.
558 canvas.translate(SkIntToScalar(-origin.x()), SkIntToScalar(-origin.y())); 556 canvas.translate(SkIntToScalar(-origin.x()), SkIntToScalar(-origin.y()));
557 canvas.scale(scale.x(), scale.y());
559 canvas.drawSprite(source, 0, 0, &paint); 558 canvas.drawSprite(source, 0, 0, &paint);
560 559
561 // Flush skia context so that all the rendered stuff appears on the 560 // Flush skia context so that all the rendered stuff appears on the
562 // texture. 561 // texture.
563 offscreen_contexts->GrContext()->flush(); 562 offscreen_contexts->GrContext()->flush();
564 563
565 // Flush the GL context so rendering results from this context are 564 // Flush the GL context so rendering results from this context are
566 // visible in the compositor's context. 565 // visible in the compositor's context.
567 offscreen_contexts->ContextGL()->Flush(); 566 offscreen_contexts->ContextGL()->Flush();
568 567
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 759
761 skia::RefPtr<SkImageFilter> filter = RenderSurfaceFilters::BuildImageFilter( 760 skia::RefPtr<SkImageFilter> filter = RenderSurfaceFilters::BuildImageFilter(
762 quad->background_filters, device_background_texture->size()); 761 quad->background_filters, device_background_texture->size());
763 762
764 SkBitmap filtered_device_background; 763 SkBitmap filtered_device_background;
765 if (apply_background_filters) { 764 if (apply_background_filters) {
766 filtered_device_background = 765 filtered_device_background =
767 ApplyImageFilter(this, 766 ApplyImageFilter(this,
768 frame->offscreen_context_provider, 767 frame->offscreen_context_provider,
769 quad->rect.origin(), 768 quad->rect.origin(),
769 quad->filters_scale,
770 filter.get(), 770 filter.get(),
771 device_background_texture.get()); 771 device_background_texture.get());
772 } 772 }
773 *background_changed = (filtered_device_background.getTexture() != NULL); 773 *background_changed = (filtered_device_background.getTexture() != NULL);
774 774
775 int filtered_device_background_texture_id = 0; 775 int filtered_device_background_texture_id = 0;
776 scoped_ptr<ResourceProvider::ScopedReadLockGL> lock; 776 scoped_ptr<ResourceProvider::ScopedReadLockGL> lock;
777 if (filtered_device_background.getTexture()) { 777 if (filtered_device_background.getTexture()) {
778 GrTexture* texture = 778 GrTexture* texture =
779 reinterpret_cast<GrTexture*>(filtered_device_background.getTexture()); 779 reinterpret_cast<GrTexture*>(filtered_device_background.getTexture());
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 } 894 }
895 895
896 if (cf && cf->asColorMatrix(color_matrix) && !filter->getInput(0)) { 896 if (cf && cf->asColorMatrix(color_matrix) && !filter->getInput(0)) {
897 // We have a single color matrix as a filter; apply it locally 897 // We have a single color matrix as a filter; apply it locally
898 // in the compositor. 898 // in the compositor.
899 use_color_matrix = true; 899 use_color_matrix = true;
900 } else { 900 } else {
901 filter_bitmap = ApplyImageFilter(this, 901 filter_bitmap = ApplyImageFilter(this,
902 frame->offscreen_context_provider, 902 frame->offscreen_context_provider,
903 quad->rect.origin(), 903 quad->rect.origin(),
904 quad->filters_scale,
904 filter.get(), 905 filter.get(),
905 contents_texture); 906 contents_texture);
906 } 907 }
907 } 908 }
908 } 909 }
909 910
910 if (quad->shared_quad_state->blend_mode != SkXfermode::kSrcOver_Mode && 911 if (quad->shared_quad_state->blend_mode != SkXfermode::kSrcOver_Mode &&
911 background_texture) { 912 background_texture) {
912 filter_bitmap = 913 filter_bitmap =
913 ApplyBlendModeWithBackdrop(this, 914 ApplyBlendModeWithBackdrop(this,
(...skipping 2127 matching lines...) Expand 10 before | Expand all | Expand 10 after
3041 is_scissor_enabled_ = false; 3042 is_scissor_enabled_ = false;
3042 GLC(gl_, gl_->Disable(GL_SCISSOR_TEST)); 3043 GLC(gl_, gl_->Disable(GL_SCISSOR_TEST));
3043 scissor_rect_needs_reset_ = true; 3044 scissor_rect_needs_reset_ = true;
3044 } 3045 }
3045 3046
3046 bool GLRenderer::IsContextLost() { 3047 bool GLRenderer::IsContextLost() {
3047 return output_surface_->context_provider()->IsContextLost(); 3048 return output_surface_->context_provider()->IsContextLost();
3048 } 3049 }
3049 3050
3050 } // namespace cc 3051 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/render_surface_impl.cc ('k') | cc/output/renderer_pixeltest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698