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

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

Issue 1728093005: Move Budgeted enum out of SkSurface, use in GrTextureProvider (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add aliases for Chrome Created 4 years, 9 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/SkGr.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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 if (!rt || rt->wasDestroyed()) { 140 if (!rt || rt->wasDestroyed()) {
141 return nullptr; 141 return nullptr;
142 } 142 }
143 unsigned flags; 143 unsigned flags;
144 if (!CheckAlphaTypeAndGetFlags(nullptr, init, &flags)) { 144 if (!CheckAlphaTypeAndGetFlags(nullptr, init, &flags)) {
145 return nullptr; 145 return nullptr;
146 } 146 }
147 return new SkGpuDevice(rt, width, height, props, flags); 147 return new SkGpuDevice(rt, width, height, props, flags);
148 } 148 }
149 149
150 SkGpuDevice* SkGpuDevice::Create(GrContext* context, SkSurface::Budgeted budgete d, 150 SkGpuDevice* SkGpuDevice::Create(GrContext* context, SkBudgeted budgeted,
151 const SkImageInfo& info, int sampleCount, 151 const SkImageInfo& info, int sampleCount,
152 const SkSurfaceProps* props, InitContents init, 152 const SkSurfaceProps* props, InitContents init,
153 GrTextureStorageAllocator customAllocator) { 153 GrTextureStorageAllocator customAllocator) {
154 unsigned flags; 154 unsigned flags;
155 if (!CheckAlphaTypeAndGetFlags(&info, init, &flags)) { 155 if (!CheckAlphaTypeAndGetFlags(&info, init, &flags)) {
156 return nullptr; 156 return nullptr;
157 } 157 }
158 158
159 SkAutoTUnref<GrRenderTarget> rt(CreateRenderTarget( 159 SkAutoTUnref<GrRenderTarget> rt(CreateRenderTarget(
160 context, budgeted, info, sampleCount, customAllocator)); 160 context, budgeted, info, sampleCount, customAllocator));
(...skipping 17 matching lines...) Expand all
178 fLegacyBitmap.setInfo(info); 178 fLegacyBitmap.setInfo(info);
179 fLegacyBitmap.setPixelRef(pr)->unref(); 179 fLegacyBitmap.setPixelRef(pr)->unref();
180 180
181 fDrawContext.reset(this->context()->drawContext(rt, &this->surfaceProps())); 181 fDrawContext.reset(this->context()->drawContext(rt, &this->surfaceProps()));
182 if (flags & kNeedClear_Flag) { 182 if (flags & kNeedClear_Flag) {
183 this->clearAll(); 183 this->clearAll();
184 } 184 }
185 } 185 }
186 186
187 GrRenderTarget* SkGpuDevice::CreateRenderTarget( 187 GrRenderTarget* SkGpuDevice::CreateRenderTarget(
188 GrContext* context, SkSurface::Budgeted budgeted, const SkImageInfo& ori gInfo, 188 GrContext* context, SkBudgeted budgeted, const SkImageInfo& origInfo,
189 int sampleCount, GrTextureStorageAllocator textureStorageAllocator) { 189 int sampleCount, GrTextureStorageAllocator textureStorageAllocator) {
190 if (kUnknown_SkColorType == origInfo.colorType() || 190 if (kUnknown_SkColorType == origInfo.colorType() ||
191 origInfo.width() < 0 || origInfo.height() < 0) { 191 origInfo.width() < 0 || origInfo.height() < 0) {
192 return nullptr; 192 return nullptr;
193 } 193 }
194 194
195 if (!context) { 195 if (!context) {
196 return nullptr; 196 return nullptr;
197 } 197 }
198 198
(...skipping 10 matching lines...) Expand all
209 } 209 }
210 const SkImageInfo info = SkImageInfo::Make(origInfo.width(), origInfo.height (), ct, at); 210 const SkImageInfo info = SkImageInfo::Make(origInfo.width(), origInfo.height (), ct, at);
211 211
212 GrSurfaceDesc desc; 212 GrSurfaceDesc desc;
213 desc.fFlags = kRenderTarget_GrSurfaceFlag; 213 desc.fFlags = kRenderTarget_GrSurfaceFlag;
214 desc.fWidth = info.width(); 214 desc.fWidth = info.width();
215 desc.fHeight = info.height(); 215 desc.fHeight = info.height();
216 desc.fConfig = SkImageInfo2GrPixelConfig(info); 216 desc.fConfig = SkImageInfo2GrPixelConfig(info);
217 desc.fSampleCnt = sampleCount; 217 desc.fSampleCnt = sampleCount;
218 desc.fTextureStorageAllocator = textureStorageAllocator; 218 desc.fTextureStorageAllocator = textureStorageAllocator;
219 GrTexture* texture = context->textureProvider()->createTexture( 219 GrTexture* texture = context->textureProvider()->createTexture(desc, budgete d, nullptr, 0);
220 desc, SkToBool(budgeted), nullptr, 0);
221 if (nullptr == texture) { 220 if (nullptr == texture) {
222 return nullptr; 221 return nullptr;
223 } 222 }
224 SkASSERT(nullptr != texture->asRenderTarget()); 223 SkASSERT(nullptr != texture->asRenderTarget());
225 return texture->asRenderTarget(); 224 return texture->asRenderTarget();
226 } 225 }
227 226
228 /////////////////////////////////////////////////////////////////////////////// 227 ///////////////////////////////////////////////////////////////////////////////
229 228
230 bool SkGpuDevice::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size _t dstRowBytes, 229 bool SkGpuDevice::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size _t dstRowBytes,
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 ASSERT_SINGLE_OWNER 313 ASSERT_SINGLE_OWNER
315 GrColor color = 0; 314 GrColor color = 0;
316 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "clearAll", fContext); 315 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "clearAll", fContext);
317 SkIRect rect = SkIRect::MakeWH(this->width(), this->height()); 316 SkIRect rect = SkIRect::MakeWH(this->width(), this->height());
318 fDrawContext->clear(&rect, color, true); 317 fDrawContext->clear(&rect, color, true);
319 } 318 }
320 319
321 void SkGpuDevice::replaceRenderTarget(bool shouldRetainContent) { 320 void SkGpuDevice::replaceRenderTarget(bool shouldRetainContent) {
322 ASSERT_SINGLE_OWNER 321 ASSERT_SINGLE_OWNER
323 322
324 SkSurface::Budgeted budgeted = 323 SkBudgeted budgeted = fRenderTarget->resourcePriv().isBudgeted();
325 fRenderTarget->resourcePriv().isBudgeted() ? SkSurface::kYes_Budgete d
326 : SkSurface::kNo_Budgeted ;
327 324
328 SkAutoTUnref<GrRenderTarget> newRT(CreateRenderTarget( 325 SkAutoTUnref<GrRenderTarget> newRT(CreateRenderTarget(
329 this->context(), budgeted, this->imageInfo(), fRenderTarget->desc().fSam pleCnt, 326 this->context(), budgeted, this->imageInfo(), fRenderTarget->desc().fSam pleCnt,
330 fRenderTarget->desc().fTextureStorageAllocator)); 327 fRenderTarget->desc().fTextureStorageAllocator));
331 328
332 if (nullptr == newRT) { 329 if (nullptr == newRT) {
333 return; 330 return;
334 } 331 }
335 332
336 if (shouldRetainContent) { 333 if (shouldRetainContent) {
(...skipping 1440 matching lines...) Expand 10 before | Expand all | Expand 10 after
1777 1774
1778 SkAutoTUnref<GrTexture> texture; 1775 SkAutoTUnref<GrTexture> texture;
1779 // Skia's convention is to only clear a device if it is non-opaque. 1776 // Skia's convention is to only clear a device if it is non-opaque.
1780 InitContents init = cinfo.fInfo.isOpaque() ? kUninit_InitContents : kClear_I nitContents; 1777 InitContents init = cinfo.fInfo.isOpaque() ? kUninit_InitContents : kClear_I nitContents;
1781 1778
1782 // layers are never draw in repeat modes, so we can request an approx 1779 // layers are never draw in repeat modes, so we can request an approx
1783 // match and ignore any padding. 1780 // match and ignore any padding.
1784 if (kNever_TileUsage == cinfo.fTileUsage) { 1781 if (kNever_TileUsage == cinfo.fTileUsage) {
1785 texture.reset(fContext->textureProvider()->createApproxTexture(desc)); 1782 texture.reset(fContext->textureProvider()->createApproxTexture(desc));
1786 } else { 1783 } else {
1787 texture.reset(fContext->textureProvider()->createTexture(desc, true)); 1784 texture.reset(fContext->textureProvider()->createTexture(desc, SkBudgete d::kYes));
1788 } 1785 }
1789 1786
1790 if (texture) { 1787 if (texture) {
1791 SkSurfaceProps props(this->surfaceProps().flags(), cinfo.fPixelGeometry) ; 1788 SkSurfaceProps props(this->surfaceProps().flags(), cinfo.fPixelGeometry) ;
1792 return SkGpuDevice::Create( 1789 return SkGpuDevice::Create(
1793 texture->asRenderTarget(), cinfo.fInfo.width(), cinfo.fInfo.height() , &props, init); 1790 texture->asRenderTarget(), cinfo.fInfo.width(), cinfo.fInfo.height() , &props, init);
1794 } else { 1791 } else {
1795 SkErrorInternals::SetError( kInternalError_SkError, 1792 SkErrorInternals::SetError( kInternalError_SkError,
1796 "---- failed to create gpu device texture [% d %d]\n", 1793 "---- failed to create gpu device texture [% d %d]\n",
1797 cinfo.fInfo.width(), cinfo.fInfo.height()); 1794 cinfo.fInfo.width(), cinfo.fInfo.height());
1798 return nullptr; 1795 return nullptr;
1799 } 1796 }
1800 } 1797 }
1801 1798
1802 SkSurface* SkGpuDevice::newSurface(const SkImageInfo& info, const SkSurfaceProps & props) { 1799 SkSurface* SkGpuDevice::newSurface(const SkImageInfo& info, const SkSurfaceProps & props) {
1803 ASSERT_SINGLE_OWNER 1800 ASSERT_SINGLE_OWNER
1804 // TODO: Change the signature of newSurface to take a budgeted parameter. 1801 // TODO: Change the signature of newSurface to take a budgeted parameter.
1805 static const SkSurface::Budgeted kBudgeted = SkSurface::kNo_Budgeted; 1802 static const SkBudgeted kBudgeted = SkBudgeted::kNo;
1806 return SkSurface::NewRenderTarget(fContext, kBudgeted, info, fRenderTarget-> desc().fSampleCnt, 1803 return SkSurface::NewRenderTarget(fContext, kBudgeted, info, fRenderTarget-> desc().fSampleCnt,
1807 &props); 1804 &props);
1808 } 1805 }
1809 1806
1810 bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* mainCanvas, const SkPicture * mainPicture, 1807 bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* mainCanvas, const SkPicture * mainPicture,
1811 const SkMatrix* matrix, const SkPaint * paint) { 1808 const SkMatrix* matrix, const SkPaint * paint) {
1812 ASSERT_SINGLE_OWNER 1809 ASSERT_SINGLE_OWNER
1813 #ifndef SK_IGNORE_GPU_LAYER_HOISTING 1810 #ifndef SK_IGNORE_GPU_LAYER_HOISTING
1814 // todo: should handle this natively 1811 // todo: should handle this natively
1815 if (paint) { 1812 if (paint) {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1883 } 1880 }
1884 1881
1885 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { 1882 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() {
1886 ASSERT_SINGLE_OWNER 1883 ASSERT_SINGLE_OWNER
1887 // We always return a transient cache, so it is freed after each 1884 // We always return a transient cache, so it is freed after each
1888 // filter traversal. 1885 // filter traversal.
1889 return SkGpuDevice::NewImageFilterCache(); 1886 return SkGpuDevice::NewImageFilterCache();
1890 } 1887 }
1891 1888
1892 #endif 1889 #endif
OLDNEW
« no previous file with comments | « src/gpu/SkGpuDevice.h ('k') | src/gpu/SkGr.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698