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

Side by Side Diff: src/gpu/SkGpuDevice.cpp

Issue 1886613003: Remove GrTextureStorageAllocator. This was added from Chromium but never used and not expected to b… (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 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/gpu/SkGpuDevice.h ('k') | src/gpu/SkGrPixelRef.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 2011 Google Inc. 2 * Copyright 2011 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 "SkGpuDevice.h" 8 #include "SkGpuDevice.h"
9 9
10 #include "GrBlurUtils.h" 10 #include "GrBlurUtils.h"
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 } 137 }
138 unsigned flags; 138 unsigned flags;
139 if (!CheckAlphaTypeAndGetFlags(nullptr, init, &flags)) { 139 if (!CheckAlphaTypeAndGetFlags(nullptr, init, &flags)) {
140 return nullptr; 140 return nullptr;
141 } 141 }
142 return new SkGpuDevice(rt, width, height, props, flags); 142 return new SkGpuDevice(rt, width, height, props, flags);
143 } 143 }
144 144
145 SkGpuDevice* SkGpuDevice::Create(GrContext* context, SkBudgeted budgeted, 145 SkGpuDevice* SkGpuDevice::Create(GrContext* context, SkBudgeted budgeted,
146 const SkImageInfo& info, int sampleCount, 146 const SkImageInfo& info, int sampleCount,
147 const SkSurfaceProps* props, InitContents init, 147 const SkSurfaceProps* props, InitContents init) {
148 GrTextureStorageAllocator customAllocator) {
149 unsigned flags; 148 unsigned flags;
150 if (!CheckAlphaTypeAndGetFlags(&info, init, &flags)) { 149 if (!CheckAlphaTypeAndGetFlags(&info, init, &flags)) {
151 return nullptr; 150 return nullptr;
152 } 151 }
153 152
154 SkAutoTUnref<GrRenderTarget> rt(CreateRenderTarget( 153 SkAutoTUnref<GrRenderTarget> rt(CreateRenderTarget(context, budgeted, info, sampleCount));
155 context, budgeted, info, sampleCount, customAllocator));
156 if (nullptr == rt) { 154 if (nullptr == rt) {
157 return nullptr; 155 return nullptr;
158 } 156 }
159 157
160 return new SkGpuDevice(rt, info.width(), info.height(), props, flags); 158 return new SkGpuDevice(rt, info.width(), info.height(), props, flags);
161 } 159 }
162 160
163 SkGpuDevice::SkGpuDevice(GrRenderTarget* rt, int width, int height, 161 SkGpuDevice::SkGpuDevice(GrRenderTarget* rt, int width, int height,
164 const SkSurfaceProps* props, unsigned flags) 162 const SkSurfaceProps* props, unsigned flags)
165 : INHERITED(SkSurfacePropsCopyOrDefault(props)) 163 : INHERITED(SkSurfacePropsCopyOrDefault(props))
166 , fContext(SkRef(rt->getContext())) 164 , fContext(SkRef(rt->getContext()))
167 , fRenderTarget(SkRef(rt)) { 165 , fRenderTarget(SkRef(rt)) {
168 fOpaque = SkToBool(flags & kIsOpaque_Flag); 166 fOpaque = SkToBool(flags & kIsOpaque_Flag);
169 167
170 SkAlphaType at = fOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType; 168 SkAlphaType at = fOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType;
171 SkImageInfo info = rt->surfacePriv().info(at).makeWH(width, height); 169 SkImageInfo info = rt->surfacePriv().info(at).makeWH(width, height);
172 SkPixelRef* pr = new SkGrPixelRef(info, rt); 170 SkPixelRef* pr = new SkGrPixelRef(info, rt);
173 fLegacyBitmap.setInfo(info); 171 fLegacyBitmap.setInfo(info);
174 fLegacyBitmap.setPixelRef(pr)->unref(); 172 fLegacyBitmap.setPixelRef(pr)->unref();
175 173
176 fDrawContext.reset(this->context()->drawContext(rt, &this->surfaceProps())); 174 fDrawContext.reset(this->context()->drawContext(rt, &this->surfaceProps()));
177 if (flags & kNeedClear_Flag) { 175 if (flags & kNeedClear_Flag) {
178 this->clearAll(); 176 this->clearAll();
179 } 177 }
180 } 178 }
181 179
182 GrRenderTarget* SkGpuDevice::CreateRenderTarget( 180 GrRenderTarget* SkGpuDevice::CreateRenderTarget(GrContext* context, SkBudgeted b udgeted,
183 GrContext* context, SkBudgeted budgeted, const SkImageInfo& origInfo, 181 const SkImageInfo& origInfo, int sampleCount) {
184 int sampleCount, GrTextureStorageAllocator textureStorageAllocator) {
185 if (kUnknown_SkColorType == origInfo.colorType() || 182 if (kUnknown_SkColorType == origInfo.colorType() ||
186 origInfo.width() < 0 || origInfo.height() < 0) { 183 origInfo.width() < 0 || origInfo.height() < 0) {
187 return nullptr; 184 return nullptr;
188 } 185 }
189 186
190 if (!context) { 187 if (!context) {
191 return nullptr; 188 return nullptr;
192 } 189 }
193 190
194 SkColorType ct = origInfo.colorType(); 191 SkColorType ct = origInfo.colorType();
195 SkAlphaType at = origInfo.alphaType(); 192 SkAlphaType at = origInfo.alphaType();
196 SkColorProfileType pt = origInfo.profileType(); 193 SkColorProfileType pt = origInfo.profileType();
197 if (kRGB_565_SkColorType == ct) { 194 if (kRGB_565_SkColorType == ct) {
198 at = kOpaque_SkAlphaType; // force this setting 195 at = kOpaque_SkAlphaType; // force this setting
199 } else if (ct != kBGRA_8888_SkColorType && ct != kRGBA_8888_SkColorType) { 196 } else if (ct != kBGRA_8888_SkColorType && ct != kRGBA_8888_SkColorType) {
200 // Fall back from whatever ct was to default of kRGBA or kBGRA which is aliased as kN32 197 // Fall back from whatever ct was to default of kRGBA or kBGRA which is aliased as kN32
201 ct = kN32_SkColorType; 198 ct = kN32_SkColorType;
202 } 199 }
203 if (kOpaque_SkAlphaType != at) { 200 if (kOpaque_SkAlphaType != at) {
204 at = kPremul_SkAlphaType; // force this setting 201 at = kPremul_SkAlphaType; // force this setting
205 } 202 }
206 const SkImageInfo info = SkImageInfo::Make(origInfo.width(), origInfo.height (), ct, at, pt); 203 const SkImageInfo info = SkImageInfo::Make(origInfo.width(), origInfo.height (), ct, at, pt);
207 204
208 GrSurfaceDesc desc; 205 GrSurfaceDesc desc;
209 desc.fFlags = kRenderTarget_GrSurfaceFlag; 206 desc.fFlags = kRenderTarget_GrSurfaceFlag;
210 desc.fWidth = info.width(); 207 desc.fWidth = info.width();
211 desc.fHeight = info.height(); 208 desc.fHeight = info.height();
212 desc.fConfig = SkImageInfo2GrPixelConfig(info, *context->caps()); 209 desc.fConfig = SkImageInfo2GrPixelConfig(info, *context->caps());
213 desc.fSampleCnt = sampleCount; 210 desc.fSampleCnt = sampleCount;
214 desc.fTextureStorageAllocator = textureStorageAllocator;
215 desc.fIsMipMapped = false; 211 desc.fIsMipMapped = false;
216 GrTexture* texture = context->textureProvider()->createTexture(desc, budgete d, nullptr, 0); 212 GrTexture* texture = context->textureProvider()->createTexture(desc, budgete d, nullptr, 0);
217 if (nullptr == texture) { 213 if (nullptr == texture) {
218 return nullptr; 214 return nullptr;
219 } 215 }
220 SkASSERT(nullptr != texture->asRenderTarget()); 216 SkASSERT(nullptr != texture->asRenderTarget());
221 return texture->asRenderTarget(); 217 return texture->asRenderTarget();
222 } 218 }
223 219
224 // This method ensures that we always have a texture-backed "bitmap" when we fin ally 220 // This method ensures that we always have a texture-backed "bitmap" when we fin ally
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 SkIRect rect = SkIRect::MakeWH(this->width(), this->height()); 348 SkIRect rect = SkIRect::MakeWH(this->width(), this->height());
353 fDrawContext->clear(&rect, color, true); 349 fDrawContext->clear(&rect, color, true);
354 } 350 }
355 351
356 void SkGpuDevice::replaceRenderTarget(bool shouldRetainContent) { 352 void SkGpuDevice::replaceRenderTarget(bool shouldRetainContent) {
357 ASSERT_SINGLE_OWNER 353 ASSERT_SINGLE_OWNER
358 354
359 SkBudgeted budgeted = fRenderTarget->resourcePriv().isBudgeted(); 355 SkBudgeted budgeted = fRenderTarget->resourcePriv().isBudgeted();
360 356
361 SkAutoTUnref<GrRenderTarget> newRT(CreateRenderTarget( 357 SkAutoTUnref<GrRenderTarget> newRT(CreateRenderTarget(
362 this->context(), budgeted, this->imageInfo(), fRenderTarget->desc().fSam pleCnt, 358 this->context(), budgeted, this->imageInfo(), fRenderTarget->desc().fSam pleCnt));
363 fRenderTarget->desc().fTextureStorageAllocator));
364 359
365 if (nullptr == newRT) { 360 if (nullptr == newRT) {
366 return; 361 return;
367 } 362 }
368 363
369 if (shouldRetainContent) { 364 if (shouldRetainContent) {
370 if (fRenderTarget->wasDestroyed()) { 365 if (fRenderTarget->wasDestroyed()) {
371 return; 366 return;
372 } 367 }
373 this->context()->copySurface(newRT, fRenderTarget); 368 this->context()->copySurface(newRT, fRenderTarget);
(...skipping 1568 matching lines...) Expand 10 before | Expand all | Expand 10 after
1942 } 1937 }
1943 1938
1944 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { 1939 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() {
1945 ASSERT_SINGLE_OWNER 1940 ASSERT_SINGLE_OWNER
1946 // We always return a transient cache, so it is freed after each 1941 // We always return a transient cache, so it is freed after each
1947 // filter traversal. 1942 // filter traversal.
1948 return SkGpuDevice::NewImageFilterCache(); 1943 return SkGpuDevice::NewImageFilterCache();
1949 } 1944 }
1950 1945
1951 #endif 1946 #endif
OLDNEW
« no previous file with comments | « src/gpu/SkGpuDevice.h ('k') | src/gpu/SkGrPixelRef.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698