| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "sk_tool_utils.h" | 8 #include "sk_tool_utils.h" |
| 9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkPaint.h" | 10 #include "SkPaint.h" |
| 11 #include "SkPoint.h" | 11 #include "SkPoint.h" |
| 12 #include "SkTextBlob.h" | 12 #include "SkTextBlob.h" |
| 13 #include "SkFontMgr.h" | 13 #include "SkFontMgr.h" |
| 14 #include "SkGraphics.h" | 14 #include "SkGraphics.h" |
| 15 #include "SkSurface.h" | 15 #include "SkSurface.h" |
| 16 #include "SkTypeface.h" | 16 #include "SkTypeface.h" |
| 17 | 17 |
| 18 #ifdef SK_BUILD_FOR_WIN | 18 #ifdef SK_BUILD_FOR_WIN |
| 19 #include "SkTypeface_win.h" | 19 #include "SkTypeface_win.h" |
| 20 #endif | 20 #endif |
| 21 | 21 |
| 22 #include "Test.h" | 22 #include "Test.h" |
| 23 | 23 |
| 24 #if SK_SUPPORT_GPU | 24 #if SK_SUPPORT_GPU |
| 25 #include "GrContextFactory.h" | 25 #include "GrContextFactory.h" |
| 26 | 26 |
| 27 struct TextBlobWrapper { | 27 struct TextBlobWrapper { |
| 28 explicit TextBlobWrapper(const SkTextBlob* blob) : fBlob(SkRef(blob)) {} | 28 // This class assumes it 'owns' the textblob it wraps, and thus does not nee
d to take a ref |
| 29 explicit TextBlobWrapper(const SkTextBlob* blob) : fBlob(blob) {} |
| 29 TextBlobWrapper(const TextBlobWrapper& blob) : fBlob(SkRef(blob.fBlob.get())
) {} | 30 TextBlobWrapper(const TextBlobWrapper& blob) : fBlob(SkRef(blob.fBlob.get())
) {} |
| 30 | 31 |
| 31 SkAutoTUnref<const SkTextBlob> fBlob; | 32 SkAutoTUnref<const SkTextBlob> fBlob; |
| 32 }; | 33 }; |
| 33 | 34 |
| 34 static void draw(SkCanvas* canvas, int redraw, const SkTArray<TextBlobWrapper>&
blobs) { | 35 static void draw(SkCanvas* canvas, int redraw, const SkTArray<TextBlobWrapper>&
blobs) { |
| 35 int yOffset = 0; | 36 int yOffset = 0; |
| 36 for (int r = 0; r < redraw; r++) { | 37 for (int r = 0; r < redraw; r++) { |
| 37 for (int i = 0; i < blobs.count(); i++) { | 38 for (int i = 0; i < blobs.count(); i++) { |
| 38 const SkTextBlob* blob = blobs[i].fBlob.get(); | 39 const SkTextBlob* blob = blobs[i].fBlob.get(); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 | 117 |
| 117 // test draw after free | 118 // test draw after free |
| 118 ctx->freeGpuResources(); | 119 ctx->freeGpuResources(); |
| 119 draw(canvas, 1, blobs); | 120 draw(canvas, 1, blobs); |
| 120 | 121 |
| 121 // test draw after abandon | 122 // test draw after abandon |
| 122 ctx->abandonContext(); | 123 ctx->abandonContext(); |
| 123 draw(canvas, 1, blobs); | 124 draw(canvas, 1, blobs); |
| 124 } | 125 } |
| 125 #endif | 126 #endif |
| OLD | NEW |