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 "../src/image/SkImagePriv.h" | 8 #include "../src/image/SkImagePriv.h" |
9 #include "../src/image/SkSurface_Base.h" | 9 #include "../src/image/SkSurface_Base.h" |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 canvas->flush(); | 153 canvas->flush(); |
154 REPORTER_ASSERT(reporter, 1 == surface->fDiscardCount); | 154 REPORTER_ASSERT(reporter, 1 == surface->fDiscardCount); |
155 REPORTER_ASSERT(reporter, 0 == surface->fRetainCount); | 155 REPORTER_ASSERT(reporter, 0 == surface->fRetainCount); |
156 | 156 |
157 // Case 2: Opaque writePixels | 157 // Case 2: Opaque writePixels |
158 surface->clearCounts(); | 158 surface->clearCounts(); |
159 SkAutoTUnref<SkImage> image2(canvas->newImageSnapshot()); | 159 SkAutoTUnref<SkImage> image2(canvas->newImageSnapshot()); |
160 REPORTER_ASSERT(reporter, 0 == surface->fDiscardCount); | 160 REPORTER_ASSERT(reporter, 0 == surface->fDiscardCount); |
161 REPORTER_ASSERT(reporter, 0 == surface->fRetainCount); | 161 REPORTER_ASSERT(reporter, 0 == surface->fRetainCount); |
162 | 162 |
163 surface->clearCounts(); | |
164 canvas->writePixels(srcBitmap, 0, 0); | |
165 #if 0 | |
166 REPORTER_ASSERT(reporter, 0 == surface->fDiscardCount); | |
167 REPORTER_ASSERT(reporter, 0 == surface->fRetainCount); | |
168 #endif | |
169 surface->clearCounts(); | |
170 canvas->flush(); | |
171 #if 0 | |
172 REPORTER_ASSERT(reporter, 1 == surface->fDiscardCount); | |
173 REPORTER_ASSERT(reporter, 0 == surface->fRetainCount); | |
174 #endif | |
175 | |
176 // Case 3: writePixels that partially covers the canvas | 163 // Case 3: writePixels that partially covers the canvas |
177 surface->clearCounts(); | 164 surface->clearCounts(); |
178 SkAutoTUnref<SkImage> image3(canvas->newImageSnapshot()); | 165 SkAutoTUnref<SkImage> image3(canvas->newImageSnapshot()); |
179 REPORTER_ASSERT(reporter, 0 == surface->fDiscardCount); | 166 REPORTER_ASSERT(reporter, 0 == surface->fDiscardCount); |
180 REPORTER_ASSERT(reporter, 0 == surface->fRetainCount); | 167 REPORTER_ASSERT(reporter, 0 == surface->fRetainCount); |
181 | 168 |
182 surface->clearCounts(); | |
183 canvas->writePixels(srcBitmap, 5, 0); | |
184 #if 0 | |
185 REPORTER_ASSERT(reporter, 0 == surface->fDiscardCount); | |
186 REPORTER_ASSERT(reporter, 0 == surface->fRetainCount); | |
187 #endif | |
188 surface->clearCounts(); | |
189 canvas->flush(); | |
190 #if 0 | |
191 REPORTER_ASSERT(reporter, 0 == surface->fDiscardCount); | |
192 REPORTER_ASSERT(reporter, 1 == surface->fRetainCount); | |
193 #endif | |
194 | |
195 // Case 4: unpremultiplied opaque writePixels that entirely | 169 // Case 4: unpremultiplied opaque writePixels that entirely |
196 // covers the canvas | 170 // covers the canvas |
197 surface->clearCounts(); | 171 surface->clearCounts(); |
198 SkAutoTUnref<SkImage> image4(canvas->newImageSnapshot()); | 172 SkAutoTUnref<SkImage> image4(canvas->newImageSnapshot()); |
199 REPORTER_ASSERT(reporter, 0 == surface->fDiscardCount); | 173 REPORTER_ASSERT(reporter, 0 == surface->fDiscardCount); |
200 REPORTER_ASSERT(reporter, 0 == surface->fRetainCount); | 174 REPORTER_ASSERT(reporter, 0 == surface->fRetainCount); |
201 | 175 |
202 surface->clearCounts(); | 176 surface->clearCounts(); |
203 callWritePixels(canvas, srcBitmap, 0, 0, SkCanvas::kRGBA_Unpremul_Config8888
); | 177 callWritePixels(canvas, srcBitmap, 0, 0, SkCanvas::kRGBA_Unpremul_Config8888
); |
204 REPORTER_ASSERT(reporter, 1 == surface->fDiscardCount); | 178 REPORTER_ASSERT(reporter, 1 == surface->fDiscardCount); |
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
855 TestDeferredCanvasBitmapSizeThreshold(reporter); | 829 TestDeferredCanvasBitmapSizeThreshold(reporter); |
856 TestDeferredCanvasCreateCompatibleDevice(reporter); | 830 TestDeferredCanvasCreateCompatibleDevice(reporter); |
857 TestDeferredCanvasWritePixelsToSurface(reporter); | 831 TestDeferredCanvasWritePixelsToSurface(reporter); |
858 TestDeferredCanvasSurface(reporter, NULL); | 832 TestDeferredCanvasSurface(reporter, NULL); |
859 TestDeferredCanvasSetSurface(reporter, NULL); | 833 TestDeferredCanvasSetSurface(reporter, NULL); |
860 if (NULL != factory) { | 834 if (NULL != factory) { |
861 TestDeferredCanvasSurface(reporter, factory); | 835 TestDeferredCanvasSurface(reporter, factory); |
862 TestDeferredCanvasSetSurface(reporter, factory); | 836 TestDeferredCanvasSetSurface(reporter, factory); |
863 } | 837 } |
864 } | 838 } |
OLD | NEW |