aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Chris Dalton <csmartdalton@google.com>2017-07-14 08:48:57 -0600
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-07-14 15:22:34 +0000
commite9e91dde4e39b085f11d0dc9688c6b63d0410b41 (patch)
tree256b8d1535cd0660bccc60412ada47f6925230b7 /src
parent477d0efcf2d90c70a87c5a126349e76ac57d9649 (diff)
Add "findOrMakeStaticBuffer" to GrOnFlushResourceProvider
Bug: skia: Change-Id: If381c91f40566e6630799ea9985c48e2b738596e Reviewed-on: https://skia-review.googlesource.com/23420 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/gpu/GrOnFlushResourceProvider.cpp16
-rw-r--r--src/gpu/GrOnFlushResourceProvider.h4
2 files changed, 20 insertions, 0 deletions
diff --git a/src/gpu/GrOnFlushResourceProvider.cpp b/src/gpu/GrOnFlushResourceProvider.cpp
index 4ca773f000..d5fd3110ca 100644
--- a/src/gpu/GrOnFlushResourceProvider.cpp
+++ b/src/gpu/GrOnFlushResourceProvider.cpp
@@ -72,6 +72,22 @@ sk_sp<GrBuffer> GrOnFlushResourceProvider::makeBuffer(GrBufferType intendedType,
data));
}
+sk_sp<GrBuffer> GrOnFlushResourceProvider::findOrMakeStaticBuffer(const GrUniqueKey& key,
+ GrBufferType intendedType,
+ size_t size, const void* data) {
+ GrResourceProvider* rp = fDrawingMgr->getContext()->resourceProvider();
+ sk_sp<GrBuffer> buffer(rp->findAndRefTByUniqueKey<GrBuffer>(key));
+ if (!buffer) {
+ buffer.reset(rp->createBuffer(size, intendedType, kStatic_GrAccessPattern, 0, data));
+ if (!buffer) {
+ return nullptr;
+ }
+ SkASSERT(buffer->sizeInBytes() == size); // rp shouldn't bin and/or cache static buffers.
+ buffer->resourcePriv().setUniqueKey(key);
+ }
+ return buffer;
+}
+
const GrCaps* GrOnFlushResourceProvider::caps() const {
return fDrawingMgr->getContext()->caps();
}
diff --git a/src/gpu/GrOnFlushResourceProvider.h b/src/gpu/GrOnFlushResourceProvider.h
index fdf34fe40a..e2c0b73075 100644
--- a/src/gpu/GrOnFlushResourceProvider.h
+++ b/src/gpu/GrOnFlushResourceProvider.h
@@ -71,6 +71,10 @@ public:
// Creates a GPU buffer with a "dynamic" access pattern.
sk_sp<GrBuffer> makeBuffer(GrBufferType, size_t, const void* data = nullptr);
+ // Either finds and refs, or creates a static GPU buffer with the given data.
+ sk_sp<GrBuffer> findOrMakeStaticBuffer(const GrUniqueKey&, GrBufferType,
+ size_t, const void* data);
+
const GrCaps* caps() const;
private: