| 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/paint/clip_display_item.h" | 9 #include "cc/paint/clip_display_item.h" |
| 10 #include "cc/paint/drawing_display_item.h" | 10 #include "cc/paint/drawing_display_item.h" |
| 11 #include "cc/paint/paint_canvas.h" | 11 #include "cc/paint/paint_canvas.h" |
| 12 #include "cc/paint/paint_recorder.h" | 12 #include "cc/paint/paint_recorder.h" |
| 13 #include "cc/paint/transform_display_item.h" | 13 #include "cc/paint/transform_display_item.h" |
| 14 #include "ui/gfx/geometry/rect_conversions.h" | 14 #include "ui/gfx/geometry/rect_conversions.h" |
| 15 #include "ui/gfx/skia_util.h" | 15 #include "ui/gfx/skia_util.h" |
| 16 | 16 |
| 17 namespace cc { | 17 namespace cc { |
| 18 | 18 |
| 19 FakeContentLayerClient::ImageData::ImageData(sk_sp<SkImage> img, | 19 FakeContentLayerClient::ImageData::ImageData(PaintImage img, |
| 20 const gfx::Point& point, | 20 const gfx::Point& point, |
| 21 const PaintFlags& flags) | 21 const PaintFlags& flags) |
| 22 : image(std::move(img)), point(point), flags(flags) {} | 22 : image(std::move(img)), point(point), flags(flags) {} |
| 23 | 23 |
| 24 FakeContentLayerClient::ImageData::ImageData(sk_sp<SkImage> img, | 24 FakeContentLayerClient::ImageData::ImageData(PaintImage img, |
| 25 const gfx::Transform& transform, | 25 const gfx::Transform& transform, |
| 26 const PaintFlags& flags) | 26 const PaintFlags& flags) |
| 27 : image(std::move(img)), transform(transform), flags(flags) {} | 27 : image(std::move(img)), transform(transform), flags(flags) {} |
| 28 | 28 |
| 29 FakeContentLayerClient::ImageData::ImageData(const ImageData& other) = default; | 29 FakeContentLayerClient::ImageData::ImageData(const ImageData& other) = default; |
| 30 | 30 |
| 31 FakeContentLayerClient::ImageData::~ImageData() {} | 31 FakeContentLayerClient::ImageData::~ImageData() {} |
| 32 | 32 |
| 33 FakeContentLayerClient::FakeContentLayerClient() | 33 FakeContentLayerClient::FakeContentLayerClient() |
| 34 : fill_with_nonsolid_color_(false), | 34 : fill_with_nonsolid_color_(false), |
| (...skipping 27 matching lines...) Expand all Loading... |
| 62 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>( | 62 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>( |
| 63 ToEnclosingRect(draw_rect), recorder.finishRecordingAsPicture()); | 63 ToEnclosingRect(draw_rect), recorder.finishRecordingAsPicture()); |
| 64 } | 64 } |
| 65 | 65 |
| 66 for (ImageVector::const_iterator it = draw_images_.begin(); | 66 for (ImageVector::const_iterator it = draw_images_.begin(); |
| 67 it != draw_images_.end(); ++it) { | 67 it != draw_images_.end(); ++it) { |
| 68 if (!it->transform.IsIdentity()) { | 68 if (!it->transform.IsIdentity()) { |
| 69 display_list->CreateAndAppendPairedBeginItem<TransformDisplayItem>( | 69 display_list->CreateAndAppendPairedBeginItem<TransformDisplayItem>( |
| 70 it->transform); | 70 it->transform); |
| 71 } | 71 } |
| 72 PaintCanvas* canvas = | 72 PaintCanvas* canvas = recorder.beginRecording( |
| 73 recorder.beginRecording(it->image->width(), it->image->height()); | 73 it->image.sk_image()->width(), it->image.sk_image()->height()); |
| 74 canvas->drawImage(PaintImage(PaintImage::GetNextId(), it->image), | 74 canvas->drawImage(it->image, it->point.x(), it->point.y(), &it->flags); |
| 75 it->point.x(), it->point.y(), &it->flags); | |
| 76 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>( | 75 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>( |
| 77 PaintableRegion(), recorder.finishRecordingAsPicture()); | 76 PaintableRegion(), recorder.finishRecordingAsPicture()); |
| 78 if (!it->transform.IsIdentity()) { | 77 if (!it->transform.IsIdentity()) { |
| 79 display_list->CreateAndAppendPairedEndItem<EndTransformDisplayItem>(); | 78 display_list->CreateAndAppendPairedEndItem<EndTransformDisplayItem>(); |
| 80 } | 79 } |
| 81 } | 80 } |
| 82 | 81 |
| 83 if (fill_with_nonsolid_color_) { | 82 if (fill_with_nonsolid_color_) { |
| 84 gfx::Rect draw_rect = PaintableRegion(); | 83 gfx::Rect draw_rect = PaintableRegion(); |
| 85 bool red = true; | 84 bool red = true; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 99 return display_list; | 98 return display_list; |
| 100 } | 99 } |
| 101 | 100 |
| 102 bool FakeContentLayerClient::FillsBoundsCompletely() const { return false; } | 101 bool FakeContentLayerClient::FillsBoundsCompletely() const { return false; } |
| 103 | 102 |
| 104 size_t FakeContentLayerClient::GetApproximateUnsharedMemoryUsage() const { | 103 size_t FakeContentLayerClient::GetApproximateUnsharedMemoryUsage() const { |
| 105 return reported_memory_usage_; | 104 return reported_memory_usage_; |
| 106 } | 105 } |
| 107 | 106 |
| 108 } // namespace cc | 107 } // namespace cc |
| OLD | NEW |