| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 * @param reporter Object to report failures. | 37 * @param reporter Object to report failures. |
| 38 * @param obj Flattenable object to be flattened. | 38 * @param obj Flattenable object to be flattened. |
| 39 * @param flattenProc Function that flattens objects with the same type as obj. | 39 * @param flattenProc Function that flattens objects with the same type as obj. |
| 40 */ | 40 */ |
| 41 static void testCreate(skiatest::Reporter* reporter, const void* obj, | 41 static void testCreate(skiatest::Reporter* reporter, const void* obj, |
| 42 void (*flattenProc)(SkOrderedWriteBuffer&, const void*))
{ | 42 void (*flattenProc)(SkOrderedWriteBuffer&, const void*))
{ |
| 43 Controller controller; | 43 Controller controller; |
| 44 // No need to delete data because that will be taken care of by the | 44 // No need to delete data because that will be taken care of by the |
| 45 // controller. | 45 // controller. |
| 46 SkFlatData* data1 = SkFlatData::Create(&controller, obj, 0, flattenProc); | 46 SkFlatData* data1 = SkFlatData::Create(&controller, obj, 0, flattenProc); |
| 47 data1->setSentinelInCache(); | |
| 48 SkFlatData* data2 = SkFlatData::Create(&controller, obj, 1, flattenProc); | 47 SkFlatData* data2 = SkFlatData::Create(&controller, obj, 1, flattenProc); |
| 49 data2->setSentinelAsCandidate(); | 48 REPORTER_ASSERT(reporter, *data1 == *data2); |
| 50 REPORTER_ASSERT(reporter, SkFlatData::Compare(*data1, *data2) == 0); | |
| 51 } | 49 } |
| 52 | 50 |
| 53 static void Tests(skiatest::Reporter* reporter) { | 51 static void Tests(skiatest::Reporter* reporter) { |
| 54 // Test flattening SkShader | 52 // Test flattening SkShader |
| 55 SkPoint points[2]; | 53 SkPoint points[2]; |
| 56 points[0].set(0, 0); | 54 points[0].set(0, 0); |
| 57 points[1].set(SkIntToScalar(20), SkIntToScalar(20)); | 55 points[1].set(SkIntToScalar(20), SkIntToScalar(20)); |
| 58 SkColor colors[2]; | 56 SkColor colors[2]; |
| 59 colors[0] = SK_ColorRED; | 57 colors[0] = SK_ColorRED; |
| 60 colors[1] = SK_ColorBLUE; | 58 colors[1] = SK_ColorBLUE; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 82 testCreate(reporter, cf, &flattenFlattenableProc); | 80 testCreate(reporter, cf, &flattenFlattenableProc); |
| 83 | 81 |
| 84 // Test SkXfermode | 82 // Test SkXfermode |
| 85 SkXfermode* xfer = SkXfermode::Create(SkXfermode::kDstOver_Mode); | 83 SkXfermode* xfer = SkXfermode::Create(SkXfermode::kDstOver_Mode); |
| 86 SkAutoUnref aurxf(xfer); | 84 SkAutoUnref aurxf(xfer); |
| 87 testCreate(reporter, xfer, &flattenFlattenableProc); | 85 testCreate(reporter, xfer, &flattenFlattenableProc); |
| 88 } | 86 } |
| 89 | 87 |
| 90 #include "TestClassDef.h" | 88 #include "TestClassDef.h" |
| 91 DEFINE_TESTCLASS("FlatData", FlatDataClass, Tests) | 89 DEFINE_TESTCLASS("FlatData", FlatDataClass, Tests) |
| OLD | NEW |