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

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

Issue 1877073002: Add optional data parameter to createBuffer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase 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/GrResourceProvider.h ('k') | src/gpu/gl/GrGLGpu.h » ('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 2015 Google Inc. 2 * Copyright 2015 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 "GrResourceProvider.h" 8 #include "GrResourceProvider.h"
9 9
10 #include "GrBuffer.h" 10 #include "GrBuffer.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 GrPathRange* GrResourceProvider::createGlyphs(const SkTypeface* tf, 84 GrPathRange* GrResourceProvider::createGlyphs(const SkTypeface* tf,
85 const SkScalerContextEffects& effe cts, 85 const SkScalerContextEffects& effe cts,
86 const SkDescriptor* desc, 86 const SkDescriptor* desc,
87 const GrStrokeInfo& stroke) { 87 const GrStrokeInfo& stroke) {
88 88
89 SkASSERT(this->gpu()->pathRendering()); 89 SkASSERT(this->gpu()->pathRendering());
90 return this->gpu()->pathRendering()->createGlyphs(tf, effects, desc, stroke) ; 90 return this->gpu()->pathRendering()->createGlyphs(tf, effects, desc, stroke) ;
91 } 91 }
92 92
93 GrBuffer* GrResourceProvider::createBuffer(size_t size, GrBufferType intendedTyp e, 93 GrBuffer* GrResourceProvider::createBuffer(size_t size, GrBufferType intendedTyp e,
94 GrAccessPattern accessPattern, uint32 _t flags) { 94 GrAccessPattern accessPattern, uint32 _t flags,
95 const void* data) {
95 if (this->isAbandoned()) { 96 if (this->isAbandoned()) {
96 return nullptr; 97 return nullptr;
97 } 98 }
98 99
99 if (kDynamic_GrAccessPattern == accessPattern) { 100 if (kDynamic_GrAccessPattern == accessPattern) {
100 // bin by pow2 with a reasonable min 101 // bin by pow2 with a reasonable min
101 static const uint32_t MIN_SIZE = 1 << 12; 102 static const uint32_t MIN_SIZE = 1 << 12;
102 size = SkTMax(MIN_SIZE, GrNextPow2(SkToUInt(size))); 103 size = SkTMax(MIN_SIZE, GrNextPow2(SkToUInt(size)));
103 104
104 GrScratchKey key; 105 GrScratchKey key;
105 GrBuffer::ComputeScratchKeyForDynamicBuffer(size, intendedType, &key); 106 GrBuffer::ComputeScratchKeyForDynamicBuffer(size, intendedType, &key);
106 uint32_t scratchFlags = 0; 107 uint32_t scratchFlags = 0;
107 if (flags & kNoPendingIO_Flag) { 108 if (flags & kNoPendingIO_Flag) {
108 scratchFlags = GrResourceCache::kRequireNoPendingIO_ScratchFlag; 109 scratchFlags = GrResourceCache::kRequireNoPendingIO_ScratchFlag;
109 } else { 110 } else {
110 scratchFlags = GrResourceCache::kPreferNoPendingIO_ScratchFlag; 111 scratchFlags = GrResourceCache::kPreferNoPendingIO_ScratchFlag;
111 } 112 }
112 GrGpuResource* resource = this->cache()->findAndRefScratchResource(key, size, scratchFlags); 113 GrGpuResource* resource = this->cache()->findAndRefScratchResource(key, size, scratchFlags);
113 if (resource) { 114 if (GrBuffer* buffer = static_cast<GrBuffer*>(resource)) {
114 return static_cast<GrBuffer*>(resource); 115 if (data) {
116 buffer->updateData(data, size);
117 }
118 return buffer;
115 } 119 }
116 } 120 }
117 return this->gpu()->createBuffer(size, intendedType, accessPattern); 121 return this->gpu()->createBuffer(size, intendedType, accessPattern, data);
118 } 122 }
119 123
120 GrBatchAtlas* GrResourceProvider::createAtlas(GrPixelConfig config, 124 GrBatchAtlas* GrResourceProvider::createAtlas(GrPixelConfig config,
121 int width, int height, 125 int width, int height,
122 int numPlotsX, int numPlotsY, 126 int numPlotsX, int numPlotsY,
123 GrBatchAtlas::EvictionFunc func, v oid* data) { 127 GrBatchAtlas::EvictionFunc func, v oid* data) {
124 GrSurfaceDesc desc; 128 GrSurfaceDesc desc;
125 desc.fFlags = kNone_GrSurfaceFlags; 129 desc.fFlags = kNone_GrSurfaceFlags;
126 desc.fWidth = width; 130 desc.fWidth = width;
127 desc.fHeight = height; 131 desc.fHeight = height;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 return rt->renderTargetPriv().getStencilAttachment(); 191 return rt->renderTargetPriv().getStencilAttachment();
188 } 192 }
189 193
190 GrRenderTarget* GrResourceProvider::wrapBackendTextureAsRenderTarget( 194 GrRenderTarget* GrResourceProvider::wrapBackendTextureAsRenderTarget(
191 const GrBackendTextureDesc& desc) { 195 const GrBackendTextureDesc& desc) {
192 if (this->isAbandoned()) { 196 if (this->isAbandoned()) {
193 return nullptr; 197 return nullptr;
194 } 198 }
195 return this->gpu()->wrapBackendTextureAsRenderTarget(desc); 199 return this->gpu()->wrapBackendTextureAsRenderTarget(desc);
196 } 200 }
OLDNEW
« no previous file with comments | « src/gpu/GrResourceProvider.h ('k') | src/gpu/gl/GrGLGpu.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698