Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "Test.h" | 8 #include "Test.h" |
| 9 | 9 |
| 10 #include "SkRecord.h" | 10 #include "SkRecord.h" |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 39 DEF_TEST(Record, r) { | 39 DEF_TEST(Record, r) { |
| 40 SkRecord record; | 40 SkRecord record; |
| 41 | 41 |
| 42 // Add a simple DrawRect command. | 42 // Add a simple DrawRect command. |
| 43 SkRect rect = SkRect::MakeWH(10, 10); | 43 SkRect rect = SkRect::MakeWH(10, 10); |
| 44 SkPaint paint; | 44 SkPaint paint; |
| 45 SkNEW_PLACEMENT_ARGS(record.append<SkRecords::DrawRect>(), SkRecords::DrawRe ct, (rect, paint)); | 45 SkNEW_PLACEMENT_ARGS(record.append<SkRecords::DrawRect>(), SkRecords::DrawRe ct, (rect, paint)); |
| 46 | 46 |
| 47 // Its area should be 100. | 47 // Its area should be 100. |
| 48 AreaSummer summer; | 48 AreaSummer summer; |
| 49 record.visit(summer); | 49 for (unsigned i = 0; i < record.count(); i++) { |
|
f(malita)
2014/04/22 12:16:10
This loop appears quite common - can we set up a h
mtklein
2014/04/22 15:36:27
Added apply() to AreaSummer, Stretch, and the othe
| |
| 50 record.visit(i, summer); | |
| 51 } | |
| 50 REPORTER_ASSERT(r, summer.area() == 100); | 52 REPORTER_ASSERT(r, summer.area() == 100); |
| 51 | 53 |
| 52 // Scale 2x. | 54 // Scale 2x. |
| 53 Stretch stretch; | 55 Stretch stretch; |
| 54 record.mutate(stretch); | 56 for (unsigned i = 0; i < record.count(); i++) { |
| 57 record.mutate(i, stretch); | |
| 58 } | |
| 55 | 59 |
| 56 // Now its area should be 100 + 400. | 60 // Now its area should be 100 + 400. |
| 57 record.visit(summer); | 61 for (unsigned i = 0; i < record.count(); i++) { |
| 62 record.visit(i, summer); | |
| 63 } | |
| 58 REPORTER_ASSERT(r, summer.area() == 500); | 64 REPORTER_ASSERT(r, summer.area() == 500); |
| 59 } | 65 } |
| OLD | NEW |