Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: cc/resources/picture_unittest.cc

Issue 664583002: Remove obsolete SkRecord preview code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update r&r micro, and format Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/resources/picture.cc ('k') | cc/trees/layer_tree_settings.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/resources/picture.h" 5 #include "cc/resources/picture.h"
6 6
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "cc/test/fake_content_layer_client.h" 10 #include "cc/test/fake_content_layer_client.h"
(...skipping 27 matching lines...) Expand all
38 red_paint.setColor(SkColorSetARGB(255, 255, 0, 0)); 38 red_paint.setColor(SkColorSetARGB(255, 255, 0, 0));
39 SkPaint green_paint; 39 SkPaint green_paint;
40 green_paint.setColor(SkColorSetARGB(255, 0, 255, 0)); 40 green_paint.setColor(SkColorSetARGB(255, 0, 255, 0));
41 41
42 // Invalid picture (not a dict). 42 // Invalid picture (not a dict).
43 tmp.reset(new base::StringValue("abc!@#$%")); 43 tmp.reset(new base::StringValue("abc!@#$%"));
44 scoped_refptr<Picture> invalid_picture = 44 scoped_refptr<Picture> invalid_picture =
45 Picture::CreateFromValue(tmp.get()); 45 Picture::CreateFromValue(tmp.get());
46 EXPECT_FALSE(invalid_picture.get()); 46 EXPECT_FALSE(invalid_picture.get());
47 47
48 Picture::RecordingMode kRecordingModes[] = {Picture::RECORD_NORMALLY,
49 Picture::RECORD_WITH_SKRECORD};
50
51 // Single full-size rect picture. 48 // Single full-size rect picture.
52 content_layer_client.add_draw_rect(layer_rect, red_paint); 49 content_layer_client.add_draw_rect(layer_rect, red_paint);
53 50
54 for (size_t i = 0; i < arraysize(kRecordingModes); ++i) { 51 scoped_refptr<Picture> one_rect_picture =
55 scoped_refptr<Picture> one_rect_picture = 52 Picture::Create(layer_rect,
56 Picture::Create(layer_rect, 53 &content_layer_client,
57 &content_layer_client, 54 tile_grid_info,
58 tile_grid_info, 55 false,
59 false, 56 Picture::RECORD_NORMALLY);
60 kRecordingModes[i]); 57 scoped_ptr<base::Value> serialized_one_rect(one_rect_picture->AsValue());
61 scoped_ptr<base::Value> serialized_one_rect(one_rect_picture->AsValue());
62 58
63 // Reconstruct the picture. 59 // Reconstruct the picture.
64 scoped_refptr<Picture> one_rect_picture_check = 60 scoped_refptr<Picture> one_rect_picture_check =
65 Picture::CreateFromValue(serialized_one_rect.get()); 61 Picture::CreateFromValue(serialized_one_rect.get());
66 EXPECT_TRUE(!!one_rect_picture_check.get()); 62 EXPECT_TRUE(!!one_rect_picture_check.get());
67 63
68 // Check for equivalence. 64 // Check for equivalence.
69 unsigned char one_rect_buffer[4 * 100 * 100] = {0}; 65 unsigned char one_rect_buffer[4 * 100 * 100] = {0};
70 DrawPicture(one_rect_buffer, layer_rect, one_rect_picture); 66 DrawPicture(one_rect_buffer, layer_rect, one_rect_picture);
71 unsigned char one_rect_buffer_check[4 * 100 * 100] = {0}; 67 unsigned char one_rect_buffer_check[4 * 100 * 100] = {0};
72 DrawPicture(one_rect_buffer_check, layer_rect, one_rect_picture_check); 68 DrawPicture(one_rect_buffer_check, layer_rect, one_rect_picture_check);
73 69
74 EXPECT_EQ(one_rect_picture->LayerRect(), 70 EXPECT_EQ(one_rect_picture->LayerRect(), one_rect_picture_check->LayerRect());
75 one_rect_picture_check->LayerRect()); 71 EXPECT_EQ(0, memcmp(one_rect_buffer, one_rect_buffer_check, 4 * 100 * 100));
76 EXPECT_EQ(0, memcmp(one_rect_buffer, one_rect_buffer_check, 4 * 100 * 100));
77 }
78 72
79 // Two rect picture. 73 // Two rect picture.
80 content_layer_client.add_draw_rect(gfx::Rect(25, 25, 50, 50), green_paint); 74 content_layer_client.add_draw_rect(gfx::Rect(25, 25, 50, 50), green_paint);
81 75
82 for (size_t i = 0; i < arraysize(kRecordingModes); ++i) { 76 scoped_refptr<Picture> two_rect_picture =
83 scoped_refptr<Picture> two_rect_picture = 77 Picture::Create(layer_rect,
84 Picture::Create(layer_rect, 78 &content_layer_client,
85 &content_layer_client, 79 tile_grid_info,
86 tile_grid_info, 80 false,
87 false, 81 Picture::RECORD_NORMALLY);
88 Picture::RECORD_NORMALLY);
89 82
90 scoped_ptr<base::Value> serialized_two_rect(two_rect_picture->AsValue()); 83 scoped_ptr<base::Value> serialized_two_rect(two_rect_picture->AsValue());
91 84
92 // Reconstruct the picture. 85 // Reconstruct the picture.
93 scoped_refptr<Picture> two_rect_picture_check = 86 scoped_refptr<Picture> two_rect_picture_check =
94 Picture::CreateFromValue(serialized_two_rect.get()); 87 Picture::CreateFromValue(serialized_two_rect.get());
95 EXPECT_TRUE(!!two_rect_picture_check.get()); 88 EXPECT_TRUE(!!two_rect_picture_check.get());
96 89
97 // Check for equivalence. 90 // Check for equivalence.
98 unsigned char two_rect_buffer[4 * 100 * 100] = {0}; 91 unsigned char two_rect_buffer[4 * 100 * 100] = {0};
99 DrawPicture(two_rect_buffer, layer_rect, two_rect_picture); 92 DrawPicture(two_rect_buffer, layer_rect, two_rect_picture);
100 unsigned char two_rect_buffer_check[4 * 100 * 100] = {0}; 93 unsigned char two_rect_buffer_check[4 * 100 * 100] = {0};
101 DrawPicture(two_rect_buffer_check, layer_rect, two_rect_picture_check); 94 DrawPicture(two_rect_buffer_check, layer_rect, two_rect_picture_check);
102 95
103 EXPECT_EQ(two_rect_picture->LayerRect(), 96 EXPECT_EQ(two_rect_picture->LayerRect(), two_rect_picture_check->LayerRect());
104 two_rect_picture_check->LayerRect()); 97 EXPECT_EQ(0, memcmp(two_rect_buffer, two_rect_buffer_check, 4 * 100 * 100));
105 EXPECT_EQ(0, memcmp(two_rect_buffer, two_rect_buffer_check, 4 * 100 * 100));
106 }
107 } 98 }
108 99
109 TEST(PictureTest, PixelRefIterator) { 100 TEST(PictureTest, PixelRefIterator) {
110 gfx::Rect layer_rect(2048, 2048); 101 gfx::Rect layer_rect(2048, 2048);
111 102
112 SkTileGridFactory::TileGridInfo tile_grid_info; 103 SkTileGridFactory::TileGridInfo tile_grid_info;
113 tile_grid_info.fTileInterval = SkISize::Make(512, 512); 104 tile_grid_info.fTileInterval = SkISize::Make(512, 512);
114 tile_grid_info.fMargin.setEmpty(); 105 tile_grid_info.fMargin.setEmpty();
115 tile_grid_info.fOffset.setZero(); 106 tile_grid_info.fOffset.setZero();
116 107
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 picture = Picture::Create(layer_rect, 463 picture = Picture::Create(layer_rect,
473 &content_layer_client, 464 &content_layer_client,
474 tile_grid_info, 465 tile_grid_info,
475 false, 466 false,
476 Picture::RECORD_WITH_PAINTING_DISABLED); 467 Picture::RECORD_WITH_PAINTING_DISABLED);
477 EXPECT_TRUE(content_layer_client.last_canvas() != NULL); 468 EXPECT_TRUE(content_layer_client.last_canvas() != NULL);
478 EXPECT_EQ(ContentLayerClient::GRAPHICS_CONTEXT_DISABLED, 469 EXPECT_EQ(ContentLayerClient::GRAPHICS_CONTEXT_DISABLED,
479 content_layer_client.last_context_status()); 470 content_layer_client.last_context_status());
480 EXPECT_TRUE(picture.get()); 471 EXPECT_TRUE(picture.get());
481 472
482 picture = Picture::Create(layer_rect, 473 EXPECT_EQ(3, Picture::RECORDING_MODE_COUNT);
483 &content_layer_client,
484 tile_grid_info,
485 false,
486 Picture::RECORD_WITH_SKRECORD);
487 EXPECT_TRUE(content_layer_client.last_canvas() != NULL);
488 EXPECT_TRUE(picture.get());
489
490 EXPECT_EQ(4, Picture::RECORDING_MODE_COUNT);
491 } 474 }
492 475
493 } // namespace 476 } // namespace
494 } // namespace cc 477 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/picture.cc ('k') | cc/trees/layer_tree_settings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698