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

Side by Side Diff: src/image/SkSurface_Gpu.cpp

Issue 2448593002: Remove SkAutoTUnref and SkAutoTDelete from public includes. (Closed)
Patch Set: And Vulcan. Created 4 years, 1 month 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 | « src/image/SkImage_Gpu.cpp ('k') | src/ports/SkFontMgr_win_dw.cpp » ('j') | 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 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 "SkSurface_Gpu.h" 8 #include "SkSurface_Gpu.h"
9 9
10 #include "GrContextPriv.h" 10 #include "GrContextPriv.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 // TODO: Make caller specify this (change virtual signature of onNewSurface) . 72 // TODO: Make caller specify this (change virtual signature of onNewSurface) .
73 static const SkBudgeted kBudgeted = SkBudgeted::kNo; 73 static const SkBudgeted kBudgeted = SkBudgeted::kNo;
74 return SkSurface::MakeRenderTarget(fDevice->context(), kBudgeted, info, samp leCount, 74 return SkSurface::MakeRenderTarget(fDevice->context(), kBudgeted, info, samp leCount,
75 origin, &this->props()); 75 origin, &this->props());
76 } 76 }
77 77
78 sk_sp<SkImage> SkSurface_Gpu::onNewImageSnapshot(SkBudgeted budgeted, SkCopyPixe lsMode cpm) { 78 sk_sp<SkImage> SkSurface_Gpu::onNewImageSnapshot(SkBudgeted budgeted, SkCopyPixe lsMode cpm) {
79 GrRenderTarget* rt = fDevice->accessDrawContext()->accessRenderTarget(); 79 GrRenderTarget* rt = fDevice->accessDrawContext()->accessRenderTarget();
80 SkASSERT(rt); 80 SkASSERT(rt);
81 GrTexture* tex = rt->asTexture(); 81 GrTexture* tex = rt->asTexture();
82 SkAutoTUnref<GrTexture> copy; 82 sk_sp<GrTexture> copy;
83 // If the original render target is a buffer originally created by the clien t, then we don't 83 // If the original render target is a buffer originally created by the clien t, then we don't
84 // want to ever retarget the SkSurface at another buffer we create. Force a copy now to avoid 84 // want to ever retarget the SkSurface at another buffer we create. Force a copy now to avoid
85 // copy-on-write. 85 // copy-on-write.
86 if (kAlways_SkCopyPixelsMode == cpm || !tex || rt->resourcePriv().refsWrappe dObjects()) { 86 if (kAlways_SkCopyPixelsMode == cpm || !tex || rt->resourcePriv().refsWrappe dObjects()) {
87 GrSurfaceDesc desc = fDevice->accessDrawContext()->desc(); 87 GrSurfaceDesc desc = fDevice->accessDrawContext()->desc();
88 GrContext* ctx = fDevice->context(); 88 GrContext* ctx = fDevice->context();
89 desc.fFlags = desc.fFlags & ~kRenderTarget_GrSurfaceFlag; 89 desc.fFlags = desc.fFlags & ~kRenderTarget_GrSurfaceFlag;
90 copy.reset(ctx->textureProvider()->createTexture(desc, budgeted)); 90 copy.reset(ctx->textureProvider()->createTexture(desc, budgeted));
91 if (!copy) { 91 if (!copy) {
92 return nullptr; 92 return nullptr;
93 } 93 }
94 if (!ctx->copySurface(copy, rt)) { 94 if (!ctx->copySurface(copy.get(), rt)) {
95 return nullptr; 95 return nullptr;
96 } 96 }
97 tex = copy; 97 tex = copy.get();
98 } 98 }
99 const SkImageInfo info = fDevice->imageInfo(); 99 const SkImageInfo info = fDevice->imageInfo();
100 sk_sp<SkImage> image; 100 sk_sp<SkImage> image;
101 if (tex) { 101 if (tex) {
102 image = sk_make_sp<SkImage_Gpu>(info.width(), info.height(), kNeedNewIma geUniqueID, 102 image = sk_make_sp<SkImage_Gpu>(info.width(), info.height(), kNeedNewIma geUniqueID,
103 info.alphaType(), tex, sk_ref_sp(info.co lorSpace()), 103 info.alphaType(), sk_ref_sp(tex),
104 budgeted); 104 sk_ref_sp(info.colorSpace()), budgeted);
105 } 105 }
106 return image; 106 return image;
107 } 107 }
108 108
109 // Create a new render target and, if necessary, copy the contents of the old 109 // Create a new render target and, if necessary, copy the contents of the old
110 // render target into it. Note that this flushes the SkGpuDevice but 110 // render target into it. Note that this flushes the SkGpuDevice but
111 // doesn't force an OpenGL flush. 111 // doesn't force an OpenGL flush.
112 void SkSurface_Gpu::onCopyOnWrite(ContentChangeMode mode) { 112 void SkSurface_Gpu::onCopyOnWrite(ContentChangeMode mode) {
113 GrRenderTarget* rt = fDevice->accessDrawContext()->accessRenderTarget(); 113 GrRenderTarget* rt = fDevice->accessDrawContext()->accessRenderTarget();
114 // are we sharing our render target with the image? Note this call should ne ver create a new 114 // are we sharing our render target with the image? Note this call should ne ver create a new
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 258
259 sk_sp<SkGpuDevice> device(SkGpuDevice::Make(std::move(dc), desc.fWidth, desc .fHeight, 259 sk_sp<SkGpuDevice> device(SkGpuDevice::Make(std::move(dc), desc.fWidth, desc .fHeight,
260 SkGpuDevice::kUninit_InitContent s)); 260 SkGpuDevice::kUninit_InitContent s));
261 if (!device) { 261 if (!device) {
262 return nullptr; 262 return nullptr;
263 } 263 }
264 return sk_make_sp<SkSurface_Gpu>(std::move(device)); 264 return sk_make_sp<SkSurface_Gpu>(std::move(device));
265 } 265 }
266 266
267 #endif 267 #endif
OLDNEW
« no previous file with comments | « src/image/SkImage_Gpu.cpp ('k') | src/ports/SkFontMgr_win_dw.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698