| 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 "SkPictureRecorder.h" | 10 #include "SkPictureRecorder.h" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 recorder.restore(); | 148 recorder.restore(); |
| 149 REPORTER_ASSERT(r, !recorder.isDrawingToLayer()); | 149 REPORTER_ASSERT(r, !recorder.isDrawingToLayer()); |
| 150 recorder.restore(); | 150 recorder.restore(); |
| 151 REPORTER_ASSERT(r, !recorder.isDrawingToLayer()); | 151 REPORTER_ASSERT(r, !recorder.isDrawingToLayer()); |
| 152 } | 152 } |
| 153 | 153 |
| 154 DEF_TEST(Recorder_drawImage_takeReference, reporter) { | 154 DEF_TEST(Recorder_drawImage_takeReference, reporter) { |
| 155 | 155 |
| 156 SkAutoTUnref<SkImage> image; | 156 SkAutoTUnref<SkImage> image; |
| 157 { | 157 { |
| 158 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterPMColor(100, 100)); | 158 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(100, 100))
; |
| 159 surface->getCanvas()->clear(SK_ColorGREEN); | 159 surface->getCanvas()->clear(SK_ColorGREEN); |
| 160 image.reset(surface->newImageSnapshot()); | 160 image.reset(surface->newImageSnapshot()); |
| 161 } | 161 } |
| 162 { | 162 { |
| 163 SkRecord record; | 163 SkRecord record; |
| 164 SkRecorder recorder(&record, 100, 100); | 164 SkRecorder recorder(&record, 100, 100); |
| 165 | 165 |
| 166 // DrawImage is supposed to take a reference | 166 // DrawImage is supposed to take a reference |
| 167 recorder.drawImage(image.get(), 0, 0); | 167 recorder.drawImage(image.get(), 0, 0); |
| 168 REPORTER_ASSERT(reporter, !image->unique()); | 168 REPORTER_ASSERT(reporter, !image->unique()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 182 recorder.drawImageRect(image.get(), 0, SkRect::MakeWH(100, 100)); | 182 recorder.drawImageRect(image.get(), 0, SkRect::MakeWH(100, 100)); |
| 183 REPORTER_ASSERT(reporter, !image->unique()); | 183 REPORTER_ASSERT(reporter, !image->unique()); |
| 184 | 184 |
| 185 Tally tally; | 185 Tally tally; |
| 186 tally.apply(record); | 186 tally.apply(record); |
| 187 | 187 |
| 188 REPORTER_ASSERT(reporter, 1 == tally.count<SkRecords::DrawImageRect>()); | 188 REPORTER_ASSERT(reporter, 1 == tally.count<SkRecords::DrawImageRect>()); |
| 189 } | 189 } |
| 190 REPORTER_ASSERT(reporter, image->unique()); | 190 REPORTER_ASSERT(reporter, image->unique()); |
| 191 } | 191 } |
| OLD | NEW |