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

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

Issue 2128113002: Use a cc::Display for WebView resourceless software draws. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: displaywebview: mojom Created 4 years, 5 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
« no previous file with comments | « cc/output/software_renderer.h ('k') | cc/output/software_renderer_unittest.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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/software_renderer.h" 5 #include "cc/output/software_renderer.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/trace_event/trace_event.h" 8 #include "base/trace_event/trace_event.h"
9 #include "cc/base/math_util.h" 9 #include "cc/base/math_util.h"
10 #include "cc/output/compositor_frame.h" 10 #include "cc/output/compositor_frame.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 SkScalarNearlyZero(matrix[SkMatrix::kMPersp1]) && 49 SkScalarNearlyZero(matrix[SkMatrix::kMPersp1]) &&
50 SkScalarNearlyZero(matrix[SkMatrix::kMPersp2] - 1.0f); 50 SkScalarNearlyZero(matrix[SkMatrix::kMPersp2] - 1.0f);
51 } 51 }
52 52
53 } // anonymous namespace 53 } // anonymous namespace
54 54
55 std::unique_ptr<SoftwareRenderer> SoftwareRenderer::Create( 55 std::unique_ptr<SoftwareRenderer> SoftwareRenderer::Create(
56 RendererClient* client, 56 RendererClient* client,
57 const RendererSettings* settings, 57 const RendererSettings* settings,
58 OutputSurface* output_surface, 58 OutputSurface* output_surface,
59 ResourceProvider* resource_provider, 59 ResourceProvider* resource_provider) {
60 bool use_image_hijack_canvas) {
61 return base::WrapUnique(new SoftwareRenderer(client, settings, output_surface, 60 return base::WrapUnique(new SoftwareRenderer(client, settings, output_surface,
62 resource_provider, 61 resource_provider));
63 use_image_hijack_canvas));
64 } 62 }
65 63
66 SoftwareRenderer::SoftwareRenderer(RendererClient* client, 64 SoftwareRenderer::SoftwareRenderer(RendererClient* client,
67 const RendererSettings* settings, 65 const RendererSettings* settings,
68 OutputSurface* output_surface, 66 OutputSurface* output_surface,
69 ResourceProvider* resource_provider, 67 ResourceProvider* resource_provider)
70 bool use_image_hijack_canvas)
71 : DirectRenderer(client, settings, output_surface, resource_provider), 68 : DirectRenderer(client, settings, output_surface, resource_provider),
72 is_scissor_enabled_(false), 69 is_scissor_enabled_(false),
73 is_backbuffer_discarded_(false), 70 is_backbuffer_discarded_(false),
74 output_device_(output_surface->software_device()), 71 output_device_(output_surface->software_device()),
75 current_canvas_(nullptr), 72 current_canvas_(nullptr) {
76 use_image_hijack_canvas_(use_image_hijack_canvas) {
77 if (resource_provider_) { 73 if (resource_provider_) {
78 capabilities_.max_texture_size = resource_provider_->max_texture_size(); 74 capabilities_.max_texture_size = resource_provider_->max_texture_size();
79 capabilities_.best_texture_format = 75 capabilities_.best_texture_format =
80 resource_provider_->best_texture_format(); 76 resource_provider_->best_texture_format();
81 } 77 }
82 // The updater can access bitmaps while the SoftwareRenderer is using them. 78 // The updater can access bitmaps while the SoftwareRenderer is using them.
83 capabilities_.allow_partial_texture_updates = true; 79 capabilities_.allow_partial_texture_updates = true;
84 capabilities_.using_partial_swap = true; 80 capabilities_.using_partial_swap = true;
85 81
86 capabilities_.using_shared_memory_resources = true; 82 capabilities_.using_shared_memory_resources = true;
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 SkMatrix content_matrix; 355 SkMatrix content_matrix;
360 content_matrix.setRectToRect( 356 content_matrix.setRectToRect(
361 gfx::RectFToSkRect(quad->tex_coord_rect), 357 gfx::RectFToSkRect(quad->tex_coord_rect),
362 gfx::RectFToSkRect(QuadVertexRect()), 358 gfx::RectFToSkRect(QuadVertexRect()),
363 SkMatrix::kFill_ScaleToFit); 359 SkMatrix::kFill_ScaleToFit);
364 current_canvas_->concat(content_matrix); 360 current_canvas_->concat(content_matrix);
365 361
366 const bool needs_transparency = 362 const bool needs_transparency =
367 SkScalarRoundToInt(quad->shared_quad_state->opacity * 255) < 255; 363 SkScalarRoundToInt(quad->shared_quad_state->opacity * 255) < 255;
368 const bool disable_image_filtering = 364 const bool disable_image_filtering =
369 frame->disable_picture_quad_image_filtering || quad->nearest_neighbor; 365 disable_picture_quad_image_filtering_ || quad->nearest_neighbor;
370 366
371 TRACE_EVENT0("cc", "SoftwareRenderer::DrawPictureQuad"); 367 TRACE_EVENT0("cc", "SoftwareRenderer::DrawPictureQuad");
372 368
373 RasterSource::PlaybackSettings playback_settings; 369 RasterSource::PlaybackSettings playback_settings;
374 playback_settings.playback_to_shared_canvas = true; 370 playback_settings.playback_to_shared_canvas = true;
375 playback_settings.use_image_hijack_canvas = use_image_hijack_canvas_; 371 // Indicates whether content rasterization should happen through an
372 // ImageHijackCanvas, which causes image decodes to be managed by an
373 // ImageDecodeController. PictureDrawQuads are used for resourceless software
374 // draws, while a GPU ImageDecodeController may be in use by the compositor
375 // providing the RasterSource. So we disable the image hijack canvas to avoid
376 // trying to use the GPU ImageDecodeController while doing a software draw.
377 playback_settings.use_image_hijack_canvas = false;
376 if (needs_transparency || disable_image_filtering) { 378 if (needs_transparency || disable_image_filtering) {
377 // TODO(aelias): This isn't correct in all cases. We should detect these 379 // TODO(aelias): This isn't correct in all cases. We should detect these
378 // cases and fall back to a persistent bitmap backing 380 // cases and fall back to a persistent bitmap backing
379 // (http://crbug.com/280374). 381 // (http://crbug.com/280374).
380 // TODO(vmpstr): Fold this canvas into playback and have raster source 382 // TODO(vmpstr): Fold this canvas into playback and have raster source
381 // accept a set of settings on playback that will determine which canvas to 383 // accept a set of settings on playback that will determine which canvas to
382 // apply. (http://crbug.com/594679) 384 // apply. (http://crbug.com/594679)
383 skia::OpacityFilterCanvas filtered_canvas(current_canvas_, 385 skia::OpacityFilterCanvas filtered_canvas(current_canvas_,
384 quad->shared_quad_state->opacity, 386 quad->shared_quad_state->opacity,
385 disable_image_filtering); 387 disable_image_filtering);
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 ApplyImageFilter(filter.get(), quad, backdrop_bitmap, nullptr); 752 ApplyImageFilter(filter.get(), quad, backdrop_bitmap, nullptr);
751 753
752 if (!filter_backdrop_image) 754 if (!filter_backdrop_image)
753 return nullptr; 755 return nullptr;
754 756
755 return filter_backdrop_image->makeShader(content_tile_mode, content_tile_mode, 757 return filter_backdrop_image->makeShader(content_tile_mode, content_tile_mode,
756 &filter_backdrop_transform); 758 &filter_backdrop_transform);
757 } 759 }
758 760
759 } // namespace cc 761 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/software_renderer.h ('k') | cc/output/software_renderer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698