OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "SkBitmapDevice.h" | 8 #include "SkBitmapDevice.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 1128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1139 canvas->drawBitmap(bm, 0, 0); | 1139 canvas->drawBitmap(bm, 0, 0); |
1140 canvas->drawPicture(childWithBitmap); | 1140 canvas->drawPicture(childWithBitmap); |
1141 parentWBWB.endRecording(); | 1141 parentWBWB.endRecording(); |
1142 REPORTER_ASSERT(reporter, parentWBWB.willPlayBackBitmaps()); // 2 | 1142 REPORTER_ASSERT(reporter, parentWBWB.willPlayBackBitmaps()); // 2 |
1143 } | 1143 } |
1144 | 1144 |
1145 static void test_gen_id(skiatest::Reporter* reporter) { | 1145 static void test_gen_id(skiatest::Reporter* reporter) { |
1146 | 1146 |
1147 SkPicture hasData, empty, midRecord; | 1147 SkPicture hasData, empty, midRecord; |
1148 | 1148 |
1149 uint32_t beforeID = hasData.getGenerationID(); | 1149 uint32_t beforeID = hasData.uniqueID(); |
1150 REPORTER_ASSERT(reporter, SkPicture::kInvalidGenID != beforeID); | 1150 REPORTER_ASSERT(reporter, SK_InvalidGenID != beforeID); |
1151 | 1151 |
1152 // all 3 pictures should have different ids | 1152 // all 3 pictures should have different ids |
1153 REPORTER_ASSERT(reporter, beforeID != empty.getGenerationID()); | 1153 REPORTER_ASSERT(reporter, beforeID != empty.uniqueID()); |
1154 REPORTER_ASSERT(reporter, beforeID != midRecord.getGenerationID()); | 1154 REPORTER_ASSERT(reporter, beforeID != midRecord.uniqueID()); |
1155 REPORTER_ASSERT(reporter, empty.getGenerationID() != midRecord.getGeneration
ID()); | 1155 REPORTER_ASSERT(reporter, empty.uniqueID() != midRecord.uniqueID()); |
1156 | 1156 |
1157 hasData.beginRecording(1, 1); | 1157 hasData.beginRecording(1, 1); |
1158 // gen ID should be invalid mid-record | 1158 // gen ID should be invalid mid-record |
1159 REPORTER_ASSERT(reporter, SkPicture::kInvalidGenID == hasData.getGenerationI
D()); | 1159 REPORTER_ASSERT(reporter, SK_InvalidGenID == hasData.uniqueID()); |
1160 hasData.endRecording(); | 1160 hasData.endRecording(); |
1161 // picture should get a new (non-zero) id after recording | 1161 // picture should get a new (non-zero) id after recording |
1162 REPORTER_ASSERT(reporter, hasData.getGenerationID() != beforeID); | 1162 REPORTER_ASSERT(reporter, hasData.uniqueID() != beforeID); |
1163 REPORTER_ASSERT(reporter, hasData.getGenerationID() != SkPicture::kInvalidGe
nID); | 1163 REPORTER_ASSERT(reporter, hasData.uniqueID() != SK_InvalidGenID); |
1164 | 1164 |
1165 midRecord.beginRecording(1, 1); | 1165 midRecord.beginRecording(1, 1); |
1166 REPORTER_ASSERT(reporter, SkPicture::kInvalidGenID == midRecord.getGeneratio
nID()); | 1166 REPORTER_ASSERT(reporter, SK_InvalidGenID == midRecord.uniqueID()); |
1167 | 1167 |
1168 // test out copy constructor | 1168 // test out copy constructor |
1169 SkPicture copyWithData(hasData); | 1169 SkPicture copyWithData(hasData); |
1170 REPORTER_ASSERT(reporter, hasData.getGenerationID() == copyWithData.getGener
ationID()); | 1170 REPORTER_ASSERT(reporter, hasData.uniqueID() == copyWithData.uniqueID()); |
1171 | 1171 |
1172 SkPicture emptyCopy(empty); | 1172 SkPicture emptyCopy(empty); |
1173 REPORTER_ASSERT(reporter, empty.getGenerationID() != emptyCopy.getGeneration
ID()); | 1173 REPORTER_ASSERT(reporter, empty.uniqueID() != emptyCopy.uniqueID()); |
1174 | 1174 |
1175 SkPicture copyMidRecord(midRecord); | 1175 SkPicture copyMidRecord(midRecord); |
1176 REPORTER_ASSERT(reporter, midRecord.getGenerationID() != copyMidRecord.getGe
nerationID()); | 1176 REPORTER_ASSERT(reporter, midRecord.uniqueID() != copyMidRecord.uniqueID()); |
1177 REPORTER_ASSERT(reporter, copyMidRecord.getGenerationID() != SkPicture::kInv
alidGenID); | 1177 REPORTER_ASSERT(reporter, copyMidRecord.uniqueID() != SK_InvalidGenID); |
1178 | 1178 |
1179 // test out swap | 1179 // test out swap |
1180 beforeID = copyMidRecord.getGenerationID(); | 1180 beforeID = copyMidRecord.uniqueID(); |
1181 copyWithData.swap(copyMidRecord); | 1181 copyWithData.swap(copyMidRecord); |
1182 REPORTER_ASSERT(reporter, copyWithData.getGenerationID() == beforeID); | 1182 REPORTER_ASSERT(reporter, copyWithData.uniqueID() == beforeID); |
1183 REPORTER_ASSERT(reporter, copyMidRecord.getGenerationID() == hasData.getGene
rationID()); | 1183 REPORTER_ASSERT(reporter, copyMidRecord.uniqueID() == hasData.uniqueID()); |
1184 | 1184 |
1185 // test out clone | 1185 // test out clone |
1186 SkAutoTUnref<SkPicture> cloneWithData(hasData.clone()); | 1186 SkAutoTUnref<SkPicture> cloneWithData(hasData.clone()); |
1187 REPORTER_ASSERT(reporter, hasData.getGenerationID() == cloneWithData->getGen
erationID()); | 1187 REPORTER_ASSERT(reporter, hasData.uniqueID() == cloneWithData->uniqueID()); |
1188 | 1188 |
1189 SkAutoTUnref<SkPicture> emptyClone(empty.clone()); | 1189 SkAutoTUnref<SkPicture> emptyClone(empty.clone()); |
1190 REPORTER_ASSERT(reporter, empty.getGenerationID() != emptyClone->getGenerati
onID()); | 1190 REPORTER_ASSERT(reporter, empty.uniqueID() != emptyClone->uniqueID()); |
1191 | 1191 |
1192 SkAutoTUnref<SkPicture> cloneMidRecord(midRecord.clone()); | 1192 SkAutoTUnref<SkPicture> cloneMidRecord(midRecord.clone()); |
1193 REPORTER_ASSERT(reporter, midRecord.getGenerationID() != cloneMidRecord->get
GenerationID()); | 1193 REPORTER_ASSERT(reporter, midRecord.uniqueID() != cloneMidRecord->uniqueID()
); |
1194 REPORTER_ASSERT(reporter, cloneMidRecord->getGenerationID() != SkPicture::kI
nvalidGenID); | 1194 REPORTER_ASSERT(reporter, cloneMidRecord->uniqueID() != SK_InvalidGenID); |
1195 } | 1195 } |
1196 | 1196 |
1197 DEF_TEST(Picture, reporter) { | 1197 DEF_TEST(Picture, reporter) { |
1198 #ifdef SK_DEBUG | 1198 #ifdef SK_DEBUG |
1199 test_deleting_empty_playback(); | 1199 test_deleting_empty_playback(); |
1200 test_serializing_empty_picture(); | 1200 test_serializing_empty_picture(); |
1201 #else | 1201 #else |
1202 test_bad_bitmap(); | 1202 test_bad_bitmap(); |
1203 #endif | 1203 #endif |
1204 test_unbalanced_save_restores(reporter); | 1204 test_unbalanced_save_restores(reporter); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1240 picture.endRecording(); | 1240 picture.endRecording(); |
1241 } | 1241 } |
1242 | 1242 |
1243 DEF_TEST(Canvas_EmptyBitmap, r) { | 1243 DEF_TEST(Canvas_EmptyBitmap, r) { |
1244 SkBitmap dst; | 1244 SkBitmap dst; |
1245 dst.allocN32Pixels(10, 10); | 1245 dst.allocN32Pixels(10, 10); |
1246 SkCanvas canvas(dst); | 1246 SkCanvas canvas(dst); |
1247 | 1247 |
1248 test_draw_bitmaps(&canvas); | 1248 test_draw_bitmaps(&canvas); |
1249 } | 1249 } |
OLD | NEW |