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

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

Issue 1734043002: Revert of Move Budgeted enum out of SkSurface, use in GrTextureProvider (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 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 | « src/image/SkSurface_Gpu.h ('k') | src/image/SkSurface_Raster.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 "GrResourceProvider.h" 10 #include "GrResourceProvider.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 SkCanvas::InitFlags flags = SkCanvas::kDefault_InitFlags; 65 SkCanvas::InitFlags flags = SkCanvas::kDefault_InitFlags;
66 flags = static_cast<SkCanvas::InitFlags>(flags | SkCanvas::kConservativeRast erClip_InitFlag); 66 flags = static_cast<SkCanvas::InitFlags>(flags | SkCanvas::kConservativeRast erClip_InitFlag);
67 67
68 return new SkCanvas(fDevice, flags); 68 return new SkCanvas(fDevice, flags);
69 } 69 }
70 70
71 SkSurface* SkSurface_Gpu::onNewSurface(const SkImageInfo& info) { 71 SkSurface* SkSurface_Gpu::onNewSurface(const SkImageInfo& info) {
72 GrRenderTarget* rt = fDevice->accessRenderTarget(); 72 GrRenderTarget* rt = fDevice->accessRenderTarget();
73 int sampleCount = rt->numColorSamples(); 73 int sampleCount = rt->numColorSamples();
74 // TODO: Make caller specify this (change virtual signature of onNewSurface) . 74 // TODO: Make caller specify this (change virtual signature of onNewSurface) .
75 static const SkBudgeted kBudgeted = SkBudgeted::kNo; 75 static const Budgeted kBudgeted = kNo_Budgeted;
76 return SkSurface::NewRenderTarget(fDevice->context(), kBudgeted, info, sampl eCount, 76 return SkSurface::NewRenderTarget(fDevice->context(), kBudgeted, info, sampl eCount,
77 &this->props()); 77 &this->props());
78 } 78 }
79 79
80 SkImage* SkSurface_Gpu::onNewImageSnapshot(SkBudgeted budgeted, ForceCopyMode fo rceCopyMode) { 80 SkImage* SkSurface_Gpu::onNewImageSnapshot(Budgeted budgeted, ForceCopyMode forc eCopyMode) {
81 GrRenderTarget* rt = fDevice->accessRenderTarget(); 81 GrRenderTarget* rt = fDevice->accessRenderTarget();
82 SkASSERT(rt); 82 SkASSERT(rt);
83 GrTexture* tex = rt->asTexture(); 83 GrTexture* tex = rt->asTexture();
84 SkAutoTUnref<GrTexture> copy; 84 SkAutoTUnref<GrTexture> copy;
85 // TODO: Force a copy when the rt is an external resource. 85 // TODO: Force a copy when the rt is an external resource.
86 if (kYes_ForceCopyMode == forceCopyMode || !tex) { 86 if (kYes_ForceCopyMode == forceCopyMode || !tex) {
87 GrSurfaceDesc desc = fDevice->accessRenderTarget()->desc(); 87 GrSurfaceDesc desc = fDevice->accessRenderTarget()->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, kYes_Budgeted == 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, rt)) {
95 return nullptr; 95 return nullptr;
96 } 96 }
97 tex = copy; 97 tex = copy;
98 } 98 }
99 const SkImageInfo info = fDevice->imageInfo(); 99 const SkImageInfo info = fDevice->imageInfo();
100 SkImage* image = nullptr; 100 SkImage* image = nullptr;
101 if (tex) { 101 if (tex) {
102 image = new SkImage_Gpu(info.width(), info.height(), kNeedNewImageUnique ID, 102 image = new SkImage_Gpu(info.width(), info.height(), kNeedNewImageUnique ID,
103 info.alphaType(), tex, budgeted); 103 info.alphaType(), tex, budgeted);
104 } 104 }
105 return image; 105 return image;
106 } 106 }
107 107
108 // Create a new render target and, if necessary, copy the contents of the old 108 // Create a new render target and, if necessary, copy the contents of the old
109 // render target into it. Note that this flushes the SkGpuDevice but 109 // render target into it. Note that this flushes the SkGpuDevice but
110 // doesn't force an OpenGL flush. 110 // doesn't force an OpenGL flush.
111 void SkSurface_Gpu::onCopyOnWrite(ContentChangeMode mode) { 111 void SkSurface_Gpu::onCopyOnWrite(ContentChangeMode mode) {
112 GrRenderTarget* rt = fDevice->accessRenderTarget(); 112 GrRenderTarget* rt = fDevice->accessRenderTarget();
113 // are we sharing our render target with the image? Note this call should ne ver create a new 113 // are we sharing our render target with the image? Note this call should ne ver create a new
114 // image because onCopyOnWrite is only called when there is a cached image. 114 // image because onCopyOnWrite is only called when there is a cached image.
115 SkAutoTUnref<SkImage> image(this->refCachedImage(SkBudgeted::kNo, kNo_ForceU nique)); 115 SkAutoTUnref<SkImage> image(this->refCachedImage(kNo_Budgeted, kNo_ForceUniq ue));
116 SkASSERT(image); 116 SkASSERT(image);
117 if (rt->asTexture() == as_IB(image)->getTexture()) { 117 if (rt->asTexture() == as_IB(image)->getTexture()) {
118 this->fDevice->replaceRenderTarget(SkSurface::kRetain_ContentChangeMode == mode); 118 this->fDevice->replaceRenderTarget(SkSurface::kRetain_ContentChangeMode == mode);
119 SkTextureImageApplyBudgetedDecision(image); 119 SkTextureImageApplyBudgetedDecision(image);
120 } else if (kDiscard_ContentChangeMode == mode) { 120 } else if (kDiscard_ContentChangeMode == mode) {
121 this->SkSurface_Gpu::onDiscard(); 121 this->SkSurface_Gpu::onDiscard();
122 } 122 }
123 } 123 }
124 124
125 void SkSurface_Gpu::onDiscard() { 125 void SkSurface_Gpu::onDiscard() {
126 fDevice->accessRenderTarget()->discard(); 126 fDevice->accessRenderTarget()->discard();
127 } 127 }
128 128
129 void SkSurface_Gpu::onPrepareForExternalIO() { 129 void SkSurface_Gpu::onPrepareForExternalIO() {
130 fDevice->accessRenderTarget()->prepareForExternalIO(); 130 fDevice->accessRenderTarget()->prepareForExternalIO();
131 } 131 }
132 132
133 /////////////////////////////////////////////////////////////////////////////// 133 ///////////////////////////////////////////////////////////////////////////////
134 134
135 SkSurface* SkSurface::NewRenderTargetDirect(GrRenderTarget* target, const SkSurf aceProps* props) { 135 SkSurface* SkSurface::NewRenderTargetDirect(GrRenderTarget* target, const SkSurf aceProps* props) {
136 SkAutoTUnref<SkGpuDevice> device( 136 SkAutoTUnref<SkGpuDevice> device(
137 SkGpuDevice::Create(target, props, SkGpuDevice::kUninit_InitContents)); 137 SkGpuDevice::Create(target, props, SkGpuDevice::kUninit_InitContents));
138 if (!device) { 138 if (!device) {
139 return nullptr; 139 return nullptr;
140 } 140 }
141 return new SkSurface_Gpu(device); 141 return new SkSurface_Gpu(device);
142 } 142 }
143 143
144 SkSurface* SkSurface::NewRenderTarget(GrContext* ctx, SkBudgeted budgeted, const SkImageInfo& info, 144 SkSurface* SkSurface::NewRenderTarget(GrContext* ctx, Budgeted budgeted, const S kImageInfo& info,
145 int sampleCount, const SkSurfaceProps* pro ps, 145 int sampleCount, const SkSurfaceProps* pro ps,
146 GrTextureStorageAllocator customAllocator) { 146 GrTextureStorageAllocator customAllocator) {
147 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create( 147 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(
148 ctx, budgeted, info, sampleCount, props, SkGpuDevice::kClear_InitCon tents, 148 ctx, budgeted, info, sampleCount, props, SkGpuDevice::kClear_InitCon tents,
149 customAllocator)); 149 customAllocator));
150 if (!device) { 150 if (!device) {
151 return nullptr; 151 return nullptr;
152 } 152 }
153 return new SkSurface_Gpu(device); 153 return new SkSurface_Gpu(device);
154 } 154 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 } 205 }
206 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(rt, props, 206 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(rt, props,
207 SkGpuDevice::kUninit_In itContents)); 207 SkGpuDevice::kUninit_In itContents));
208 if (!device) { 208 if (!device) {
209 return nullptr; 209 return nullptr;
210 } 210 }
211 return new SkSurface_Gpu(device); 211 return new SkSurface_Gpu(device);
212 } 212 }
213 213
214 #endif 214 #endif
OLDNEW
« no previous file with comments | « src/image/SkSurface_Gpu.h ('k') | src/image/SkSurface_Raster.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698