| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "cc/playback/clip_display_item.h" | 9 #include "cc/playback/clip_display_item.h" |
| 10 #include "cc/playback/display_item_list_settings.h" | 10 #include "cc/playback/display_item_list_settings.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 FakeContentLayerClient::PaintContentsToDisplayList( | 51 FakeContentLayerClient::PaintContentsToDisplayList( |
| 52 PaintingControlSetting painting_control) { | 52 PaintingControlSetting painting_control) { |
| 53 // Cached picture is used because unit tests expect to be able to | 53 // Cached picture is used because unit tests expect to be able to |
| 54 // use GatherPixelRefs. | 54 // use GatherPixelRefs. |
| 55 DisplayItemListSettings settings; | 55 DisplayItemListSettings settings; |
| 56 settings.use_cached_picture = display_list_use_cached_picture_; | 56 settings.use_cached_picture = display_list_use_cached_picture_; |
| 57 scoped_refptr<DisplayItemList> display_list = | 57 scoped_refptr<DisplayItemList> display_list = |
| 58 DisplayItemList::Create(settings); | 58 DisplayItemList::Create(settings); |
| 59 display_list->SetRetainVisualRectsForTesting(true); | 59 display_list->SetRetainVisualRectsForTesting(true); |
| 60 SkPictureRecorder recorder; | 60 SkPictureRecorder recorder; |
| 61 sk_sp<SkCanvas> canvas; | |
| 62 | 61 |
| 63 for (RectPaintVector::const_iterator it = draw_rects_.begin(); | 62 for (RectPaintVector::const_iterator it = draw_rects_.begin(); |
| 64 it != draw_rects_.end(); ++it) { | 63 it != draw_rects_.end(); ++it) { |
| 65 const gfx::RectF& draw_rect = it->first; | 64 const gfx::RectF& draw_rect = it->first; |
| 66 const SkPaint& paint = it->second; | 65 const SkPaint& paint = it->second; |
| 67 canvas = sk_ref_sp(recorder.beginRecording(gfx::RectFToSkRect(draw_rect))); | 66 SkCanvas* canvas = recorder.beginRecording(gfx::RectFToSkRect(draw_rect)); |
| 68 canvas->drawRect(gfx::RectFToSkRect(draw_rect), paint); | 67 canvas->drawRect(gfx::RectFToSkRect(draw_rect), paint); |
| 69 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>( | 68 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>( |
| 70 ToEnclosingRect(draw_rect), recorder.finishRecordingAsPicture()); | 69 ToEnclosingRect(draw_rect), recorder.finishRecordingAsPicture()); |
| 71 } | 70 } |
| 72 | 71 |
| 73 for (ImageVector::const_iterator it = draw_images_.begin(); | 72 for (ImageVector::const_iterator it = draw_images_.begin(); |
| 74 it != draw_images_.end(); ++it) { | 73 it != draw_images_.end(); ++it) { |
| 75 if (!it->transform.IsIdentity()) { | 74 if (!it->transform.IsIdentity()) { |
| 76 display_list->CreateAndAppendPairedBeginItem<TransformDisplayItem>( | 75 display_list->CreateAndAppendPairedBeginItem<TransformDisplayItem>( |
| 77 it->transform); | 76 it->transform); |
| 78 } | 77 } |
| 79 canvas = sk_ref_sp( | 78 SkCanvas* canvas = |
| 80 recorder.beginRecording(it->image->width(), it->image->height())); | 79 recorder.beginRecording(it->image->width(), it->image->height()); |
| 81 canvas->drawImage(it->image.get(), it->point.x(), it->point.y(), | 80 canvas->drawImage(it->image.get(), it->point.x(), it->point.y(), |
| 82 &it->paint); | 81 &it->paint); |
| 83 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>( | 82 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>( |
| 84 PaintableRegion(), recorder.finishRecordingAsPicture()); | 83 PaintableRegion(), recorder.finishRecordingAsPicture()); |
| 85 if (!it->transform.IsIdentity()) { | 84 if (!it->transform.IsIdentity()) { |
| 86 display_list->CreateAndAppendPairedEndItem<EndTransformDisplayItem>(); | 85 display_list->CreateAndAppendPairedEndItem<EndTransformDisplayItem>(); |
| 87 } | 86 } |
| 88 } | 87 } |
| 89 | 88 |
| 90 if (fill_with_nonsolid_color_) { | 89 if (fill_with_nonsolid_color_) { |
| 91 gfx::Rect draw_rect = PaintableRegion(); | 90 gfx::Rect draw_rect = PaintableRegion(); |
| 92 bool red = true; | 91 bool red = true; |
| 93 while (!draw_rect.IsEmpty()) { | 92 while (!draw_rect.IsEmpty()) { |
| 94 SkPaint paint; | 93 SkPaint paint; |
| 95 paint.setColor(red ? SK_ColorRED : SK_ColorBLUE); | 94 paint.setColor(red ? SK_ColorRED : SK_ColorBLUE); |
| 96 canvas = sk_ref_sp(recorder.beginRecording(gfx::RectToSkRect(draw_rect))); | 95 SkCanvas* canvas = recorder.beginRecording(gfx::RectToSkRect(draw_rect)); |
| 97 canvas->drawIRect(gfx::RectToSkIRect(draw_rect), paint); | 96 canvas->drawIRect(gfx::RectToSkIRect(draw_rect), paint); |
| 98 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>( | 97 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>( |
| 99 draw_rect, recorder.finishRecordingAsPicture()); | 98 draw_rect, recorder.finishRecordingAsPicture()); |
| 100 draw_rect.Inset(1, 1); | 99 draw_rect.Inset(1, 1); |
| 101 } | 100 } |
| 102 } | 101 } |
| 103 | 102 |
| 104 display_list->Finalize(); | 103 display_list->Finalize(); |
| 105 return display_list; | 104 return display_list; |
| 106 } | 105 } |
| 107 | 106 |
| 108 bool FakeContentLayerClient::FillsBoundsCompletely() const { return false; } | 107 bool FakeContentLayerClient::FillsBoundsCompletely() const { return false; } |
| 109 | 108 |
| 110 size_t FakeContentLayerClient::GetApproximateUnsharedMemoryUsage() const { | 109 size_t FakeContentLayerClient::GetApproximateUnsharedMemoryUsage() const { |
| 111 return reported_memory_usage_; | 110 return reported_memory_usage_; |
| 112 } | 111 } |
| 113 | 112 |
| 114 } // namespace cc | 113 } // namespace cc |
| OLD | NEW |