| OLD | NEW |
| 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" | |
| 17 #include "SkTDArray.h" | 16 #include "SkTDArray.h" |
| 18 | 17 |
| 19 class GrContext; | 18 class GrContext; |
| 20 class GrDrawContext; | 19 class GrDrawContext; |
| 21 class GrSingleOWner; | 20 class GrSingleOWner; |
| 22 class GrSoftwarePathRenderer; | 21 class GrSoftwarePathRenderer; |
| 23 | 22 |
| 24 // The GrDrawingManager allocates a new GrDrawContext for each GrRenderTarget | 23 // The GrDrawingManager allocates a new GrDrawContext for each GrRenderTarget |
| 25 // but all of them still land in the same GrDrawTarget! | 24 // but all of them still land in the same GrDrawTarget! |
| 26 // | 25 // |
| (...skipping 16 matching lines...) Expand all Loading... |
| 43 | 42 |
| 44 GrContext* getContext() { return fContext; } | 43 GrContext* getContext() { return fContext; } |
| 45 | 44 |
| 46 GrAtlasTextContext* getAtlasTextContext(); | 45 GrAtlasTextContext* getAtlasTextContext(); |
| 47 | 46 |
| 48 GrPathRenderer* getPathRenderer(const GrPathRenderer::CanDrawPathArgs& args, | 47 GrPathRenderer* getPathRenderer(const GrPathRenderer::CanDrawPathArgs& args, |
| 49 bool allowSW, | 48 bool allowSW, |
| 50 GrPathRendererChain::DrawType drawType, | 49 GrPathRendererChain::DrawType drawType, |
| 51 GrPathRenderer::StencilSupport* stencilSuppo
rt = NULL); | 50 GrPathRenderer::StencilSupport* stencilSuppo
rt = NULL); |
| 52 | 51 |
| 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 | |
| 61 static bool ProgramUnitTest(GrContext* context, int maxStages); | 52 static bool ProgramUnitTest(GrContext* context, int maxStages); |
| 62 | 53 |
| 63 private: | 54 private: |
| 64 GrDrawingManager(GrContext* context, const GrDrawTarget::Options& optionsFor
DrawTargets, | 55 GrDrawingManager(GrContext* context, const GrDrawTarget::Options& optionsFor
DrawTargets, |
| 65 bool isImmediateMode, GrSingleOwner* singleOwner) | 56 GrSingleOwner* singleOwner) |
| 66 : fContext(context) | 57 : fContext(context) |
| 67 , fOptionsForDrawTargets(optionsForDrawTargets) | 58 , fOptionsForDrawTargets(optionsForDrawTargets) |
| 68 , fSingleOwner(singleOwner) | 59 , fSingleOwner(singleOwner) |
| 69 , fAbandoned(false) | 60 , fAbandoned(false) |
| 70 , fAtlasTextContext(nullptr) | 61 , fAtlasTextContext(nullptr) |
| 71 , fPathRendererChain(nullptr) | 62 , fPathRendererChain(nullptr) |
| 72 , fSoftwarePathRenderer(nullptr) | 63 , fSoftwarePathRenderer(nullptr) |
| 73 , fFlushState(context->getGpu(), context->resourceProvider()) | 64 , fFlushState(context->getGpu(), context->resourceProvider()) |
| 74 , fFlushing(false) { | 65 , fFlushing(false) { |
| 75 } | 66 } |
| 76 | 67 |
| 77 void abandon(); | 68 void abandon(); |
| 78 void cleanup(); | 69 void cleanup(); |
| 79 void reset(); | 70 void reset(); |
| 80 void flush() { this->internalFlush(GrResourceCache::FlushType::kExternal); } | 71 /** Returns true if there was anything to flush and false otherwise */ |
| 81 void internalFlush(GrResourceCache::FlushType); | 72 bool flush(); |
| 82 | 73 |
| 83 friend class GrContext; // for access to: ctor, abandon, reset & flush | 74 friend class GrContext; // for access to: ctor, abandon, reset & flush |
| 84 | 75 |
| 85 static const int kNumPixelGeometries = 5; // The different pixel geometries | 76 static const int kNumPixelGeometries = 5; // The different pixel geometries |
| 86 static const int kNumDFTOptions = 2; // DFT or no DFT | 77 static const int kNumDFTOptions = 2; // DFT or no DFT |
| 87 | 78 |
| 88 GrContext* fContext; | 79 GrContext* fContext; |
| 89 GrDrawTarget::Options fOptionsForDrawTargets; | 80 GrDrawTarget::Options fOptionsForDrawTargets; |
| 90 | 81 |
| 91 // In debug builds we guard against improper thread handling | 82 // In debug builds we guard against improper thread handling |
| 92 GrSingleOwner* fSingleOwner; | 83 GrSingleOwner* fSingleOwner; |
| 93 | 84 |
| 94 bool fAbandoned; | 85 bool fAbandoned; |
| 95 SkTDArray<GrDrawTarget*> fDrawTargets; | 86 SkTDArray<GrDrawTarget*> fDrawTargets; |
| 96 | 87 |
| 97 SkAutoTDelete<GrAtlasTextContext> fAtlasTextContext; | 88 SkAutoTDelete<GrAtlasTextContext> fAtlasTextContext; |
| 98 | 89 |
| 99 GrPathRendererChain* fPathRendererChain; | 90 GrPathRendererChain* fPathRendererChain; |
| 100 GrSoftwarePathRenderer* fSoftwarePathRenderer; | 91 GrSoftwarePathRenderer* fSoftwarePathRenderer; |
| 101 | 92 |
| 102 GrBatchFlushState fFlushState; | 93 GrBatchFlushState fFlushState; |
| 103 bool fFlushing; | 94 bool fFlushing; |
| 104 | |
| 105 bool fIsImmediateMode; | |
| 106 }; | 95 }; |
| 107 | 96 |
| 108 #endif | 97 #endif |
| OLD | NEW |