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

Side by Side Diff: src/gpu/GrPendingProgramElement.h

Issue 739673002: Create GrOptDrawState before recording draw in GrInOrderDrawBuffer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: more Created 6 years, 1 month 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 unified diff | Download patch
OLDNEW
(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 GrPendingProgramElement_DEFINED
9 #define GrPendingProgramElement_DEFINED
10
11 #include "SkRefCnt.h"
12 #include "GrTypes.h"
13
14 /**
15 * Helper for owning a pending execution on a GrProgramElement. Using this rathe r than ref allows
16 * resources that are owned by the program element to be correctly tracked as ha ving pending reads
17 * and writes rather than refs.
18 */
19 template <typename T> class GrPendingProgramElement : SkNoncopyable {
20 public:
21 GrPendingProgramElement() : fObj(NULL) { };
22
23 // Adds a pending execution on obj.
24 explicit GrPendingProgramElement(T* obj) : fObj(obj) {
25 if (obj) {
26 obj->addPendingExecution();
27 }
28 }
29
30 void reset(T* obj) {
31 if (obj) {
32 obj->addPendingExecution();
33 }
34 if (fObj) {
35 fObj->completedExecution();
36 }
37 fObj = obj;
38 }
39
40 void convertToPendingExec() {
41 SkASSERT(!fOwnPendingExec);
42 fObj->convertRefToPendingExecution();
43 fOwnPendingExec = true;
44 }
45
46 T* get() const { return fObj; }
47 operator T*() { return fObj; }
48
49 T *operator->() const {
50 return static_cast<BlockRefType*>(fObj);
51 }
52
53 ~GrPendingProgramElement() {
54 if (fObj) {
55 fObj->completedExecution();
56 }
57 }
58
59 private:
60 T* fObj;
61
62 typedef SkNoncopyable INHERITED;
63 };
64 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698