| OLD | NEW |
| 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 Loading... |
| 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) { |
| 60 return base::WrapUnique(new SoftwareRenderer(client, settings, output_surface, | 61 return base::WrapUnique(new SoftwareRenderer(client, settings, output_surface, |
| 61 resource_provider)); | 62 resource_provider, |
| 63 use_image_hijack_canvas)); |
| 62 } | 64 } |
| 63 | 65 |
| 64 SoftwareRenderer::SoftwareRenderer(RendererClient* client, | 66 SoftwareRenderer::SoftwareRenderer(RendererClient* client, |
| 65 const RendererSettings* settings, | 67 const RendererSettings* settings, |
| 66 OutputSurface* output_surface, | 68 OutputSurface* output_surface, |
| 67 ResourceProvider* resource_provider) | 69 ResourceProvider* resource_provider, |
| 70 bool use_image_hijack_canvas) |
| 68 : DirectRenderer(client, settings, output_surface, resource_provider), | 71 : DirectRenderer(client, settings, output_surface, resource_provider), |
| 69 is_scissor_enabled_(false), | 72 is_scissor_enabled_(false), |
| 70 is_backbuffer_discarded_(false), | 73 is_backbuffer_discarded_(false), |
| 71 output_device_(output_surface->software_device()), | 74 output_device_(output_surface->software_device()), |
| 72 current_canvas_(NULL) { | 75 current_canvas_(nullptr), |
| 76 use_image_hijack_canvas_(use_image_hijack_canvas) { |
| 73 if (resource_provider_) { | 77 if (resource_provider_) { |
| 74 capabilities_.max_texture_size = resource_provider_->max_texture_size(); | 78 capabilities_.max_texture_size = resource_provider_->max_texture_size(); |
| 75 capabilities_.best_texture_format = | 79 capabilities_.best_texture_format = |
| 76 resource_provider_->best_texture_format(); | 80 resource_provider_->best_texture_format(); |
| 77 } | 81 } |
| 78 // The updater can access bitmaps while the SoftwareRenderer is using them. | 82 // The updater can access bitmaps while the SoftwareRenderer is using them. |
| 79 capabilities_.allow_partial_texture_updates = true; | 83 capabilities_.allow_partial_texture_updates = true; |
| 80 capabilities_.using_partial_swap = true; | 84 capabilities_.using_partial_swap = true; |
| 81 | 85 |
| 82 capabilities_.using_shared_memory_resources = true; | 86 capabilities_.using_shared_memory_resources = true; |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 | 365 |
| 362 const bool needs_transparency = | 366 const bool needs_transparency = |
| 363 SkScalarRoundToInt(quad->shared_quad_state->opacity * 255) < 255; | 367 SkScalarRoundToInt(quad->shared_quad_state->opacity * 255) < 255; |
| 364 const bool disable_image_filtering = | 368 const bool disable_image_filtering = |
| 365 frame->disable_picture_quad_image_filtering || quad->nearest_neighbor; | 369 frame->disable_picture_quad_image_filtering || quad->nearest_neighbor; |
| 366 | 370 |
| 367 TRACE_EVENT0("cc", "SoftwareRenderer::DrawPictureQuad"); | 371 TRACE_EVENT0("cc", "SoftwareRenderer::DrawPictureQuad"); |
| 368 | 372 |
| 369 RasterSource::PlaybackSettings playback_settings; | 373 RasterSource::PlaybackSettings playback_settings; |
| 370 playback_settings.playback_to_shared_canvas = true; | 374 playback_settings.playback_to_shared_canvas = true; |
| 375 playback_settings.use_image_hijack_canvas = use_image_hijack_canvas_; |
| 371 if (needs_transparency || disable_image_filtering) { | 376 if (needs_transparency || disable_image_filtering) { |
| 372 // TODO(aelias): This isn't correct in all cases. We should detect these | 377 // TODO(aelias): This isn't correct in all cases. We should detect these |
| 373 // cases and fall back to a persistent bitmap backing | 378 // cases and fall back to a persistent bitmap backing |
| 374 // (http://crbug.com/280374). | 379 // (http://crbug.com/280374). |
| 375 // TODO(vmpstr): Fold this canvas into playback and have raster source | 380 // TODO(vmpstr): Fold this canvas into playback and have raster source |
| 376 // accept a set of settings on playback that will determine which canvas to | 381 // accept a set of settings on playback that will determine which canvas to |
| 377 // apply. (http://crbug.com/594679) | 382 // apply. (http://crbug.com/594679) |
| 378 skia::OpacityFilterCanvas filtered_canvas(current_canvas_, | 383 skia::OpacityFilterCanvas filtered_canvas(current_canvas_, |
| 379 quad->shared_quad_state->opacity, | 384 quad->shared_quad_state->opacity, |
| 380 disable_image_filtering); | 385 disable_image_filtering); |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 ApplyImageFilter(filter.get(), quad, backdrop_bitmap, nullptr); | 751 ApplyImageFilter(filter.get(), quad, backdrop_bitmap, nullptr); |
| 747 | 752 |
| 748 if (!filter_backdrop_image) | 753 if (!filter_backdrop_image) |
| 749 return nullptr; | 754 return nullptr; |
| 750 | 755 |
| 751 return filter_backdrop_image->makeShader(content_tile_mode, content_tile_mode, | 756 return filter_backdrop_image->makeShader(content_tile_mode, content_tile_mode, |
| 752 &filter_backdrop_transform); | 757 &filter_backdrop_transform); |
| 753 } | 758 } |
| 754 | 759 |
| 755 } // namespace cc | 760 } // namespace cc |
| OLD | NEW |