| 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 "GrDrawTarget.h" | 11 #include "GrDrawTarget.h" |
| 12 #include "GrPathRendererChain.h" |
| 13 #include "GrPathRenderer.h" |
| 12 #include "SkTDArray.h" | 14 #include "SkTDArray.h" |
| 13 | 15 |
| 14 class GrContext; | 16 class GrContext; |
| 15 class GrDrawContext; | 17 class GrDrawContext; |
| 18 class GrSoftwarePathRenderer; |
| 16 class GrTextContext; | 19 class GrTextContext; |
| 17 | 20 |
| 18 // Currently the DrawingManager creates a separate GrTextContext for each | 21 // Currently the DrawingManager creates a separate GrTextContext for each |
| 19 // combination of text drawing options (pixel geometry x DFT use) | 22 // combination of text drawing options (pixel geometry x DFT use) |
| 20 // and hands the appropriate one back given the DrawContext's request. | 23 // and hands the appropriate one back given the DrawContext's request. |
| 21 // | 24 // |
| 22 // It allocates a new GrDrawContext for each GrRenderTarget | 25 // It allocates a new GrDrawContext for each GrRenderTarget |
| 23 // but all of them still land in the same GrDrawTarget! | 26 // but all of them still land in the same GrDrawTarget! |
| 24 // | 27 // |
| 25 // In the future this class will allocate a new GrDrawContext for | 28 // In the future this class will allocate a new GrDrawContext for |
| 26 // each GrRenderTarget/GrDrawTarget and manage the DAG. | 29 // each GrRenderTarget/GrDrawTarget and manage the DAG. |
| 27 class GrDrawingManager { | 30 class GrDrawingManager { |
| 28 public: | 31 public: |
| 29 ~GrDrawingManager(); | 32 ~GrDrawingManager(); |
| 30 | 33 |
| 31 bool abandoned() const { return fAbandoned; } | 34 bool abandoned() const { return fAbandoned; } |
| 35 void freeGpuResources(); |
| 32 | 36 |
| 33 GrDrawContext* drawContext(GrRenderTarget* rt, const SkSurfaceProps* surface
Props); | 37 GrDrawContext* drawContext(GrRenderTarget* rt, const SkSurfaceProps* surface
Props); |
| 34 | 38 |
| 35 GrTextContext* textContext(const SkSurfaceProps& props, GrRenderTarget* rt); | 39 GrTextContext* textContext(const SkSurfaceProps& props, GrRenderTarget* rt); |
| 36 | 40 |
| 37 // The caller automatically gets a ref on the returned drawTarget. It must | 41 // The caller automatically gets a ref on the returned drawTarget. It must |
| 38 // be balanced by an unref call. | 42 // be balanced by an unref call. |
| 39 GrDrawTarget* newDrawTarget(GrRenderTarget* rt); | 43 GrDrawTarget* newDrawTarget(GrRenderTarget* rt); |
| 40 | 44 |
| 41 GrContext* getContext() { return fContext; } | 45 GrContext* getContext() { return fContext; } |
| 42 | 46 |
| 47 GrPathRenderer* getPathRenderer(const GrPathRenderer::CanDrawPathArgs& args, |
| 48 bool allowSW, |
| 49 GrPathRendererChain::DrawType drawType, |
| 50 GrPathRenderer::StencilSupport* stencilSuppo
rt = NULL); |
| 51 |
| 43 private: | 52 private: |
| 44 GrDrawingManager(GrContext* context, GrDrawTarget::Options options) | 53 GrDrawingManager(GrContext* context, GrDrawTarget::Options options) |
| 45 : fContext(context) | 54 : fContext(context) |
| 46 , fAbandoned(false) | 55 , fAbandoned(false) |
| 47 , fOptions(options) | 56 , fOptions(options) |
| 48 , fNVPRTextContext(nullptr) { | 57 , fNVPRTextContext(nullptr) |
| 58 , fPathRendererChain(nullptr) |
| 59 , fSoftwarePathRenderer(nullptr) { |
| 49 sk_bzero(fTextContexts, sizeof(fTextContexts)); | 60 sk_bzero(fTextContexts, sizeof(fTextContexts)); |
| 50 } | 61 } |
| 51 | 62 |
| 52 void abandon(); | 63 void abandon(); |
| 53 void cleanup(); | 64 void cleanup(); |
| 54 void reset(); | 65 void reset(); |
| 55 void flush(); | 66 void flush(); |
| 56 | 67 |
| 57 friend class GrContext; // for access to: ctor, abandon, reset & flush | 68 friend class GrContext; // for access to: ctor, abandon, reset & flush |
| 58 | 69 |
| 59 static const int kNumPixelGeometries = 5; // The different pixel geometries | 70 static const int kNumPixelGeometries = 5; // The different pixel geometries |
| 60 static const int kNumDFTOptions = 2; // DFT or no DFT | 71 static const int kNumDFTOptions = 2; // DFT or no DFT |
| 61 | 72 |
| 62 GrContext* fContext; | 73 GrContext* fContext; |
| 63 | 74 |
| 64 bool fAbandoned; | 75 bool fAbandoned; |
| 65 SkTDArray<GrDrawTarget*> fDrawTargets; | 76 SkTDArray<GrDrawTarget*> fDrawTargets; |
| 66 GrDrawTarget::Options fOptions; | 77 GrDrawTarget::Options fOptions; |
| 67 | 78 |
| 68 GrTextContext* fNVPRTextContext; | 79 GrTextContext* fNVPRTextContext; |
| 69 GrTextContext* fTextContexts[kNumPixelGeometries][kNumDFTOption
s]; | 80 GrTextContext* fTextContexts[kNumPixelGeometries][kNumDFTOption
s]; |
| 81 |
| 82 GrPathRendererChain* fPathRendererChain; |
| 83 GrSoftwarePathRenderer* fSoftwarePathRenderer; |
| 70 }; | 84 }; |
| 71 | 85 |
| 72 #endif | 86 #endif |
| OLD | NEW |