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/copy_output_request.h" | 10 #include "cc/output/copy_output_request.h" |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 SkMatrix::kFill_ScaleToFit); | 329 SkMatrix::kFill_ScaleToFit); |
330 current_canvas_->concat(content_matrix); | 330 current_canvas_->concat(content_matrix); |
331 | 331 |
332 const bool needs_transparency = | 332 const bool needs_transparency = |
333 SkScalarRoundToInt(quad->shared_quad_state->opacity * 255) < 255; | 333 SkScalarRoundToInt(quad->shared_quad_state->opacity * 255) < 255; |
334 const bool disable_image_filtering = | 334 const bool disable_image_filtering = |
335 disable_picture_quad_image_filtering_ || quad->nearest_neighbor; | 335 disable_picture_quad_image_filtering_ || quad->nearest_neighbor; |
336 | 336 |
337 TRACE_EVENT0("cc", "SoftwareRenderer::DrawPictureQuad"); | 337 TRACE_EVENT0("cc", "SoftwareRenderer::DrawPictureQuad"); |
338 | 338 |
| 339 // TODO(ccameron): Determine a color space strategy for software rendering. |
| 340 gfx::ColorSpace canvas_color_space; |
| 341 if (settings_->enable_color_correct_rendering) |
| 342 canvas_color_space = gfx::ColorSpace::CreateSRGB(); |
| 343 |
339 RasterSource::PlaybackSettings playback_settings; | 344 RasterSource::PlaybackSettings playback_settings; |
340 playback_settings.playback_to_shared_canvas = true; | 345 playback_settings.playback_to_shared_canvas = true; |
341 // Indicates whether content rasterization should happen through an | 346 // Indicates whether content rasterization should happen through an |
342 // ImageHijackCanvas, which causes image decodes to be managed by an | 347 // ImageHijackCanvas, which causes image decodes to be managed by an |
343 // ImageDecodeCache. PictureDrawQuads are used for resourceless software | 348 // ImageDecodeCache. PictureDrawQuads are used for resourceless software |
344 // draws, while a GPU ImageDecodeCache may be in use by the compositor | 349 // draws, while a GPU ImageDecodeCache may be in use by the compositor |
345 // providing the RasterSource. So we disable the image hijack canvas to avoid | 350 // providing the RasterSource. So we disable the image hijack canvas to avoid |
346 // trying to use the GPU ImageDecodeCache while doing a software draw. | 351 // trying to use the GPU ImageDecodeCache while doing a software draw. |
347 playback_settings.use_image_hijack_canvas = false; | 352 playback_settings.use_image_hijack_canvas = false; |
348 if (needs_transparency || disable_image_filtering) { | 353 if (needs_transparency || disable_image_filtering) { |
349 // TODO(aelias): This isn't correct in all cases. We should detect these | 354 // TODO(aelias): This isn't correct in all cases. We should detect these |
350 // cases and fall back to a persistent bitmap backing | 355 // cases and fall back to a persistent bitmap backing |
351 // (http://crbug.com/280374). | 356 // (http://crbug.com/280374). |
352 // TODO(vmpstr): Fold this canvas into playback and have raster source | 357 // TODO(vmpstr): Fold this canvas into playback and have raster source |
353 // accept a set of settings on playback that will determine which canvas to | 358 // accept a set of settings on playback that will determine which canvas to |
354 // apply. (http://crbug.com/594679) | 359 // apply. (http://crbug.com/594679) |
355 skia::OpacityFilterCanvas filtered_canvas(current_canvas_, | 360 skia::OpacityFilterCanvas filtered_canvas(current_canvas_, |
356 quad->shared_quad_state->opacity, | 361 quad->shared_quad_state->opacity, |
357 disable_image_filtering); | 362 disable_image_filtering); |
358 quad->raster_source->PlaybackToCanvas( | 363 quad->raster_source->PlaybackToCanvas( |
359 &filtered_canvas, quad->content_rect, quad->content_rect, | 364 &filtered_canvas, canvas_color_space, quad->content_rect, |
360 quad->contents_scale, playback_settings); | 365 quad->content_rect, quad->contents_scale, playback_settings); |
361 } else { | 366 } else { |
362 quad->raster_source->PlaybackToCanvas( | 367 quad->raster_source->PlaybackToCanvas( |
363 current_canvas_, quad->content_rect, quad->content_rect, | 368 current_canvas_, canvas_color_space, quad->content_rect, |
364 quad->contents_scale, playback_settings); | 369 quad->content_rect, quad->contents_scale, playback_settings); |
365 } | 370 } |
366 } | 371 } |
367 | 372 |
368 void SoftwareRenderer::DrawSolidColorQuad(const SolidColorDrawQuad* quad) { | 373 void SoftwareRenderer::DrawSolidColorQuad(const SolidColorDrawQuad* quad) { |
369 gfx::RectF visible_quad_vertex_rect = MathUtil::ScaleRectProportional( | 374 gfx::RectF visible_quad_vertex_rect = MathUtil::ScaleRectProportional( |
370 QuadVertexRect(), gfx::RectF(quad->rect), gfx::RectF(quad->visible_rect)); | 375 QuadVertexRect(), gfx::RectF(quad->rect), gfx::RectF(quad->visible_rect)); |
371 current_paint_.setColor(quad->color); | 376 current_paint_.setColor(quad->color); |
372 current_paint_.setAlpha(quad->shared_quad_state->opacity * | 377 current_paint_.setAlpha(quad->shared_quad_state->opacity * |
373 SkColorGetA(quad->color)); | 378 SkColorGetA(quad->color)); |
374 current_canvas_->drawRect(gfx::RectFToSkRect(visible_quad_vertex_rect), | 379 current_canvas_->drawRect(gfx::RectFToSkRect(visible_quad_vertex_rect), |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
714 ApplyImageFilter(filter.get(), quad, backdrop_bitmap, nullptr); | 719 ApplyImageFilter(filter.get(), quad, backdrop_bitmap, nullptr); |
715 | 720 |
716 if (!filter_backdrop_image) | 721 if (!filter_backdrop_image) |
717 return nullptr; | 722 return nullptr; |
718 | 723 |
719 return filter_backdrop_image->makeShader(content_tile_mode, content_tile_mode, | 724 return filter_backdrop_image->makeShader(content_tile_mode, content_tile_mode, |
720 &filter_backdrop_transform); | 725 &filter_backdrop_transform); |
721 } | 726 } |
722 | 727 |
723 } // namespace cc | 728 } // namespace cc |
OLD | NEW |