Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Side by Side Diff: tests/TextBlobCacheTest.cpp

Issue 1252593002: fix memory leak in TextBlobCacheTest (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: tweaks Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698