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

Side by Side Diff: include/gpu/GrContext.h

Issue 1413673002: Remove DrawingMgr shims from GrContext (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix names in comments Created 5 years, 2 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 | « no previous file | include/gpu/GrDrawContext.h » ('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 2010 Google Inc. 2 * Copyright 2010 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 GrContext_DEFINED 8 #ifndef GrContext_DEFINED
9 #define GrContext_DEFINED 9 #define GrContext_DEFINED
10 10
11 #include "GrClip.h" 11 #include "GrClip.h"
12 #include "GrColor.h" 12 #include "GrColor.h"
13 #include "GrPaint.h" 13 #include "GrPaint.h"
14 #include "GrPathRendererChain.h" 14 #include "GrPathRendererChain.h"
15 #include "GrRenderTarget.h" 15 #include "GrRenderTarget.h"
16 #include "GrTextureProvider.h" 16 #include "GrTextureProvider.h"
17 #include "SkMatrix.h" 17 #include "SkMatrix.h"
18 #include "../private/SkMutex.h" 18 #include "../private/SkMutex.h"
19 #include "SkPathEffect.h" 19 #include "SkPathEffect.h"
20 #include "SkTypes.h" 20 #include "SkTypes.h"
21 21
22 struct GrBatchAtlasConfig; 22 struct GrBatchAtlasConfig;
23 class GrBatchFontCache; 23 class GrBatchFontCache;
24 class GrCaps; 24 class GrCaps;
25 struct GrContextOptions; 25 struct GrContextOptions;
26 class GrDrawingManager;
26 class GrDrawContext; 27 class GrDrawContext;
27 class GrDrawTarget; 28 class GrDrawTarget;
28 class GrFragmentProcessor; 29 class GrFragmentProcessor;
29 class GrGpu; 30 class GrGpu;
30 class GrIndexBuffer; 31 class GrIndexBuffer;
31 class GrLayerCache; 32 class GrLayerCache;
32 class GrOvalRenderer; 33 class GrOvalRenderer;
33 class GrPath; 34 class GrPath;
34 class GrPathRenderer; 35 class GrPathRenderer;
35 class GrPipelineBuilder; 36 class GrPipelineBuilder;
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 * @param dpi the display density in dots per inch. 166 * @param dpi the display density in dots per inch.
166 * 167 *
167 * @return sample count that should be perform well and have good enough 168 * @return sample count that should be perform well and have good enough
168 * rendering quality for the display. Alternatively returns 0 if 169 * rendering quality for the display. Alternatively returns 0 if
169 * MSAA is not supported or recommended to be used by default. 170 * MSAA is not supported or recommended to be used by default.
170 */ 171 */
171 int getRecommendedSampleCount(GrPixelConfig config, SkScalar dpi) const; 172 int getRecommendedSampleCount(GrPixelConfig config, SkScalar dpi) const;
172 173
173 /** 174 /**
174 * Returns a helper object to orchestrate draws. 175 * Returns a helper object to orchestrate draws.
175 * Callers should take a ref if they rely on the GrDrawContext sticking arou nd. 176 * Callers assume the creation ref of the drawContext
176 * NULL will be returned if the context has been abandoned. 177 * NULL will be returned if the context has been abandoned.
177 * 178 *
178 * @param rt the render target receiving the draws 179 * @param rt the render target receiving the draws
179 * @param surfaceProps the surface properties (mainly defines text drawing) 180 * @param surfaceProps the surface properties (mainly defines text drawing)
180 * 181 *
181 * @return a draw context 182 * @return a draw context
182 */ 183 */
183 GrDrawContext* drawContext(GrRenderTarget* rt, const SkSurfaceProps* surface Props = NULL) { 184 GrDrawContext* drawContext(GrRenderTarget* rt, const SkSurfaceProps* surface Props = NULL);
184 return fDrawingMgr.drawContext(rt, surfaceProps);
185 }
186
187 GrTextContext* textContext(const SkSurfaceProps& surfaceProps, GrRenderTarge t* rt) {
188 return fDrawingMgr.textContext(surfaceProps, rt);
189 }
190
191 // The caller automatically gets a ref on the returned drawTarget. It must
192 // be balanced by an unref call.
193 GrDrawTarget* newDrawTarget(GrRenderTarget* rt) {
194 return fDrawingMgr.newDrawTarget(rt);
195 }
196 185
197 /////////////////////////////////////////////////////////////////////////// 186 ///////////////////////////////////////////////////////////////////////////
198 // Misc. 187 // Misc.
199 188
200 /** 189 /**
201 * Flags that affect flush() behavior. 190 * Flags that affect flush() behavior.
202 */ 191 */
203 enum FlushBits { 192 enum FlushBits {
204 /** 193 /**
205 * A client may reach a point where it has partially rendered a frame 194 * A client may reach a point where it has partially rendered a frame
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 */ 318 */
330 uint32_t uniqueID() { return fUniqueID; } 319 uint32_t uniqueID() { return fUniqueID; }
331 320
332 /////////////////////////////////////////////////////////////////////////// 321 ///////////////////////////////////////////////////////////////////////////
333 // Functions intended for internal use only. 322 // Functions intended for internal use only.
334 GrGpu* getGpu() { return fGpu; } 323 GrGpu* getGpu() { return fGpu; }
335 const GrGpu* getGpu() const { return fGpu; } 324 const GrGpu* getGpu() const { return fGpu; }
336 GrBatchFontCache* getBatchFontCache() { return fBatchFontCache; } 325 GrBatchFontCache* getBatchFontCache() { return fBatchFontCache; }
337 GrLayerCache* getLayerCache() { return fLayerCache.get(); } 326 GrLayerCache* getLayerCache() { return fLayerCache.get(); }
338 GrTextBlobCache* getTextBlobCache() { return fTextBlobCache; } 327 GrTextBlobCache* getTextBlobCache() { return fTextBlobCache; }
339 bool abandoned() const { return fDrawingMgr.abandoned(); } 328 bool abandoned() const;
340 GrResourceProvider* resourceProvider() { return fResourceProvider; } 329 GrResourceProvider* resourceProvider() { return fResourceProvider; }
341 const GrResourceProvider* resourceProvider() const { return fResourceProvide r; } 330 const GrResourceProvider* resourceProvider() const { return fResourceProvide r; }
342 GrResourceCache* getResourceCache() { return fResourceCache; } 331 GrResourceCache* getResourceCache() { return fResourceCache; }
343 332
344 // Called by tests that draw directly to the context via GrDrawTarget 333 // Called by tests that draw directly to the context via GrDrawTarget
345 void getTestTarget(GrTestTarget*); 334 void getTestTarget(GrTestTarget*);
346 335
347 GrPathRenderer* getPathRenderer( 336 GrPathRenderer* getPathRenderer(
348 const GrDrawTarget* target, 337 const GrDrawTarget* target,
349 const GrPipelineBuilder*, 338 const GrPipelineBuilder*,
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 400
412 struct CleanUpData { 401 struct CleanUpData {
413 PFCleanUpFunc fFunc; 402 PFCleanUpFunc fFunc;
414 void* fInfo; 403 void* fInfo;
415 }; 404 };
416 405
417 SkTDArray<CleanUpData> fCleanUpData; 406 SkTDArray<CleanUpData> fCleanUpData;
418 407
419 const uint32_t fUniqueID; 408 const uint32_t fUniqueID;
420 409
410 SkAutoTDelete<GrDrawingManager> fDrawingManager;
411
421 GrContext(); // init must be called after the constructor. 412 GrContext(); // init must be called after the constructor.
422 bool init(GrBackend, GrBackendContext, const GrContextOptions& options); 413 bool init(GrBackend, GrBackendContext, const GrContextOptions& options);
423 414
424 // Currently the DrawingMgr creates a separate GrTextContext for each
425 // combination of text drawing options (pixel geometry x DFT use)
426 // and hands the appropriate one back given the DrawContext's request.
427 //
428 // It allocates a new GrDrawContext for each GrRenderTarget
429 // but all of them still land in the same GrDrawTarget!
430 //
431 // In the future this class will allocate a new GrDrawContext for
432 // each GrRenderTarget/GrDrawTarget and manage the DAG.
433 class DrawingMgr {
434 public:
435 DrawingMgr()
436 : fContext(nullptr)
437 , fAbandoned(false)
438 , fNVPRTextContext(nullptr) {
439 sk_bzero(fTextContexts, sizeof(fTextContexts));
440 }
441
442 ~DrawingMgr();
443
444 void init(GrContext* context);
445
446 void abandon();
447 bool abandoned() const { return fAbandoned; }
448
449 void reset();
450 void flush();
451
452 // Callers assume the creation ref of the drawContext!
453 // NULL will be returned if the context has been abandoned.
454 GrDrawContext* drawContext(GrRenderTarget* rt, const SkSurfaceProps* sur faceProps);
455
456 GrTextContext* textContext(const SkSurfaceProps& props, GrRenderTarget* rt);
457
458 GrDrawTarget* newDrawTarget(GrRenderTarget* rt);
459
460 private:
461 void cleanup();
462
463 friend class GrContext; // for access to fDrawTarget for testing
464
465 static const int kNumPixelGeometries = 5; // The different pixel geometr ies
466 static const int kNumDFTOptions = 2; // DFT or no DFT
467
468 GrContext* fContext;
469
470 bool fAbandoned;
471 SkTDArray<GrDrawTarget*> fDrawTargets;
472
473 GrTextContext* fNVPRTextContext;
474 GrTextContext* fTextContexts[kNumPixelGeometries][kNumDFTOptions];
475 };
476
477 DrawingMgr fDrawingMgr;
478
479 void initMockContext(); 415 void initMockContext();
480 void initCommon(); 416 void initCommon();
481 417
482 /** 418 /**
483 * These functions create premul <-> unpremul effects if it is possible to g enerate a pair 419 * These functions create premul <-> unpremul effects if it is possible to g enerate a pair
484 * of effects that make a readToUPM->writeToPM->readToUPM cycle invariant. O therwise, they 420 * of effects that make a readToUPM->writeToPM->readToUPM cycle invariant. O therwise, they
485 * return NULL. 421 * return NULL.
486 */ 422 */
487 const GrFragmentProcessor* createPMToUPMEffect(GrTexture*, bool swapRAndB, 423 const GrFragmentProcessor* createPMToUPMEffect(GrTexture*, bool swapRAndB,
488 const SkMatrix&) const; 424 const SkMatrix&) const;
(...skipping 16 matching lines...) Expand all
505 /** 441 /**
506 * A callback similar to the above for use by the TextBlobCache 442 * A callback similar to the above for use by the TextBlobCache
507 * TODO move textblob draw calls below context so we can use the call above. 443 * TODO move textblob draw calls below context so we can use the call above.
508 */ 444 */
509 static void TextBlobCacheOverBudgetCB(void* data); 445 static void TextBlobCacheOverBudgetCB(void* data);
510 446
511 typedef SkRefCnt INHERITED; 447 typedef SkRefCnt INHERITED;
512 }; 448 };
513 449
514 #endif 450 #endif
OLDNEW
« no previous file with comments | « no previous file | include/gpu/GrDrawContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698