| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   82     REPORTER_ASSERT(r, paint.getShader()->unique()); |   82     REPORTER_ASSERT(r, paint.getShader()->unique()); | 
|   83     { |   83     { | 
|   84         SkRecord record; |   84         SkRecord record; | 
|   85         SkRecorder recorder(&record, 1920, 1080); |   85         SkRecorder recorder(&record, 1920, 1080); | 
|   86         recorder.saveLayer(&bounds, &paint); |   86         recorder.saveLayer(&bounds, &paint); | 
|   87         REPORTER_ASSERT(r, !paint.getShader()->unique()); |   87         REPORTER_ASSERT(r, !paint.getShader()->unique()); | 
|   88     } |   88     } | 
|   89     REPORTER_ASSERT(r, paint.getShader()->unique()); |   89     REPORTER_ASSERT(r, paint.getShader()->unique()); | 
|   90 } |   90 } | 
|   91  |   91  | 
|   92 DEF_TEST(Recorder_RefPictures, r) { |  | 
|   93     SkAutoTUnref<SkPicture> pic; |  | 
|   94  |  | 
|   95     { |  | 
|   96         SkPictureRecorder pr; |  | 
|   97         SkCanvas* canvas = pr.beginRecording(100, 100); |  | 
|   98         canvas->drawColor(SK_ColorRED); |  | 
|   99         pic.reset(pr.endRecording()); |  | 
|  100     } |  | 
|  101     REPORTER_ASSERT(r, pic->unique()); |  | 
|  102  |  | 
|  103     { |  | 
|  104         SkRecord record; |  | 
|  105         SkRecorder recorder(&record, 100, 100); |  | 
|  106         recorder.drawPicture(pic); |  | 
|  107         // the recorder should now also be an owner |  | 
|  108         REPORTER_ASSERT(r, !pic->unique()); |  | 
|  109     } |  | 
|  110     // the recorder destructor should have released us (back to unique) |  | 
|  111     REPORTER_ASSERT(r, pic->unique()); |  | 
|  112 } |  | 
|  113  |  | 
|  114 DEF_TEST(Recorder_drawImage_takeReference, reporter) { |   92 DEF_TEST(Recorder_drawImage_takeReference, reporter) { | 
|  115  |   93  | 
|  116     SkAutoTUnref<SkImage> image; |   94     SkAutoTUnref<SkImage> image; | 
|  117     { |   95     { | 
|  118         SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(100, 100))
     ; |   96         SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(100, 100))
     ; | 
|  119         surface->getCanvas()->clear(SK_ColorGREEN); |   97         surface->getCanvas()->clear(SK_ColorGREEN); | 
|  120         image.reset(surface->newImageSnapshot()); |   98         image.reset(surface->newImageSnapshot()); | 
|  121     } |   99     } | 
|  122     { |  100     { | 
|  123         SkRecord record; |  101         SkRecord record; | 
| (...skipping 18 matching lines...) Expand all  Loading... | 
|  142         recorder.drawImageRect(image.get(), 0, SkRect::MakeWH(100, 100)); |  120         recorder.drawImageRect(image.get(), 0, SkRect::MakeWH(100, 100)); | 
|  143         REPORTER_ASSERT(reporter, !image->unique()); |  121         REPORTER_ASSERT(reporter, !image->unique()); | 
|  144  |  122  | 
|  145         Tally tally; |  123         Tally tally; | 
|  146         tally.apply(record); |  124         tally.apply(record); | 
|  147  |  125  | 
|  148         REPORTER_ASSERT(reporter, 1 == tally.count<SkRecords::DrawImageRect>()); |  126         REPORTER_ASSERT(reporter, 1 == tally.count<SkRecords::DrawImageRect>()); | 
|  149     } |  127     } | 
|  150     REPORTER_ASSERT(reporter, image->unique()); |  128     REPORTER_ASSERT(reporter, image->unique()); | 
|  151 } |  129 } | 
| OLD | NEW |