]> git.sesse.net Git - nageru/blob - ref_counted_frame.h
Properly reset the PBO setting in Mixer::bm_frame(), so new textures are properly...
[nageru] / ref_counted_frame.h
1 #ifndef _REF_COUNTED_FRAME_H
2 #define _REF_COUNTED_FRAME_H 1
3
4 // A wrapper around FrameAllocator::Frame that is automatically refcounted;
5 // when the refcount goes to zero, the frame is given back to the allocator.
6 //
7 // Note that the important point isn't really the pointer to the Frame itself,
8 // it's the resources it's representing that need to go back to the allocator.
9
10 #include <memory>
11
12 #include "bmusb/bmusb.h"
13
14 void release_refcounted_frame(FrameAllocator::Frame *frame);
15
16 typedef std::shared_ptr<FrameAllocator::Frame> RefCountedFrameBase;
17
18 class RefCountedFrame : public RefCountedFrameBase {
19 public:
20         RefCountedFrame() {}
21
22         RefCountedFrame(const FrameAllocator::Frame &frame)
23                 : RefCountedFrameBase(new FrameAllocator::Frame(frame), release_refcounted_frame) {}
24 };
25
26 #endif  // !defined(_REF_COUNTED_FRAME_H)