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

Side by Side Diff: gm/deferredtextureimagedata.cpp

Issue 2069443004: Fix leak of GrContextThreadSafeProxy in deferred_texture_image_data (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 4 years, 6 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 2016 Google Inc. 2 * Copyright 2016 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 #include <vector> 7 #include <vector>
8 8
9 #include "gm.h" 9 #include "gm.h"
10 #include "GrContext.h" 10 #include "GrContext.h"
11 #include "Resources.h" 11 #include "Resources.h"
12 #include "SkImage.h" 12 #include "SkImage.h"
13 13
14 #if SK_SUPPORT_GPU 14 #if SK_SUPPORT_GPU
15 15
16 // Helper function that uploads the given SkImage using MakdeFromDeferredTexture ImageData and then 16 // Helper function that uploads the given SkImage using MakdeFromDeferredTexture ImageData and then
17 // draws the uploaded version at the specified coordinates. 17 // draws the uploaded version at the specified coordinates.
18 static bool DrawDeferredTextureImageData(GrContext* context, SkCanvas* canvas, S kImage* image, 18 static bool DrawDeferredTextureImageData(GrContext* context, SkCanvas* canvas, S kImage* image,
19 SkImage::DeferredTextureImageUsageParam s* params, 19 SkImage::DeferredTextureImageUsageParam s* params,
20 SkScalar x, SkScalar y) { 20 SkScalar x, SkScalar y) {
21 size_t deferredSize = 21 size_t deferredSize =
22 image->getDeferredTextureImageData(*context->threadSafeProxy(), params, 1, nullptr); 22 image->getDeferredTextureImageData(*context->threadSafeProxy(), params, 1, nullptr);
23 if (deferredSize == 0) { 23 if (deferredSize == 0) {
24 SkDebugf("\nCould not create DeferredTextureImageData.\n"); 24 SkDebugf("\nCould not create DeferredTextureImageData.\n");
25 return false; 25 return false;
26 } 26 }
27 27
28 std::vector<uint8_t> memory; 28 std::vector<uint8_t> memory;
29 memory.resize(deferredSize); 29 memory.resize(deferredSize);
30 image->getDeferredTextureImageData(*context->threadSafeProxy(), params, 1, mem ory.data()); 30 SkAutoTUnref<GrContextThreadSafeProxy> proxy(context->threadSafeProxy());
31 image->getDeferredTextureImageData(*proxy, params, 1, memory.data());
31 sk_sp<SkImage> uploadedImage = 32 sk_sp<SkImage> uploadedImage =
32 SkImage::MakeFromDeferredTextureImageData(context, memory.data(), SkBudget ed::kNo); 33 SkImage::MakeFromDeferredTextureImageData(context, memory.data(), SkBudget ed::kNo);
33 canvas->drawImage(uploadedImage, x, y); 34 canvas->drawImage(uploadedImage, x, y);
34 35
35 return true; 36 return true;
36 } 37 }
37 38
38 DEF_SIMPLE_GM(deferred_texture_image_data, canvas, 60, 10) { 39 DEF_SIMPLE_GM(deferred_texture_image_data, canvas, 60, 10) {
39 GrContext* context = canvas->getGrContext(); 40 GrContext* context = canvas->getGrContext();
40 if (!context) { 41 if (!context) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 // Draw 50% scaled versions of the encoded and decoded images at none qualit y. 73 // Draw 50% scaled versions of the encoded and decoded images at none qualit y.
73 SkImage::DeferredTextureImageUsageParams noneScaledParams; 74 SkImage::DeferredTextureImageUsageParams noneScaledParams;
74 noneScaledParams.fPreScaleMipLevel = 1; 75 noneScaledParams.fPreScaleMipLevel = 1;
75 noneScaledParams.fQuality = kNone_SkFilterQuality; 76 noneScaledParams.fQuality = kNone_SkFilterQuality;
76 77
77 DrawDeferredTextureImageData(context, canvas, encodedImage.get(), &noneScale dParams, 40, 0); 78 DrawDeferredTextureImageData(context, canvas, encodedImage.get(), &noneScale dParams, 40, 0);
78 DrawDeferredTextureImageData(context, canvas, decodedImage.get(), &noneScale dParams, 50, 0); 79 DrawDeferredTextureImageData(context, canvas, decodedImage.get(), &noneScale dParams, 50, 0);
79 } 80 }
80 81
81 #endif 82 #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