| 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/test/fake_content_layer_client.h" |    5 #include "cc/test/fake_content_layer_client.h" | 
|    6  |    6  | 
|    7 #include "cc/playback/clip_display_item.h" |    7 #include "cc/playback/clip_display_item.h" | 
|    8 #include "cc/playback/display_item_list_settings.h" |    8 #include "cc/playback/display_item_list_settings.h" | 
|    9 #include "cc/playback/drawing_display_item.h" |    9 #include "cc/playback/drawing_display_item.h" | 
|   10 #include "cc/playback/transform_display_item.h" |   10 #include "cc/playback/transform_display_item.h" | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
|   28  |   28  | 
|   29 FakeContentLayerClient::FakeContentLayerClient() |   29 FakeContentLayerClient::FakeContentLayerClient() | 
|   30     : fill_with_nonsolid_color_(false), |   30     : fill_with_nonsolid_color_(false), | 
|   31       last_canvas_(nullptr), |   31       last_canvas_(nullptr), | 
|   32       last_painting_control_(PAINTING_BEHAVIOR_NORMAL), |   32       last_painting_control_(PAINTING_BEHAVIOR_NORMAL), | 
|   33       reported_memory_usage_(0) {} |   33       reported_memory_usage_(0) {} | 
|   34  |   34  | 
|   35 FakeContentLayerClient::~FakeContentLayerClient() { |   35 FakeContentLayerClient::~FakeContentLayerClient() { | 
|   36 } |   36 } | 
|   37  |   37  | 
|   38 void FakeContentLayerClient::PaintContents( |  | 
|   39     SkCanvas* canvas, |  | 
|   40     const gfx::Rect& paint_rect, |  | 
|   41     PaintingControlSetting painting_control) { |  | 
|   42   last_canvas_ = canvas; |  | 
|   43   last_painting_control_ = painting_control; |  | 
|   44  |  | 
|   45   canvas->clipRect(gfx::RectToSkRect(paint_rect)); |  | 
|   46   for (RectPaintVector::const_iterator it = draw_rects_.begin(); |  | 
|   47       it != draw_rects_.end(); ++it) { |  | 
|   48     const gfx::RectF& draw_rect = it->first; |  | 
|   49     const SkPaint& paint = it->second; |  | 
|   50     canvas->drawRect(gfx::RectFToSkRect(draw_rect), paint); |  | 
|   51   } |  | 
|   52  |  | 
|   53   for (ImageVector::const_iterator it = draw_images_.begin(); |  | 
|   54        it != draw_images_.end(); ++it) { |  | 
|   55     canvas->drawImage(it->image.get(), it->point.x(), it->point.y(), |  | 
|   56                       &it->paint); |  | 
|   57   } |  | 
|   58  |  | 
|   59   if (fill_with_nonsolid_color_) { |  | 
|   60     gfx::Rect draw_rect = paint_rect; |  | 
|   61     bool red = true; |  | 
|   62     while (!draw_rect.IsEmpty()) { |  | 
|   63       SkPaint paint; |  | 
|   64       paint.setColor(red ? SK_ColorRED : SK_ColorBLUE); |  | 
|   65       canvas->drawIRect(gfx::RectToSkIRect(draw_rect), paint); |  | 
|   66       draw_rect.Inset(1, 1); |  | 
|   67     } |  | 
|   68   } |  | 
|   69 } |  | 
|   70  |  | 
|   71 scoped_refptr<DisplayItemList> |   38 scoped_refptr<DisplayItemList> | 
|   72 FakeContentLayerClient::PaintContentsToDisplayList( |   39 FakeContentLayerClient::PaintContentsToDisplayList( | 
|   73     const gfx::Rect& clip, |   40     const gfx::Rect& clip, | 
|   74     PaintingControlSetting painting_control) { |   41     PaintingControlSetting painting_control) { | 
|   75   // Cached picture is used because unit tests expect to be able to |   42   // Cached picture is used because unit tests expect to be able to | 
|   76   // use GatherPixelRefs. |   43   // use GatherPixelRefs. | 
|   77   DisplayItemListSettings settings; |   44   DisplayItemListSettings settings; | 
|   78   settings.use_cached_picture = true; |   45   settings.use_cached_picture = true; | 
|   79   scoped_refptr<DisplayItemList> display_list = |   46   scoped_refptr<DisplayItemList> display_list = | 
|   80       DisplayItemList::Create(clip, settings); |   47       DisplayItemList::Create(clip, settings); | 
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  136   return display_list; |  103   return display_list; | 
|  137 } |  104 } | 
|  138  |  105  | 
|  139 bool FakeContentLayerClient::FillsBoundsCompletely() const { return false; } |  106 bool FakeContentLayerClient::FillsBoundsCompletely() const { return false; } | 
|  140  |  107  | 
|  141 size_t FakeContentLayerClient::GetApproximateUnsharedMemoryUsage() const { |  108 size_t FakeContentLayerClient::GetApproximateUnsharedMemoryUsage() const { | 
|  142   return reported_memory_usage_; |  109   return reported_memory_usage_; | 
|  143 } |  110 } | 
|  144  |  111  | 
|  145 }  // namespace cc |  112 }  // namespace cc | 
| OLD | NEW |