| OLD | NEW | 
|    1 // Copyright 2014 The Chromium Authors. All rights reserved. |    1 // Copyright 2014 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/raster/raster_source.h" |    5 #include "cc/raster/raster_source.h" | 
|    6  |    6  | 
|    7 #include <stddef.h> |    7 #include <stddef.h> | 
|    8  |    8  | 
|    9 #include "base/trace_event/trace_event.h" |    9 #include "base/trace_event/trace_event.h" | 
|   10 #include "cc/base/math_util.h" |   10 #include "cc/base/math_util.h" | 
| (...skipping 15 matching lines...) Expand all  Loading... | 
|   26     : display_list_(other->display_list_), |   26     : display_list_(other->display_list_), | 
|   27       painter_reported_memory_usage_(other->painter_reported_memory_usage_), |   27       painter_reported_memory_usage_(other->painter_reported_memory_usage_), | 
|   28       background_color_(other->background_color_), |   28       background_color_(other->background_color_), | 
|   29       requires_clear_(other->requires_clear_), |   29       requires_clear_(other->requires_clear_), | 
|   30       is_solid_color_(other->is_solid_color_), |   30       is_solid_color_(other->is_solid_color_), | 
|   31       solid_color_(other->solid_color_), |   31       solid_color_(other->solid_color_), | 
|   32       recorded_viewport_(other->recorded_viewport_), |   32       recorded_viewport_(other->recorded_viewport_), | 
|   33       size_(other->size_), |   33       size_(other->size_), | 
|   34       clear_canvas_with_debug_color_(other->clear_canvas_with_debug_color_), |   34       clear_canvas_with_debug_color_(other->clear_canvas_with_debug_color_), | 
|   35       slow_down_raster_scale_factor_for_debug_( |   35       slow_down_raster_scale_factor_for_debug_( | 
|   36           other->slow_down_raster_scale_factor_for_debug_) {} |   36           other->slow_down_raster_scale_factor_for_debug_), | 
 |   37       recording_scale_factor_(other->recording_scale_factor_) {} | 
|   37 RasterSource::~RasterSource() = default; |   38 RasterSource::~RasterSource() = default; | 
|   38  |   39  | 
|   39 void RasterSource::SetupCanvasForRaster( |   40 void RasterSource::SetupCanvasForRaster( | 
|   40     PaintCanvas* canvas, |   41     PaintCanvas* canvas, | 
|   41     const gfx::Rect& canvas_bitmap_rect, |   42     const gfx::Rect& canvas_bitmap_rect, | 
|   42     const gfx::Rect& canvas_playback_rect, |   43     const gfx::Rect& canvas_playback_rect, | 
|   43     const gfx::AxisTransform2d& raster_transform, |   44     const gfx::AxisTransform2d& raster_transform, | 
|   44     bool should_clear_canvas) const { |   45     bool should_clear_canvas) const { | 
|   45   canvas->translate(-canvas_bitmap_rect.x(), -canvas_bitmap_rect.y()); |   46   canvas->translate(-canvas_bitmap_rect.x(), -canvas_bitmap_rect.y()); | 
|   46   canvas->clipRect(gfx::RectToSkRect(canvas_playback_rect)); |   47   canvas->clipRect(gfx::RectToSkRect(canvas_playback_rect)); | 
|   47   canvas->translate(raster_transform.translation().x(), |   48   canvas->translate(raster_transform.translation().x(), | 
|   48                     raster_transform.translation().y()); |   49                     raster_transform.translation().y()); | 
|   49   canvas->scale(raster_transform.scale(), raster_transform.scale()); |   50   canvas->scale(raster_transform.scale() / recording_scale_factor_, | 
 |   51                 raster_transform.scale() / recording_scale_factor_); | 
|   50  |   52  | 
|   51   if (should_clear_canvas) |   53   if (should_clear_canvas) | 
|   52     ClearCanvasForPlayback(canvas); |   54     ClearCanvasForPlayback(canvas); | 
|   53 } |   55 } | 
|   54  |   56  | 
|   55 void RasterSource::PlaybackToCanvas( |   57 void RasterSource::PlaybackToCanvas( | 
|   56     SkCanvas* raster_canvas, |   58     SkCanvas* raster_canvas, | 
|   57     const gfx::ColorSpace& target_color_space, |   59     const gfx::ColorSpace& target_color_space, | 
|   58     const gfx::Rect& canvas_bitmap_rect, |   60     const gfx::Rect& canvas_bitmap_rect, | 
|   59     const gfx::Rect& canvas_playback_rect, |   61     const gfx::Rect& canvas_playback_rect, | 
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  179   if (!display_list_) |  181   if (!display_list_) | 
|  180     return 0; |  182     return 0; | 
|  181   return display_list_->BytesUsed() + painter_reported_memory_usage_; |  183   return display_list_->BytesUsed() + painter_reported_memory_usage_; | 
|  182 } |  184 } | 
|  183  |  185  | 
|  184 bool RasterSource::PerformSolidColorAnalysis(gfx::Rect layer_rect, |  186 bool RasterSource::PerformSolidColorAnalysis(gfx::Rect layer_rect, | 
|  185                                              SkColor* color) const { |  187                                              SkColor* color) const { | 
|  186   TRACE_EVENT0("cc", "RasterSource::PerformSolidColorAnalysis"); |  188   TRACE_EVENT0("cc", "RasterSource::PerformSolidColorAnalysis"); | 
|  187  |  189  | 
|  188   layer_rect.Intersect(gfx::Rect(size_)); |  190   layer_rect.Intersect(gfx::Rect(size_)); | 
 |  191   layer_rect = gfx::ScaleToRoundedRect(layer_rect, recording_scale_factor_); | 
|  189   return display_list_->GetColorIfSolidInRect(layer_rect, color); |  192   return display_list_->GetColorIfSolidInRect(layer_rect, color); | 
|  190 } |  193 } | 
|  191  |  194  | 
|  192 void RasterSource::GetDiscardableImagesInRect( |  195 void RasterSource::GetDiscardableImagesInRect( | 
|  193     const gfx::Rect& layer_rect, |  196     const gfx::Rect& layer_rect, | 
|  194     float contents_scale, |  197     float contents_scale, | 
|  195     const gfx::ColorSpace& target_color_space, |  198     const gfx::ColorSpace& target_color_space, | 
|  196     std::vector<DrawImage>* images) const { |  199     std::vector<DrawImage>* images) const { | 
|  197   DCHECK_EQ(0u, images->size()); |  200   DCHECK_EQ(0u, images->size()); | 
|  198   display_list_->discardable_image_map().GetDiscardableImagesInRect( |  201   display_list_->discardable_image_map().GetDiscardableImagesInRect( | 
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  249       use_lcd_text(true) {} |  252       use_lcd_text(true) {} | 
|  250  |  253  | 
|  251 RasterSource::PlaybackSettings::PlaybackSettings(const PlaybackSettings&) = |  254 RasterSource::PlaybackSettings::PlaybackSettings(const PlaybackSettings&) = | 
|  252     default; |  255     default; | 
|  253  |  256  | 
|  254 RasterSource::PlaybackSettings::PlaybackSettings(PlaybackSettings&&) = default; |  257 RasterSource::PlaybackSettings::PlaybackSettings(PlaybackSettings&&) = default; | 
|  255  |  258  | 
|  256 RasterSource::PlaybackSettings::~PlaybackSettings() = default; |  259 RasterSource::PlaybackSettings::~PlaybackSettings() = default; | 
|  257  |  260  | 
|  258 }  // namespace cc |  261 }  // namespace cc | 
| OLD | NEW |