| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 skia::RefPtr<SkCanvas> canvas; | 60 skia::RefPtr<SkCanvas> canvas; |
| 61 | 61 |
| 62 for (RectPaintVector::const_iterator it = draw_rects_.begin(); | 62 for (RectPaintVector::const_iterator it = draw_rects_.begin(); |
| 63 it != draw_rects_.end(); ++it) { | 63 it != draw_rects_.end(); ++it) { |
| 64 const gfx::RectF& draw_rect = it->first; | 64 const gfx::RectF& draw_rect = it->first; |
| 65 const SkPaint& paint = it->second; | 65 const SkPaint& paint = it->second; |
| 66 canvas = | 66 canvas = |
| 67 skia::SharePtr(recorder.beginRecording(gfx::RectFToSkRect(draw_rect))); | 67 skia::SharePtr(recorder.beginRecording(gfx::RectFToSkRect(draw_rect))); |
| 68 canvas->drawRect(gfx::RectFToSkRect(draw_rect), paint); | 68 canvas->drawRect(gfx::RectFToSkRect(draw_rect), paint); |
| 69 display_list->CreateAndAppendItem<DrawingDisplayItem>( | 69 display_list->CreateAndAppendItem<DrawingDisplayItem>( |
| 70 ToEnclosingRect(draw_rect), | 70 ToEnclosingRect(draw_rect), recorder.finishRecordingAsPicture()); |
| 71 skia::AdoptRef(recorder.endRecordingAsPicture())); | |
| 72 } | 71 } |
| 73 | 72 |
| 74 for (ImageVector::const_iterator it = draw_images_.begin(); | 73 for (ImageVector::const_iterator it = draw_images_.begin(); |
| 75 it != draw_images_.end(); ++it) { | 74 it != draw_images_.end(); ++it) { |
| 76 if (!it->transform.IsIdentity()) { | 75 if (!it->transform.IsIdentity()) { |
| 77 display_list->CreateAndAppendItem<TransformDisplayItem>(PaintableRegion(), | 76 display_list->CreateAndAppendItem<TransformDisplayItem>(PaintableRegion(), |
| 78 it->transform); | 77 it->transform); |
| 79 } | 78 } |
| 80 canvas = skia::SharePtr( | 79 canvas = skia::SharePtr( |
| 81 recorder.beginRecording(it->image->width(), it->image->height())); | 80 recorder.beginRecording(it->image->width(), it->image->height())); |
| 82 canvas->drawImage(it->image.get(), it->point.x(), it->point.y(), | 81 canvas->drawImage(it->image.get(), it->point.x(), it->point.y(), |
| 83 &it->paint); | 82 &it->paint); |
| 84 display_list->CreateAndAppendItem<DrawingDisplayItem>( | 83 display_list->CreateAndAppendItem<DrawingDisplayItem>( |
| 85 PaintableRegion(), skia::AdoptRef(recorder.endRecordingAsPicture())); | 84 PaintableRegion(), recorder.finishRecordingAsPicture()); |
| 86 if (!it->transform.IsIdentity()) { | 85 if (!it->transform.IsIdentity()) { |
| 87 display_list->CreateAndAppendItem<EndTransformDisplayItem>( | 86 display_list->CreateAndAppendItem<EndTransformDisplayItem>( |
| 88 PaintableRegion()); | 87 PaintableRegion()); |
| 89 } | 88 } |
| 90 } | 89 } |
| 91 | 90 |
| 92 if (fill_with_nonsolid_color_) { | 91 if (fill_with_nonsolid_color_) { |
| 93 gfx::Rect draw_rect = PaintableRegion(); | 92 gfx::Rect draw_rect = PaintableRegion(); |
| 94 bool red = true; | 93 bool red = true; |
| 95 while (!draw_rect.IsEmpty()) { | 94 while (!draw_rect.IsEmpty()) { |
| 96 SkPaint paint; | 95 SkPaint paint; |
| 97 paint.setColor(red ? SK_ColorRED : SK_ColorBLUE); | 96 paint.setColor(red ? SK_ColorRED : SK_ColorBLUE); |
| 98 canvas = | 97 canvas = |
| 99 skia::SharePtr(recorder.beginRecording(gfx::RectToSkRect(draw_rect))); | 98 skia::SharePtr(recorder.beginRecording(gfx::RectToSkRect(draw_rect))); |
| 100 canvas->drawIRect(gfx::RectToSkIRect(draw_rect), paint); | 99 canvas->drawIRect(gfx::RectToSkIRect(draw_rect), paint); |
| 101 display_list->CreateAndAppendItem<DrawingDisplayItem>( | 100 display_list->CreateAndAppendItem<DrawingDisplayItem>( |
| 102 draw_rect, skia::AdoptRef(recorder.endRecordingAsPicture())); | 101 draw_rect, recorder.finishRecordingAsPicture()); |
| 103 draw_rect.Inset(1, 1); | 102 draw_rect.Inset(1, 1); |
| 104 } | 103 } |
| 105 } | 104 } |
| 106 | 105 |
| 107 | 106 |
| 108 display_list->Finalize(); | 107 display_list->Finalize(); |
| 109 return display_list; | 108 return display_list; |
| 110 } | 109 } |
| 111 | 110 |
| 112 bool FakeContentLayerClient::FillsBoundsCompletely() const { return false; } | 111 bool FakeContentLayerClient::FillsBoundsCompletely() const { return false; } |
| 113 | 112 |
| 114 size_t FakeContentLayerClient::GetApproximateUnsharedMemoryUsage() const { | 113 size_t FakeContentLayerClient::GetApproximateUnsharedMemoryUsage() const { |
| 115 return reported_memory_usage_; | 114 return reported_memory_usage_; |
| 116 } | 115 } |
| 117 | 116 |
| 118 } // namespace cc | 117 } // namespace cc |
| OLD | NEW |