Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright 2014 Google Inc. | |
| 3 * | |
| 4 * Use of this source code is governed by a BSD-style license that can be | |
| 5 * found in the LICENSE file. | |
| 6 */ | |
| 7 | |
| 8 #ifndef GrProgramResource_DEFINED | |
| 9 #define GrProgramResource_DEFINED | |
| 10 | |
| 11 #include "SkRefCnt.h" | |
| 12 | |
| 13 class GrGpuResource; | |
| 14 | |
| 15 /** | |
|
robertphillips
2014/09/04 17:39:12
Should these be over a space ?
bsalomon
2014/09/04 18:09:42
Done.
| |
| 16 * Class that wraps a resource referenced by a GrProgramElement or GrDrawState. I t manages | |
| 17 * converting refs to pending io operations. Like SkAutoTUnref, its constructor a nd setter adopt | |
| 18 * a ref from their caller. This class is intended only for internal use in core Gr code. | |
| 19 */ | |
| 20 class GrProgramResource : SkNoncopyable { | |
| 21 public: | |
| 22 enum IOType { | |
| 23 kRead_IOType, | |
| 24 kWrite_IOType, | |
| 25 kRW_IOType, | |
| 26 | |
| 27 kNone_IOType, // For internal use only, don't specify to constructor or setResource(). | |
| 28 }; | |
| 29 | |
| 30 SK_DECLARE_INST_COUNT_ROOT(GrProgramResource); | |
| 31 GrProgramResource(); | |
| 32 | |
| 33 /** Adopts a ref from the caller. ioType expresses what type of IO operation s will be marked as | |
| 34 pending on the resource when markPendingIO is called. */ | |
| 35 explicit GrProgramResource(GrGpuResource*, IOType ioType); | |
| 36 | |
| 37 ~GrProgramResource(); | |
| 38 | |
| 39 GrGpuResource* getResource() const { return fResource; } | |
| 40 | |
| 41 /** Adopts a ref from the caller. ioType expresses what type of IO operation s will be marked as | |
| 42 pending on the resource when markPendingIO is called. */ | |
| 43 void setResource(GrGpuResource*, IOType ioType); | |
| 44 | |
| 45 /** Does this object own a pending read or write on the resource it is wrapp ing. */ | |
| 46 bool ownsPendingIO() const { return fPendingIO; } | |
| 47 | |
| 48 /** Shortcut for calling setResource() with NULL. It cannot be called after markingPendingIO | |
| 49 is called. */ | |
| 50 void reset(); | |
| 51 | |
| 52 private: | |
| 53 /** Called by owning GrProgramElement when the program element is first sche duled for | |
| 54 execution. */ | |
| 55 void markPendingIO() const; | |
| 56 | |
| 57 /** Called when the program element/draw state is no longer owned by GrDrawT arget-client code. | |
|
robertphillips
2014/09/04 17:39:12
Should these be over a space ?
bsalomon
2014/09/04 18:09:42
Done.
| |
| 58 This lets the cache know that the drawing code no longer schedule additio nal reads or writes | |
| 59 to the resource using the program element or draw state. */ | |
| 60 void removeRef() const; | |
| 61 | |
| 62 friend class GrDrawState; | |
| 63 friend class GrProgramElement; | |
| 64 | |
| 65 GrGpuResource* fResource; | |
| 66 mutable bool fOwnRef; | |
| 67 mutable bool fPendingIO; | |
| 68 IOType fIOType; | |
| 69 | |
| 70 typedef SkNoncopyable INHERITED; | |
| 71 }; | |
| 72 | |
| 73 #endif | |
| OLD | NEW |