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 "GrDrawTarget.h" |
12 #include "GrPathRendering.h" | 12 #include "GrPathRendering.h" |
13 #include "GrProgramDesc.h" | 13 #include "GrProgramDesc.h" |
14 #include "SkPath.h" | 14 #include "SkPath.h" |
15 | 15 |
16 class GrContext; | 16 class GrContext; |
17 class GrIndexBufferAllocPool; | 17 class GrIndexBufferAllocPool; |
18 class GrOptDrawState; | 18 class GrOptDrawState; |
19 class GrPath; | 19 class GrPath; |
20 class GrPathRange; | 20 class GrPathRange; |
21 class GrPathRenderer; | 21 class GrPathRenderer; |
22 class GrPathRendererChain; | 22 class GrPathRendererChain; |
23 class GrPrimitiveProcessor; | |
23 class GrStencilBuffer; | 24 class GrStencilBuffer; |
24 class GrVertexBufferAllocPool; | 25 class GrVertexBufferAllocPool; |
25 | 26 |
26 class GrGpu : public SkRefCnt { | 27 class GrGpu : public SkRefCnt { |
27 public: | 28 public: |
28 | 29 |
29 /** | 30 /** |
30 * Additional blend coefficients for dual source blending, not exposed | 31 * Additional blend coefficients for dual source blending, not exposed |
31 * through GrPaint/GrContext. | 32 * through GrPaint/GrContext. |
32 */ | 33 */ |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
308 kDrawPath_DrawType, | 309 kDrawPath_DrawType, |
309 kDrawPaths_DrawType, | 310 kDrawPaths_DrawType, |
310 }; | 311 }; |
311 | 312 |
312 static bool IsPathRenderingDrawType(DrawType type) { | 313 static bool IsPathRenderingDrawType(DrawType type) { |
313 return kDrawPath_DrawType == type || kDrawPaths_DrawType == type; | 314 return kDrawPath_DrawType == type || kDrawPaths_DrawType == type; |
314 } | 315 } |
315 | 316 |
316 GrContext::GPUStats* gpuStats() { return &fGPUStats; } | 317 GrContext::GPUStats* gpuStats() { return &fGPUStats; } |
317 | 318 |
318 virtual void buildProgramDesc(const GrOptDrawState&, | 319 virtual void buildProgramDesc(GrProgramDesc*, |
320 const GrPrimitiveProcessor&, | |
321 const GrOptDrawState&, | |
319 const GrProgramDesc::DescInfo&, | 322 const GrProgramDesc::DescInfo&, |
320 GrGpu::DrawType, | 323 GrGpu::DrawType, |
321 GrProgramDesc*) = 0; | 324 const GrBatchTracker&) const = 0; |
322 | 325 |
323 /** | 326 /** |
324 * Called at start and end of gpu trace marking | 327 * Called at start and end of gpu trace marking |
325 * GR_CREATE_GPU_TRACE_MARKER(marker_str, target) will automatically call th ese at the start | 328 * GR_CREATE_GPU_TRACE_MARKER(marker_str, target) will automatically call th ese at the start |
326 * and end of a code block respectively | 329 * and end of a code block respectively |
327 */ | 330 */ |
328 void addGpuTraceMarker(const GrGpuTraceMarker* marker); | 331 void addGpuTraceMarker(const GrGpuTraceMarker* marker); |
329 void removeGpuTraceMarker(const GrGpuTraceMarker* marker); | 332 void removeGpuTraceMarker(const GrGpuTraceMarker* marker); |
330 | 333 |
331 /** | 334 /** |
(...skipping 19 matching lines...) Expand all Loading... | |
351 | 354 |
352 // Called to perform a surface to surface copy. Fallbacks to issuing a draw from the src to dst | 355 // Called to perform a surface to surface copy. Fallbacks to issuing a draw from the src to dst |
353 // take place at the GrDrawTarget level and this function implement faster c opy paths. The rect | 356 // take place at the GrDrawTarget level and this function implement faster c opy paths. The rect |
354 // and point are pre-clipped. The src rect and implied dst rect are guarante ed to be within the | 357 // and point are pre-clipped. The src rect and implied dst rect are guarante ed to be within the |
355 // src/dst bounds and non-empty. | 358 // src/dst bounds and non-empty. |
356 virtual bool copySurface(GrSurface* dst, | 359 virtual bool copySurface(GrSurface* dst, |
357 GrSurface* src, | 360 GrSurface* src, |
358 const SkIRect& srcRect, | 361 const SkIRect& srcRect, |
359 const SkIPoint& dstPoint) = 0; | 362 const SkIPoint& dstPoint) = 0; |
360 | 363 |
361 void draw(const GrOptDrawState&, const GrDrawTarget::DrawInfo&); | 364 struct DrawArgs { |
bsalomon
2015/01/16 21:00:33
Is this going to be a long lived struct? Kind of g
| |
365 typedef GrDrawTarget::DrawInfo DrawInfo; | |
366 DrawArgs(const GrPrimitiveProcessor& primProc, | |
367 const GrOptDrawState& optState, | |
368 const GrProgramDesc& desc, | |
369 const GrBatchTracker& batchTracker) | |
370 : fPrimitiveProcessor(primProc) | |
371 , fOptState(optState) | |
372 , fDesc(desc) | |
373 , fBatchTracker(batchTracker) {} | |
374 const GrPrimitiveProcessor& fPrimitiveProcessor; | |
375 const GrOptDrawState& fOptState; | |
376 const GrProgramDesc& fDesc; | |
377 const GrBatchTracker& fBatchTracker; | |
378 }; | |
379 | |
380 void draw(const DrawArgs&, const GrDrawTarget::DrawInfo&); | |
362 | 381 |
363 /** None of these params are optional, pointers used just to avoid making co pies. */ | 382 /** None of these params are optional, pointers used just to avoid making co pies. */ |
364 struct StencilPathState { | 383 struct StencilPathState { |
365 bool fUseHWAA; | 384 bool fUseHWAA; |
366 GrRenderTarget* fRenderTarget; | 385 GrRenderTarget* fRenderTarget; |
367 const SkMatrix* fViewMatrix; | 386 const SkMatrix* fViewMatrix; |
368 const GrStencilSettings* fStencil; | 387 const GrStencilSettings* fStencil; |
369 const GrScissorState* fScissor; | 388 const GrScissorState* fScissor; |
370 }; | 389 }; |
371 | 390 |
372 void stencilPath(const GrPath*, const StencilPathState&); | 391 void stencilPath(const GrPath*, const StencilPathState&); |
373 | 392 |
374 void drawPath(const GrOptDrawState&, const GrPath*, const GrStencilSettings& ); | 393 void drawPath(const DrawArgs&, const GrPath*, const GrStencilSettings&); |
375 void drawPaths(const GrOptDrawState&, | 394 void drawPaths(const DrawArgs&, |
376 const GrPathRange*, | 395 const GrPathRange*, |
377 const void* indices, | 396 const void* indices, |
378 GrDrawTarget::PathIndexType, | 397 GrDrawTarget::PathIndexType, |
379 const float transformValues[], | 398 const float transformValues[], |
380 GrDrawTarget::PathTransformType, | 399 GrDrawTarget::PathTransformType, |
381 int count, | 400 int count, |
382 const GrStencilSettings&); | 401 const GrStencilSettings&); |
383 | 402 |
384 static DrawType PrimTypeToDrawType(GrPrimitiveType type) { | 403 static DrawType PrimTypeToDrawType(GrPrimitiveType type) { |
385 switch (type) { | 404 switch (type) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
439 bool canIgnoreRect) = 0; | 458 bool canIgnoreRect) = 0; |
440 | 459 |
441 | 460 |
442 // Overridden by backend specific classes to perform a clear of the stencil clip bits. This is | 461 // Overridden by backend specific classes to perform a clear of the stencil clip bits. This is |
443 // ONLY used by the the clip target | 462 // ONLY used by the the clip target |
444 virtual void onClearStencilClip(GrRenderTarget*, | 463 virtual void onClearStencilClip(GrRenderTarget*, |
445 const SkIRect& rect, | 464 const SkIRect& rect, |
446 bool insideClip) = 0; | 465 bool insideClip) = 0; |
447 | 466 |
448 // overridden by backend-specific derived class to perform the draw call. | 467 // overridden by backend-specific derived class to perform the draw call. |
449 virtual void onDraw(const GrOptDrawState&, const GrDrawTarget::DrawInfo&) = 0; | 468 virtual void onDraw(const DrawArgs&, const GrDrawTarget::DrawInfo&) = 0; |
450 virtual void onStencilPath(const GrPath*, const StencilPathState&) = 0; | 469 virtual void onStencilPath(const GrPath*, const StencilPathState&) = 0; |
451 | 470 |
452 virtual void onDrawPath(const GrOptDrawState&, const GrPath*, const GrStenci lSettings&) = 0; | 471 virtual void onDrawPath(const DrawArgs&, const GrPath*, const GrStencilSetti ngs&) = 0; |
453 virtual void onDrawPaths(const GrOptDrawState&, | 472 virtual void onDrawPaths(const DrawArgs&, |
454 const GrPathRange*, | 473 const GrPathRange*, |
455 const void* indices, | 474 const void* indices, |
456 GrDrawTarget::PathIndexType, | 475 GrDrawTarget::PathIndexType, |
457 const float transformValues[], | 476 const float transformValues[], |
458 GrDrawTarget::PathTransformType, | 477 GrDrawTarget::PathTransformType, |
459 int count, | 478 int count, |
460 const GrStencilSettings&) = 0; | 479 const GrStencilSettings&) = 0; |
461 | 480 |
462 // overridden by backend-specific derived class to perform the read pixels. | 481 // overridden by backend-specific derived class to perform the read pixels. |
463 virtual bool onReadPixels(GrRenderTarget* target, | 482 virtual bool onReadPixels(GrRenderTarget* target, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
512 int fGpuTrac eMarkerCount; | 531 int fGpuTrac eMarkerCount; |
513 GrTraceMarkerSet fActiveT raceMarkers; | 532 GrTraceMarkerSet fActiveT raceMarkers; |
514 GrTraceMarkerSet fStoredT raceMarkers; | 533 GrTraceMarkerSet fStoredT raceMarkers; |
515 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. | 534 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. |
516 GrContext* fContext ; | 535 GrContext* fContext ; |
517 | 536 |
518 typedef SkRefCnt INHERITED; | 537 typedef SkRefCnt INHERITED; |
519 }; | 538 }; |
520 | 539 |
521 #endif | 540 #endif |
OLD | NEW |