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