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>
This commit is contained in:
parent
477d0efcf2
commit
e9e91dde4e
@ -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();
|
||||
}
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user