OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 GrGpu_DEFINED | 8 #ifndef GrGpu_DEFINED |
9 #define GrGpu_DEFINED | 9 #define GrGpu_DEFINED |
10 | 10 |
11 #include "GrDrawTarget.h" | 11 #include "GrPipelineBuilder.h" |
12 #include "GrPathRendering.h" | |
13 #include "GrProgramDesc.h" | 12 #include "GrProgramDesc.h" |
| 13 #include "GrStencil.h" |
| 14 #include "GrTraceMarker.h" |
| 15 #include "GrXferProcessor.h" |
14 #include "SkPath.h" | 16 #include "SkPath.h" |
15 | 17 |
| 18 class GrBatchTracker; |
16 class GrContext; | 19 class GrContext; |
17 struct GrGLInterface; | 20 struct GrGLInterface; |
| 21 class GrIndexBuffer; |
18 class GrNonInstancedVertices; | 22 class GrNonInstancedVertices; |
19 class GrPath; | 23 class GrPath; |
20 class GrPathRange; | 24 class GrPathRange; |
21 class GrPathRenderer; | 25 class GrPathRenderer; |
22 class GrPathRendererChain; | 26 class GrPathRendererChain; |
| 27 class GrPathRendering; |
23 class GrPipeline; | 28 class GrPipeline; |
24 class GrPrimitiveProcessor; | 29 class GrPrimitiveProcessor; |
| 30 class GrRenderTarget; |
25 class GrStencilAttachment; | 31 class GrStencilAttachment; |
| 32 class GrSurface; |
| 33 class GrTexture; |
| 34 class GrVertexBuffer; |
26 class GrVertices; | 35 class GrVertices; |
27 | 36 |
28 class GrGpu : public SkRefCnt { | 37 class GrGpu : public SkRefCnt { |
29 public: | 38 public: |
30 /** | 39 /** |
31 * Create an instance of GrGpu that matches the specified backend. If the re
quested backend is | 40 * Create an instance of GrGpu that matches the specified backend. If the re
quested backend is |
32 * not supported (at compile-time or run-time) this returns NULL. The contex
t will not be | 41 * not supported (at compile-time or run-time) this returns NULL. The contex
t will not be |
33 * fully constructed and should not be used by GrGpu until after this functi
on returns. | 42 * fully constructed and should not be used by GrGpu until after this functi
on returns. |
34 */ | 43 */ |
35 static GrGpu* Create(GrBackend, GrBackendContext, const GrContextOptions&, G
rContext* context); | 44 static GrGpu* Create(GrBackend, GrBackendContext, const GrContextOptions&, G
rContext* context); |
36 | 45 |
37 //////////////////////////////////////////////////////////////////////////// | 46 //////////////////////////////////////////////////////////////////////////// |
38 | 47 |
39 GrGpu(GrContext* context); | 48 GrGpu(GrContext* context); |
40 ~GrGpu() override; | 49 ~GrGpu() override; |
41 | 50 |
42 GrContext* getContext() { return fContext; } | 51 GrContext* getContext() { return fContext; } |
43 const GrContext* getContext() const { return fContext; } | 52 const GrContext* getContext() const { return fContext; } |
44 | 53 |
45 /** | 54 /** |
46 * Gets the capabilities of the draw target. | 55 * Gets the capabilities of the draw target. |
47 */ | 56 */ |
48 const GrCaps* caps() const { return fCaps.get(); } | 57 const GrCaps* caps() const { return fCaps.get(); } |
49 | 58 |
50 GrPathRendering* pathRendering() { return fPathRendering.get(); } | 59 GrPathRendering* pathRendering() { return fPathRendering.get(); } |
51 | 60 |
52 // Called by GrContext when the underlying backend context has been destroye
d. | 61 // Called by GrContext when the underlying backend context has been destroye
d. |
53 // GrGpu should use this to ensure that no backend API calls will be made fr
om | 62 // GrGpu should use this to ensure that no backend API calls will be made fr
om |
54 // here onward, including in its destructor. Subclasses should call | 63 // here onward, including in its destructor. Subclasses should call |
55 // INHERITED::contextAbandoned() if they override this. | 64 // INHERITED::contextAbandoned() if they override this. |
56 virtual void contextAbandoned(); | 65 virtual void contextAbandoned(); |
57 | 66 |
58 /** | 67 /** |
59 * The GrGpu object normally assumes that no outsider is setting state | 68 * The GrGpu object normally assumes that no outsider is setting state |
60 * within the underlying 3D API's context/device/whatever. This call informs | 69 * within the underlying 3D API's context/device/whatever. This call informs |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 SkASSERT(primProc && pipeline && desc && batchTracker); | 301 SkASSERT(primProc && pipeline && desc && batchTracker); |
293 } | 302 } |
294 const GrPrimitiveProcessor* fPrimitiveProcessor; | 303 const GrPrimitiveProcessor* fPrimitiveProcessor; |
295 const GrPipeline* fPipeline; | 304 const GrPipeline* fPipeline; |
296 const GrProgramDesc* fDesc; | 305 const GrProgramDesc* fDesc; |
297 const GrBatchTracker* fBatchTracker; | 306 const GrBatchTracker* fBatchTracker; |
298 }; | 307 }; |
299 | 308 |
300 void draw(const DrawArgs&, const GrVertices&); | 309 void draw(const DrawArgs&, const GrVertices&); |
301 | 310 |
302 /** None of these params are optional, pointers used just to avoid making co
pies. */ | |
303 struct StencilPathState { | |
304 bool fUseHWAA; | |
305 GrRenderTarget* fRenderTarget; | |
306 const SkMatrix* fViewMatrix; | |
307 const GrStencilSettings* fStencil; | |
308 const GrScissorState* fScissor; | |
309 }; | |
310 | |
311 void stencilPath(const GrPath*, const StencilPathState&); | |
312 | |
313 void drawPath(const DrawArgs&, const GrPath*, const GrStencilSettings&); | |
314 void drawPaths(const DrawArgs&, | |
315 const GrPathRange*, | |
316 const void* indices, | |
317 GrDrawTarget::PathIndexType, | |
318 const float transformValues[], | |
319 GrDrawTarget::PathTransformType, | |
320 int count, | |
321 const GrStencilSettings&); | |
322 | |
323 /////////////////////////////////////////////////////////////////////////// | 311 /////////////////////////////////////////////////////////////////////////// |
324 // Debugging and Stats | 312 // Debugging and Stats |
325 | 313 |
326 class Stats { | 314 class Stats { |
327 public: | 315 public: |
328 #if GR_GPU_STATS | 316 #if GR_GPU_STATS |
329 Stats() { this->reset(); } | 317 Stats() { this->reset(); } |
330 | 318 |
331 void reset() { | 319 void reset() { |
332 fRenderTargetBinds = 0; | 320 fRenderTargetBinds = 0; |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 virtual void onClear(GrRenderTarget*, const SkIRect* rect, GrColor color, | 420 virtual void onClear(GrRenderTarget*, const SkIRect* rect, GrColor color, |
433 bool canIgnoreRect) = 0; | 421 bool canIgnoreRect) = 0; |
434 | 422 |
435 | 423 |
436 // Overridden by backend specific classes to perform a clear of the stencil
clip bits. This is | 424 // Overridden by backend specific classes to perform a clear of the stencil
clip bits. This is |
437 // ONLY used by the the clip target | 425 // ONLY used by the the clip target |
438 virtual void onClearStencilClip(GrRenderTarget*, const SkIRect& rect, bool i
nsideClip) = 0; | 426 virtual void onClearStencilClip(GrRenderTarget*, const SkIRect& rect, bool i
nsideClip) = 0; |
439 | 427 |
440 // overridden by backend-specific derived class to perform the draw call. | 428 // overridden by backend-specific derived class to perform the draw call. |
441 virtual void onDraw(const DrawArgs&, const GrNonInstancedVertices&) = 0; | 429 virtual void onDraw(const DrawArgs&, const GrNonInstancedVertices&) = 0; |
442 virtual void onStencilPath(const GrPath*, const StencilPathState&) = 0; | |
443 | 430 |
444 virtual void onDrawPath(const DrawArgs&, const GrPath*, const GrStencilSetti
ngs&) = 0; | |
445 virtual void onDrawPaths(const DrawArgs&, | |
446 const GrPathRange*, | |
447 const void* indices, | |
448 GrDrawTarget::PathIndexType, | |
449 const float transformValues[], | |
450 GrDrawTarget::PathTransformType, | |
451 int count, | |
452 const GrStencilSettings&) = 0; | |
453 | |
454 // overridden by backend-specific derived class to perform the read pixels. | |
455 virtual bool onReadPixels(GrRenderTarget* target, | 431 virtual bool onReadPixels(GrRenderTarget* target, |
456 int left, int top, int width, int height, | 432 int left, int top, int width, int height, |
457 GrPixelConfig, | 433 GrPixelConfig, |
458 void* buffer, | 434 void* buffer, |
459 size_t rowBytes) = 0; | 435 size_t rowBytes) = 0; |
460 | 436 |
461 // overridden by backend-specific derived class to perform the texture updat
e | 437 // overridden by backend-specific derived class to perform the texture updat
e |
462 virtual bool onWriteTexturePixels(GrTexture* texture, | 438 virtual bool onWriteTexturePixels(GrTexture* texture, |
463 int left, int top, int width, int height, | 439 int left, int top, int width, int height, |
464 GrPixelConfig config, const void* buffer, | 440 GrPixelConfig config, const void* buffer, |
(...skipping 30 matching lines...) Expand all Loading... |
495 | 471 |
496 ResetTimestamp fResetTi
mestamp; | 472 ResetTimestamp fResetTi
mestamp; |
497 uint32_t fResetBi
ts; | 473 uint32_t fResetBi
ts; |
498 // To keep track that we always have at least as many debug marker adds as r
emoves | 474 // To keep track that we always have at least as many debug marker adds as r
emoves |
499 int fGpuTrac
eMarkerCount; | 475 int fGpuTrac
eMarkerCount; |
500 GrTraceMarkerSet fActiveT
raceMarkers; | 476 GrTraceMarkerSet fActiveT
raceMarkers; |
501 GrTraceMarkerSet fStoredT
raceMarkers; | 477 GrTraceMarkerSet fStoredT
raceMarkers; |
502 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. | 478 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. |
503 GrContext* fContext
; | 479 GrContext* fContext
; |
504 | 480 |
| 481 friend class GrPathRendering; |
505 typedef SkRefCnt INHERITED; | 482 typedef SkRefCnt INHERITED; |
506 }; | 483 }; |
507 | 484 |
508 #endif | 485 #endif |
OLD | NEW |