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

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

Issue 2307053002: Restructure flushing relationship between GrContext, GrDrawingManager, and GrResourceCache. (Closed)
Patch Set: Fix uninit vars Created 4 years, 3 months 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
« no previous file with comments | « src/gpu/GrDrawContext.cpp ('k') | src/gpu/GrDrawingManager.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef GrDrawingManager_DEFINED 8 #ifndef GrDrawingManager_DEFINED
9 #define GrDrawingManager_DEFINED 9 #define GrDrawingManager_DEFINED
10 10
11 #include "text/GrAtlasTextContext.h" 11 #include "text/GrAtlasTextContext.h"
12 #include "GrDrawTarget.h" 12 #include "GrDrawTarget.h"
13 #include "GrBatchFlushState.h" 13 #include "GrBatchFlushState.h"
14 #include "GrPathRendererChain.h" 14 #include "GrPathRendererChain.h"
15 #include "GrPathRenderer.h" 15 #include "GrPathRenderer.h"
16 #include "GrResourceCache.h"
16 #include "SkTDArray.h" 17 #include "SkTDArray.h"
17 18
18 class GrContext; 19 class GrContext;
19 class GrDrawContext; 20 class GrDrawContext;
20 class GrSingleOWner; 21 class GrSingleOWner;
21 class GrSoftwarePathRenderer; 22 class GrSoftwarePathRenderer;
22 23
23 // The GrDrawingManager allocates a new GrDrawContext for each GrRenderTarget 24 // The GrDrawingManager allocates a new GrDrawContext for each GrRenderTarget
24 // but all of them still land in the same GrDrawTarget! 25 // but all of them still land in the same GrDrawTarget!
25 // 26 //
(...skipping 16 matching lines...) Expand all
42 43
43 GrContext* getContext() { return fContext; } 44 GrContext* getContext() { return fContext; }
44 45
45 GrAtlasTextContext* getAtlasTextContext(); 46 GrAtlasTextContext* getAtlasTextContext();
46 47
47 GrPathRenderer* getPathRenderer(const GrPathRenderer::CanDrawPathArgs& args, 48 GrPathRenderer* getPathRenderer(const GrPathRenderer::CanDrawPathArgs& args,
48 bool allowSW, 49 bool allowSW,
49 GrPathRendererChain::DrawType drawType, 50 GrPathRendererChain::DrawType drawType,
50 GrPathRenderer::StencilSupport* stencilSuppo rt = NULL); 51 GrPathRenderer::StencilSupport* stencilSuppo rt = NULL);
51 52
53 void flushIfNecessary() {
54 if (fContext->getResourceCache()->requestsFlush()) {
55 this->internalFlush(GrResourceCache::kCacheRequested);
56 } else if (fIsImmediateMode) {
57 this->internalFlush(GrResourceCache::kImmediateMode);
58 }
59 }
60
52 static bool ProgramUnitTest(GrContext* context, int maxStages); 61 static bool ProgramUnitTest(GrContext* context, int maxStages);
53 62
54 private: 63 private:
55 GrDrawingManager(GrContext* context, const GrDrawTarget::Options& optionsFor DrawTargets, 64 GrDrawingManager(GrContext* context, const GrDrawTarget::Options& optionsFor DrawTargets,
56 GrSingleOwner* singleOwner) 65 bool isImmediateMode, GrSingleOwner* singleOwner)
57 : fContext(context) 66 : fContext(context)
58 , fOptionsForDrawTargets(optionsForDrawTargets) 67 , fOptionsForDrawTargets(optionsForDrawTargets)
59 , fSingleOwner(singleOwner) 68 , fSingleOwner(singleOwner)
60 , fAbandoned(false) 69 , fAbandoned(false)
61 , fAtlasTextContext(nullptr) 70 , fAtlasTextContext(nullptr)
62 , fPathRendererChain(nullptr) 71 , fPathRendererChain(nullptr)
63 , fSoftwarePathRenderer(nullptr) 72 , fSoftwarePathRenderer(nullptr)
64 , fFlushState(context->getGpu(), context->resourceProvider()) 73 , fFlushState(context->getGpu(), context->resourceProvider())
65 , fFlushing(false) { 74 , fFlushing(false)
75 , fIsImmediateMode(isImmediateMode) {
66 } 76 }
67 77
68 void abandon(); 78 void abandon();
69 void cleanup(); 79 void cleanup();
70 void reset(); 80 void reset();
71 /** Returns true if there was anything to flush and false otherwise */ 81 void flush() { this->internalFlush(GrResourceCache::FlushType::kExternal); }
72 bool flush(); 82 void internalFlush(GrResourceCache::FlushType);
73 83
74 friend class GrContext; // for access to: ctor, abandon, reset & flush 84 friend class GrContext; // for access to: ctor, abandon, reset & flush
75 85
76 static const int kNumPixelGeometries = 5; // The different pixel geometries 86 static const int kNumPixelGeometries = 5; // The different pixel geometries
77 static const int kNumDFTOptions = 2; // DFT or no DFT 87 static const int kNumDFTOptions = 2; // DFT or no DFT
78 88
79 GrContext* fContext; 89 GrContext* fContext;
80 GrDrawTarget::Options fOptionsForDrawTargets; 90 GrDrawTarget::Options fOptionsForDrawTargets;
81 91
82 // In debug builds we guard against improper thread handling 92 // In debug builds we guard against improper thread handling
83 GrSingleOwner* fSingleOwner; 93 GrSingleOwner* fSingleOwner;
84 94
85 bool fAbandoned; 95 bool fAbandoned;
86 SkTDArray<GrDrawTarget*> fDrawTargets; 96 SkTDArray<GrDrawTarget*> fDrawTargets;
87 97
88 SkAutoTDelete<GrAtlasTextContext> fAtlasTextContext; 98 SkAutoTDelete<GrAtlasTextContext> fAtlasTextContext;
89 99
90 GrPathRendererChain* fPathRendererChain; 100 GrPathRendererChain* fPathRendererChain;
91 GrSoftwarePathRenderer* fSoftwarePathRenderer; 101 GrSoftwarePathRenderer* fSoftwarePathRenderer;
92 102
93 GrBatchFlushState fFlushState; 103 GrBatchFlushState fFlushState;
94 bool fFlushing; 104 bool fFlushing;
105
106 bool fIsImmediateMode;
95 }; 107 };
96 108
97 #endif 109 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrDrawContext.cpp ('k') | src/gpu/GrDrawingManager.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698