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 { |
| 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 SkASSERT(primProc && optState && desc && batchTracker); |
| 375 } |
| 376 const GrPrimitiveProcessor* fPrimitiveProcessor; |
| 377 const GrOptDrawState* fOptState; |
| 378 const GrProgramDesc* fDesc; |
| 379 const GrBatchTracker* fBatchTracker; |
| 380 }; |
| 381 |
| 382 void draw(const DrawArgs&, const GrDrawTarget::DrawInfo&); |
362 | 383 |
363 /** None of these params are optional, pointers used just to avoid making co
pies. */ | 384 /** None of these params are optional, pointers used just to avoid making co
pies. */ |
364 struct StencilPathState { | 385 struct StencilPathState { |
365 bool fUseHWAA; | 386 bool fUseHWAA; |
366 GrRenderTarget* fRenderTarget; | 387 GrRenderTarget* fRenderTarget; |
367 const SkMatrix* fViewMatrix; | 388 const SkMatrix* fViewMatrix; |
368 const GrStencilSettings* fStencil; | 389 const GrStencilSettings* fStencil; |
369 const GrScissorState* fScissor; | 390 const GrScissorState* fScissor; |
370 }; | 391 }; |
371 | 392 |
372 void stencilPath(const GrPath*, const StencilPathState&); | 393 void stencilPath(const GrPath*, const StencilPathState&); |
373 | 394 |
374 void drawPath(const GrOptDrawState&, const GrPath*, const GrStencilSettings&
); | 395 void drawPath(const DrawArgs&, const GrPath*, const GrStencilSettings&); |
375 void drawPaths(const GrOptDrawState&, | 396 void drawPaths(const DrawArgs&, |
376 const GrPathRange*, | 397 const GrPathRange*, |
377 const void* indices, | 398 const void* indices, |
378 GrDrawTarget::PathIndexType, | 399 GrDrawTarget::PathIndexType, |
379 const float transformValues[], | 400 const float transformValues[], |
380 GrDrawTarget::PathTransformType, | 401 GrDrawTarget::PathTransformType, |
381 int count, | 402 int count, |
382 const GrStencilSettings&); | 403 const GrStencilSettings&); |
383 | 404 |
384 static DrawType PrimTypeToDrawType(GrPrimitiveType type) { | 405 static DrawType PrimTypeToDrawType(GrPrimitiveType type) { |
385 switch (type) { | 406 switch (type) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 bool canIgnoreRect) = 0; | 460 bool canIgnoreRect) = 0; |
440 | 461 |
441 | 462 |
442 // Overridden by backend specific classes to perform a clear of the stencil
clip bits. This is | 463 // Overridden by backend specific classes to perform a clear of the stencil
clip bits. This is |
443 // ONLY used by the the clip target | 464 // ONLY used by the the clip target |
444 virtual void onClearStencilClip(GrRenderTarget*, | 465 virtual void onClearStencilClip(GrRenderTarget*, |
445 const SkIRect& rect, | 466 const SkIRect& rect, |
446 bool insideClip) = 0; | 467 bool insideClip) = 0; |
447 | 468 |
448 // overridden by backend-specific derived class to perform the draw call. | 469 // overridden by backend-specific derived class to perform the draw call. |
449 virtual void onDraw(const GrOptDrawState&, const GrDrawTarget::DrawInfo&) =
0; | 470 virtual void onDraw(const DrawArgs&, const GrDrawTarget::DrawInfo&) = 0; |
450 virtual void onStencilPath(const GrPath*, const StencilPathState&) = 0; | 471 virtual void onStencilPath(const GrPath*, const StencilPathState&) = 0; |
451 | 472 |
452 virtual void onDrawPath(const GrOptDrawState&, const GrPath*, const GrStenci
lSettings&) = 0; | 473 virtual void onDrawPath(const DrawArgs&, const GrPath*, const GrStencilSetti
ngs&) = 0; |
453 virtual void onDrawPaths(const GrOptDrawState&, | 474 virtual void onDrawPaths(const DrawArgs&, |
454 const GrPathRange*, | 475 const GrPathRange*, |
455 const void* indices, | 476 const void* indices, |
456 GrDrawTarget::PathIndexType, | 477 GrDrawTarget::PathIndexType, |
457 const float transformValues[], | 478 const float transformValues[], |
458 GrDrawTarget::PathTransformType, | 479 GrDrawTarget::PathTransformType, |
459 int count, | 480 int count, |
460 const GrStencilSettings&) = 0; | 481 const GrStencilSettings&) = 0; |
461 | 482 |
462 // overridden by backend-specific derived class to perform the read pixels. | 483 // overridden by backend-specific derived class to perform the read pixels. |
463 virtual bool onReadPixels(GrRenderTarget* target, | 484 virtual bool onReadPixels(GrRenderTarget* target, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 int fGpuTrac
eMarkerCount; | 533 int fGpuTrac
eMarkerCount; |
513 GrTraceMarkerSet fActiveT
raceMarkers; | 534 GrTraceMarkerSet fActiveT
raceMarkers; |
514 GrTraceMarkerSet fStoredT
raceMarkers; | 535 GrTraceMarkerSet fStoredT
raceMarkers; |
515 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. | 536 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. |
516 GrContext* fContext
; | 537 GrContext* fContext
; |
517 | 538 |
518 typedef SkRefCnt INHERITED; | 539 typedef SkRefCnt INHERITED; |
519 }; | 540 }; |
520 | 541 |
521 #endif | 542 #endif |
OLD | NEW |