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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrResourceProvider.cpp
diff --git a/src/gpu/GrResourceProvider.cpp b/src/gpu/GrResourceProvider.cpp
index 922e5be320daaf70d00bae144e3e1370a5c948e9..07c12f085d42f355bc5f720709084e5c9d2bca78 100644
--- a/src/gpu/GrResourceProvider.cpp
+++ b/src/gpu/GrResourceProvider.cpp
@@ -96,29 +96,34 @@ GrBuffer* GrResourceProvider::createBuffer(size_t size, GrBufferType intendedTyp
if (this->isAbandoned()) {
return nullptr;
}
+ if (kDynamic_GrAccessPattern != accessPattern) {
+ return this->gpu()->createBuffer(size, intendedType, accessPattern, data);
+ }
- if (kDynamic_GrAccessPattern == accessPattern) {
- // bin by pow2 with a reasonable min
- static const uint32_t MIN_SIZE = 1 << 12;
- size = SkTMax(MIN_SIZE, GrNextPow2(SkToUInt(size)));
-
- GrScratchKey key;
- GrBuffer::ComputeScratchKeyForDynamicBuffer(size, intendedType, &key);
- uint32_t scratchFlags = 0;
- if (flags & kNoPendingIO_Flag) {
- scratchFlags = GrResourceCache::kRequireNoPendingIO_ScratchFlag;
- } else {
- scratchFlags = GrResourceCache::kPreferNoPendingIO_ScratchFlag;
- }
- GrGpuResource* resource = this->cache()->findAndRefScratchResource(key, size, scratchFlags);
- if (GrBuffer* buffer = static_cast<GrBuffer*>(resource)) {
- if (data) {
- buffer->updateData(data, size);
- }
- return buffer;
+ // bin by pow2 with a reasonable min
+ static const uint32_t MIN_SIZE = 1 << 12;
+ size_t allocSize = SkTMax(MIN_SIZE, GrNextPow2(SkToUInt(size)));
+
+ GrScratchKey key;
+ GrBuffer::ComputeScratchKeyForDynamicBuffer(allocSize, intendedType, &key);
+ uint32_t scratchFlags = 0;
+ if (flags & kNoPendingIO_Flag) {
+ scratchFlags = GrResourceCache::kRequireNoPendingIO_ScratchFlag;
+ } else {
+ scratchFlags = GrResourceCache::kPreferNoPendingIO_ScratchFlag;
+ }
+ GrBuffer* buffer = static_cast<GrBuffer*>(
+ this->cache()->findAndRefScratchResource(key, allocSize, scratchFlags));
+ if (!buffer) {
+ buffer = this->gpu()->createBuffer(allocSize, intendedType, kDynamic_GrAccessPattern);
+ if (!buffer) {
+ return nullptr;
}
}
- return this->gpu()->createBuffer(size, intendedType, accessPattern, data);
+ if (data) {
+ buffer->updateData(data, size);
+ }
+ return buffer;
}
GrBatchAtlas* GrResourceProvider::createAtlas(GrPixelConfig config,
« 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