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

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

Issue 1911703002: Fix data parameter for createBuffer (Closed) Base URL: https://skia.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 | « no previous file | no next file » | 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 const void* data) {
96 if (this->isAbandoned()) { 96 if (this->isAbandoned()) {
97 return nullptr; 97 return nullptr;
98 } 98 }
99 if (kDynamic_GrAccessPattern != accessPattern) {
100 return this->gpu()->createBuffer(size, intendedType, accessPattern, data );
101 }
99 102
100 if (kDynamic_GrAccessPattern == accessPattern) { 103 // bin by pow2 with a reasonable min
101 // bin by pow2 with a reasonable min 104 static const uint32_t MIN_SIZE = 1 << 12;
102 static const uint32_t MIN_SIZE = 1 << 12; 105 size_t allocSize = SkTMax(MIN_SIZE, GrNextPow2(SkToUInt(size)));
103 size = SkTMax(MIN_SIZE, GrNextPow2(SkToUInt(size)));
104 106
105 GrScratchKey key; 107 GrScratchKey key;
106 GrBuffer::ComputeScratchKeyForDynamicBuffer(size, intendedType, &key); 108 GrBuffer::ComputeScratchKeyForDynamicBuffer(allocSize, intendedType, &key);
107 uint32_t scratchFlags = 0; 109 uint32_t scratchFlags = 0;
108 if (flags & kNoPendingIO_Flag) { 110 if (flags & kNoPendingIO_Flag) {
109 scratchFlags = GrResourceCache::kRequireNoPendingIO_ScratchFlag; 111 scratchFlags = GrResourceCache::kRequireNoPendingIO_ScratchFlag;
110 } else { 112 } else {
111 scratchFlags = GrResourceCache::kPreferNoPendingIO_ScratchFlag; 113 scratchFlags = GrResourceCache::kPreferNoPendingIO_ScratchFlag;
112 } 114 }
113 GrGpuResource* resource = this->cache()->findAndRefScratchResource(key, size, scratchFlags); 115 GrBuffer* buffer = static_cast<GrBuffer*>(
114 if (GrBuffer* buffer = static_cast<GrBuffer*>(resource)) { 116 this->cache()->findAndRefScratchResource(key, allocSize, scratchFlags));
115 if (data) { 117 if (!buffer) {
116 buffer->updateData(data, size); 118 buffer = this->gpu()->createBuffer(allocSize, intendedType, kDynamic_GrA ccessPattern);
117 } 119 if (!buffer) {
118 return buffer; 120 return nullptr;
119 } 121 }
120 } 122 }
121 return this->gpu()->createBuffer(size, intendedType, accessPattern, data); 123 if (data) {
124 buffer->updateData(data, size);
125 }
126 return buffer;
122 } 127 }
123 128
124 GrBatchAtlas* GrResourceProvider::createAtlas(GrPixelConfig config, 129 GrBatchAtlas* GrResourceProvider::createAtlas(GrPixelConfig config,
125 int width, int height, 130 int width, int height,
126 int numPlotsX, int numPlotsY, 131 int numPlotsX, int numPlotsY,
127 GrBatchAtlas::EvictionFunc func, v oid* data) { 132 GrBatchAtlas::EvictionFunc func, v oid* data) {
128 GrSurfaceDesc desc; 133 GrSurfaceDesc desc;
129 desc.fFlags = kNone_GrSurfaceFlags; 134 desc.fFlags = kNone_GrSurfaceFlags;
130 desc.fWidth = width; 135 desc.fWidth = width;
131 desc.fHeight = height; 136 desc.fHeight = height;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 return rt->renderTargetPriv().getStencilAttachment(); 197 return rt->renderTargetPriv().getStencilAttachment();
193 } 198 }
194 199
195 GrRenderTarget* GrResourceProvider::wrapBackendTextureAsRenderTarget( 200 GrRenderTarget* GrResourceProvider::wrapBackendTextureAsRenderTarget(
196 const GrBackendTextureDesc& desc) { 201 const GrBackendTextureDesc& desc) {
197 if (this->isAbandoned()) { 202 if (this->isAbandoned()) {
198 return nullptr; 203 return nullptr;
199 } 204 }
200 return this->gpu()->wrapBackendTextureAsRenderTarget(desc); 205 return this->gpu()->wrapBackendTextureAsRenderTarget(desc);
201 } 206 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698