| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/playback/display_item_list.h" | 5 #include "cc/playback/display_item_list.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( | 90 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( |
| 91 kVisualRect, recorder.finishRecordingAsPicture()); | 91 kVisualRect, recorder.finishRecordingAsPicture()); |
| 92 list->Finalize(); | 92 list->Finalize(); |
| 93 DrawDisplayList(pixels, layer_rect, list); | 93 DrawDisplayList(pixels, layer_rect, list); |
| 94 | 94 |
| 95 SkBitmap expected_bitmap; | 95 SkBitmap expected_bitmap; |
| 96 unsigned char expected_pixels[4 * 100 * 100] = {0}; | 96 unsigned char expected_pixels[4 * 100 * 100] = {0}; |
| 97 SkImageInfo info = | 97 SkImageInfo info = |
| 98 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); | 98 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); |
| 99 expected_bitmap.installPixels(info, expected_pixels, info.minRowBytes()); | 99 expected_bitmap.installPixels(info, expected_pixels, info.minRowBytes()); |
| 100 PaintCanvas expected_canvas(expected_bitmap); | 100 SkiaPaintCanvas expected_canvas(expected_bitmap); |
| 101 expected_canvas.clipRect(gfx::RectToSkRect(layer_rect)); | 101 expected_canvas.clipRect(gfx::RectToSkRect(layer_rect)); |
| 102 expected_canvas.drawRect( | 102 expected_canvas.drawRect( |
| 103 SkRect::MakeLTRB(0.f + offset.x(), 0.f + offset.y(), 60.f + offset.x(), | 103 SkRect::MakeLTRB(0.f + offset.x(), 0.f + offset.y(), 60.f + offset.x(), |
| 104 60.f + offset.y()), | 104 60.f + offset.y()), |
| 105 red_paint); | 105 red_paint); |
| 106 expected_canvas.drawRect( | 106 expected_canvas.drawRect( |
| 107 SkRect::MakeLTRB(50.f + offset.x(), 50.f + offset.y(), 75.f + offset.x(), | 107 SkRect::MakeLTRB(50.f + offset.x(), 50.f + offset.y(), 75.f + offset.x(), |
| 108 75.f + offset.y()), | 108 75.f + offset.y()), |
| 109 blue_flags); | 109 blue_flags); |
| 110 | 110 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 list->CreateAndAppendPairedEndItem<EndClipDisplayItem>(); | 146 list->CreateAndAppendPairedEndItem<EndClipDisplayItem>(); |
| 147 list->Finalize(); | 147 list->Finalize(); |
| 148 | 148 |
| 149 DrawDisplayList(pixels, layer_rect, list); | 149 DrawDisplayList(pixels, layer_rect, list); |
| 150 | 150 |
| 151 SkBitmap expected_bitmap; | 151 SkBitmap expected_bitmap; |
| 152 unsigned char expected_pixels[4 * 100 * 100] = {0}; | 152 unsigned char expected_pixels[4 * 100 * 100] = {0}; |
| 153 SkImageInfo info = | 153 SkImageInfo info = |
| 154 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); | 154 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); |
| 155 expected_bitmap.installPixels(info, expected_pixels, info.minRowBytes()); | 155 expected_bitmap.installPixels(info, expected_pixels, info.minRowBytes()); |
| 156 PaintCanvas expected_canvas(expected_bitmap); | 156 SkiaPaintCanvas expected_canvas(expected_bitmap); |
| 157 expected_canvas.clipRect(gfx::RectToSkRect(layer_rect)); | 157 expected_canvas.clipRect(gfx::RectToSkRect(layer_rect)); |
| 158 expected_canvas.drawRect( | 158 expected_canvas.drawRect( |
| 159 SkRect::MakeLTRB(0.f + first_offset.x(), 0.f + first_offset.y(), | 159 SkRect::MakeLTRB(0.f + first_offset.x(), 0.f + first_offset.y(), |
| 160 60.f + first_offset.x(), 60.f + first_offset.y()), | 160 60.f + first_offset.x(), 60.f + first_offset.y()), |
| 161 red_paint); | 161 red_paint); |
| 162 expected_canvas.clipRect(gfx::RectToSkRect(clip_rect)); | 162 expected_canvas.clipRect(gfx::RectToSkRect(clip_rect)); |
| 163 expected_canvas.drawRect( | 163 expected_canvas.drawRect( |
| 164 SkRect::MakeLTRB(50.f + second_offset.x(), 50.f + second_offset.y(), | 164 SkRect::MakeLTRB(50.f + second_offset.x(), 50.f + second_offset.y(), |
| 165 75.f + second_offset.x(), 75.f + second_offset.y()), | 165 75.f + second_offset.x(), 75.f + second_offset.y()), |
| 166 blue_flags); | 166 blue_flags); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 list->CreateAndAppendPairedEndItem<EndTransformDisplayItem>(); | 203 list->CreateAndAppendPairedEndItem<EndTransformDisplayItem>(); |
| 204 list->Finalize(); | 204 list->Finalize(); |
| 205 | 205 |
| 206 DrawDisplayList(pixels, layer_rect, list); | 206 DrawDisplayList(pixels, layer_rect, list); |
| 207 | 207 |
| 208 SkBitmap expected_bitmap; | 208 SkBitmap expected_bitmap; |
| 209 unsigned char expected_pixels[4 * 100 * 100] = {0}; | 209 unsigned char expected_pixels[4 * 100 * 100] = {0}; |
| 210 SkImageInfo info = | 210 SkImageInfo info = |
| 211 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); | 211 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); |
| 212 expected_bitmap.installPixels(info, expected_pixels, info.minRowBytes()); | 212 expected_bitmap.installPixels(info, expected_pixels, info.minRowBytes()); |
| 213 PaintCanvas expected_canvas(expected_bitmap); | 213 SkiaPaintCanvas expected_canvas(expected_bitmap); |
| 214 expected_canvas.clipRect(gfx::RectToSkRect(layer_rect)); | 214 expected_canvas.clipRect(gfx::RectToSkRect(layer_rect)); |
| 215 expected_canvas.drawRect( | 215 expected_canvas.drawRect( |
| 216 SkRect::MakeLTRB(0.f + first_offset.x(), 0.f + first_offset.y(), | 216 SkRect::MakeLTRB(0.f + first_offset.x(), 0.f + first_offset.y(), |
| 217 60.f + first_offset.x(), 60.f + first_offset.y()), | 217 60.f + first_offset.x(), 60.f + first_offset.y()), |
| 218 red_paint); | 218 red_paint); |
| 219 expected_canvas.setMatrix(transform.matrix()); | 219 expected_canvas.setMatrix(transform.matrix()); |
| 220 expected_canvas.drawRect( | 220 expected_canvas.drawRect( |
| 221 SkRect::MakeLTRB(50.f + second_offset.x(), 50.f + second_offset.y(), | 221 SkRect::MakeLTRB(50.f + second_offset.x(), 50.f + second_offset.y(), |
| 222 75.f + second_offset.x(), 75.f + second_offset.y()), | 222 75.f + second_offset.x(), 75.f + second_offset.y()), |
| 223 blue_flags); | 223 blue_flags); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 | 276 |
| 277 DrawDisplayList(pixels, layer_rect, list); | 277 DrawDisplayList(pixels, layer_rect, list); |
| 278 | 278 |
| 279 SkBitmap expected_bitmap; | 279 SkBitmap expected_bitmap; |
| 280 unsigned char expected_pixels[4 * 100 * 100] = {0}; | 280 unsigned char expected_pixels[4 * 100 * 100] = {0}; |
| 281 PaintFlags paint; | 281 PaintFlags paint; |
| 282 paint.setColor(SkColorSetRGB(64, 64, 64)); | 282 paint.setColor(SkColorSetRGB(64, 64, 64)); |
| 283 SkImageInfo info = | 283 SkImageInfo info = |
| 284 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); | 284 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); |
| 285 expected_bitmap.installPixels(info, expected_pixels, info.minRowBytes()); | 285 expected_bitmap.installPixels(info, expected_pixels, info.minRowBytes()); |
| 286 PaintCanvas expected_canvas(expected_bitmap); | 286 SkiaPaintCanvas expected_canvas(expected_bitmap); |
| 287 expected_canvas.drawRect(RectFToSkRect(filter_bounds), paint); | 287 expected_canvas.drawRect(RectFToSkRect(filter_bounds), paint); |
| 288 | 288 |
| 289 EXPECT_EQ(0, memcmp(pixels, expected_pixels, 4 * 100 * 100)); | 289 EXPECT_EQ(0, memcmp(pixels, expected_pixels, 4 * 100 * 100)); |
| 290 } | 290 } |
| 291 | 291 |
| 292 TEST(DisplayItemListTest, ApproximateMemoryUsage) { | 292 TEST(DisplayItemListTest, ApproximateMemoryUsage) { |
| 293 const int kNumCommandsInTestSkPicture = 1000; | 293 const int kNumCommandsInTestSkPicture = 1000; |
| 294 size_t memory_usage; | 294 size_t memory_usage; |
| 295 | 295 |
| 296 // Make an PaintRecord whose size is known. | 296 // Make an PaintRecord whose size is known. |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 list->CreateAndAppendPairedEndItem<EndClipDisplayItem>(); | 670 list->CreateAndAppendPairedEndItem<EndClipDisplayItem>(); |
| 671 | 671 |
| 672 EXPECT_EQ(4u, list->size()); | 672 EXPECT_EQ(4u, list->size()); |
| 673 EXPECT_RECT_EQ(filter_bounds, list->VisualRectForTesting(0)); | 673 EXPECT_RECT_EQ(filter_bounds, list->VisualRectForTesting(0)); |
| 674 EXPECT_RECT_EQ(filter_bounds, list->VisualRectForTesting(1)); | 674 EXPECT_RECT_EQ(filter_bounds, list->VisualRectForTesting(1)); |
| 675 EXPECT_RECT_EQ(filter_bounds, list->VisualRectForTesting(2)); | 675 EXPECT_RECT_EQ(filter_bounds, list->VisualRectForTesting(2)); |
| 676 EXPECT_RECT_EQ(filter_bounds, list->VisualRectForTesting(3)); | 676 EXPECT_RECT_EQ(filter_bounds, list->VisualRectForTesting(3)); |
| 677 } | 677 } |
| 678 | 678 |
| 679 } // namespace cc | 679 } // namespace cc |
| OLD | NEW |