| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_display_list_raster_source.h" | 5 #include "cc/test/fake_display_list_raster_source.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
| 10 #include "cc/test/fake_display_list_recording_source.h" | 10 #include "cc/test/fake_display_list_recording_source.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "ui/gfx/geometry/size.h" | 12 #include "ui/gfx/geometry/size.h" |
| 13 | 13 |
| 14 namespace cc { | 14 namespace cc { |
| 15 | 15 |
| 16 scoped_refptr<FakeDisplayListRasterSource> | 16 scoped_refptr<FakeDisplayListRasterSource> |
| 17 FakeDisplayListRasterSource::CreateInfiniteFilled() { | 17 FakeDisplayListRasterSource::CreateInfiniteFilled() { |
| 18 gfx::Size size(std::numeric_limits<int>::max() / 10, | 18 gfx::Size size(std::numeric_limits<int>::max() / 10, |
| 19 std::numeric_limits<int>::max() / 10); | 19 std::numeric_limits<int>::max() / 10); |
| 20 return CreateFilled(size); | 20 return CreateFilled(size); |
| 21 } | 21 } |
| 22 | 22 |
| 23 scoped_refptr<FakeDisplayListRasterSource> | 23 scoped_refptr<FakeDisplayListRasterSource> |
| 24 FakeDisplayListRasterSource::CreateFilled(const gfx::Size& size) { | 24 FakeDisplayListRasterSource::CreateFilled(const gfx::Size& size) { |
| 25 auto recording_source = | 25 auto recording_source = |
| 26 FakeDisplayListRecordingSource::CreateFilledRecordingSource(size); | 26 FakeDisplayListRecordingSource::CreateFilledRecordingSource(size); |
| 27 | 27 |
| 28 SkPaint red_paint; | 28 SkPaint salmon_pink_paint; |
| 29 red_paint.setColor(SK_ColorRED); | 29 salmon_pink_paint.setColor(SK_ColorRED); |
| 30 recording_source->add_draw_rect_with_paint(gfx::Rect(size), red_paint); | 30 // Set an arbitrary non-opaque alpha in order to force the source non-solid. |
| 31 | 31 // There are a number of ways to ensure the raster source is not solid. This |
| 32 gfx::Size smaller_size(size.width() - 10, size.height() - 10); | 32 // is just one of them. |
| 33 SkPaint green_paint; | 33 salmon_pink_paint.setAlpha(127); |
| 34 green_paint.setColor(SK_ColorGREEN); | 34 recording_source->add_draw_rect_with_paint(gfx::Rect(size), |
| 35 recording_source->add_draw_rect_with_paint(gfx::Rect(smaller_size), | 35 salmon_pink_paint); |
| 36 green_paint); | |
| 37 | 36 |
| 38 recording_source->Rerecord(); | 37 recording_source->Rerecord(); |
| 39 | 38 |
| 40 return make_scoped_refptr( | 39 return make_scoped_refptr( |
| 41 new FakeDisplayListRasterSource(recording_source.get(), false)); | 40 new FakeDisplayListRasterSource(recording_source.get(), false)); |
| 42 } | 41 } |
| 43 | 42 |
| 44 scoped_refptr<FakeDisplayListRasterSource> | 43 scoped_refptr<FakeDisplayListRasterSource> |
| 45 FakeDisplayListRasterSource::CreateFilledLCD(const gfx::Size& size) { | 44 FakeDisplayListRasterSource::CreateFilledLCD(const gfx::Size& size) { |
| 46 auto recording_source = | 45 auto recording_source = |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 float contents_scale, | 150 float contents_scale, |
| 152 bool include_images) const { | 151 bool include_images) const { |
| 153 if (playback_allowed_event_) | 152 if (playback_allowed_event_) |
| 154 playback_allowed_event_->Wait(); | 153 playback_allowed_event_->Wait(); |
| 155 DisplayListRasterSource::PlaybackToCanvas(canvas, canvas_bitmap_rect, | 154 DisplayListRasterSource::PlaybackToCanvas(canvas, canvas_bitmap_rect, |
| 156 canvas_playback_rect, | 155 canvas_playback_rect, |
| 157 contents_scale, include_images); | 156 contents_scale, include_images); |
| 158 } | 157 } |
| 159 | 158 |
| 160 } // namespace cc | 159 } // namespace cc |
| OLD | NEW |