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 |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 // a billion years. | 295 // a billion years. |
296 typedef uint64_t ResetTimestamp; | 296 typedef uint64_t ResetTimestamp; |
297 | 297 |
298 // This timestamp is always older than the current timestamp | 298 // This timestamp is always older than the current timestamp |
299 static const ResetTimestamp kExpiredTimestamp = 0; | 299 static const ResetTimestamp kExpiredTimestamp = 0; |
300 // Returns a timestamp based on the number of times the context was reset. | 300 // Returns a timestamp based on the number of times the context was reset. |
301 // This timestamp can be used to lazily detect when cached 3D context state | 301 // This timestamp can be used to lazily detect when cached 3D context state |
302 // is dirty. | 302 // is dirty. |
303 ResetTimestamp getResetTimestamp() const { return fResetTimestamp; } | 303 ResetTimestamp getResetTimestamp() const { return fResetTimestamp; } |
304 | 304 |
305 enum DrawType { | |
306 kDrawPoints_DrawType, | |
307 kDrawLines_DrawType, | |
308 kDrawTriangles_DrawType, | |
309 kDrawPath_DrawType, | |
310 kDrawPaths_DrawType, | |
311 }; | |
312 | |
313 static bool IsPathRenderingDrawType(DrawType type) { | |
314 return kDrawPath_DrawType == type || kDrawPaths_DrawType == type; | |
315 } | |
316 | |
317 GrContext::GPUStats* gpuStats() { return &fGPUStats; } | 305 GrContext::GPUStats* gpuStats() { return &fGPUStats; } |
318 | 306 |
319 virtual void buildProgramDesc(GrProgramDesc*, | 307 virtual void buildProgramDesc(GrProgramDesc*, |
320 const GrPrimitiveProcessor&, | 308 const GrPrimitiveProcessor&, |
321 const GrOptDrawState&, | 309 const GrOptDrawState&, |
322 const GrProgramDesc::DescInfo&, | 310 const GrProgramDesc::DescInfo&, |
323 GrGpu::DrawType, | |
324 const GrBatchTracker&) const = 0; | 311 const GrBatchTracker&) const = 0; |
325 | 312 |
326 /** | 313 /** |
327 * Called at start and end of gpu trace marking | 314 * Called at start and end of gpu trace marking |
328 * GR_CREATE_GPU_TRACE_MARKER(marker_str, target) will automatically call th
ese at the start | 315 * GR_CREATE_GPU_TRACE_MARKER(marker_str, target) will automatically call th
ese at the start |
329 * and end of a code block respectively | 316 * and end of a code block respectively |
330 */ | 317 */ |
331 void addGpuTraceMarker(const GrGpuTraceMarker* marker); | 318 void addGpuTraceMarker(const GrGpuTraceMarker* marker); |
332 void removeGpuTraceMarker(const GrGpuTraceMarker* marker); | 319 void removeGpuTraceMarker(const GrGpuTraceMarker* marker); |
333 | 320 |
(...skipping 25 matching lines...) Expand all Loading... |
359 virtual bool copySurface(GrSurface* dst, | 346 virtual bool copySurface(GrSurface* dst, |
360 GrSurface* src, | 347 GrSurface* src, |
361 const SkIRect& srcRect, | 348 const SkIRect& srcRect, |
362 const SkIPoint& dstPoint) = 0; | 349 const SkIPoint& dstPoint) = 0; |
363 | 350 |
364 struct DrawArgs { | 351 struct DrawArgs { |
365 typedef GrDrawTarget::DrawInfo DrawInfo; | 352 typedef GrDrawTarget::DrawInfo DrawInfo; |
366 DrawArgs(const GrPrimitiveProcessor* primProc, | 353 DrawArgs(const GrPrimitiveProcessor* primProc, |
367 const GrOptDrawState* optState, | 354 const GrOptDrawState* optState, |
368 const GrProgramDesc* desc, | 355 const GrProgramDesc* desc, |
369 const GrBatchTracker* batchTracker, | 356 const GrBatchTracker* batchTracker) |
370 DrawType drawType) | |
371 : fPrimitiveProcessor(primProc) | 357 : fPrimitiveProcessor(primProc) |
372 , fOptState(optState) | 358 , fOptState(optState) |
373 , fDesc(desc) | 359 , fDesc(desc) |
374 , fBatchTracker(batchTracker) | 360 , fBatchTracker(batchTracker) { |
375 , fDrawType(drawType) { | |
376 SkASSERT(primProc && optState && desc && batchTracker); | 361 SkASSERT(primProc && optState && desc && batchTracker); |
377 } | 362 } |
378 const GrPrimitiveProcessor* fPrimitiveProcessor; | 363 const GrPrimitiveProcessor* fPrimitiveProcessor; |
379 const GrOptDrawState* fOptState; | 364 const GrOptDrawState* fOptState; |
380 const GrProgramDesc* fDesc; | 365 const GrProgramDesc* fDesc; |
381 const GrBatchTracker* fBatchTracker; | 366 const GrBatchTracker* fBatchTracker; |
382 DrawType fDrawType; | |
383 }; | 367 }; |
384 | 368 |
385 void draw(const DrawArgs&, const GrDrawTarget::DrawInfo&); | 369 void draw(const DrawArgs&, const GrDrawTarget::DrawInfo&); |
386 | 370 |
387 /** None of these params are optional, pointers used just to avoid making co
pies. */ | 371 /** None of these params are optional, pointers used just to avoid making co
pies. */ |
388 struct StencilPathState { | 372 struct StencilPathState { |
389 bool fUseHWAA; | 373 bool fUseHWAA; |
390 GrRenderTarget* fRenderTarget; | 374 GrRenderTarget* fRenderTarget; |
391 const SkMatrix* fViewMatrix; | 375 const SkMatrix* fViewMatrix; |
392 const GrStencilSettings* fStencil; | 376 const GrStencilSettings* fStencil; |
393 const GrScissorState* fScissor; | 377 const GrScissorState* fScissor; |
394 }; | 378 }; |
395 | 379 |
396 void stencilPath(const GrPath*, const StencilPathState&); | 380 void stencilPath(const GrPath*, const StencilPathState&); |
397 | 381 |
398 void drawPath(const DrawArgs&, const GrPath*, const GrStencilSettings&); | 382 void drawPath(const DrawArgs&, const GrPath*, const GrStencilSettings&); |
399 void drawPaths(const DrawArgs&, | 383 void drawPaths(const DrawArgs&, |
400 const GrPathRange*, | 384 const GrPathRange*, |
401 const void* indices, | 385 const void* indices, |
402 GrDrawTarget::PathIndexType, | 386 GrDrawTarget::PathIndexType, |
403 const float transformValues[], | 387 const float transformValues[], |
404 GrDrawTarget::PathTransformType, | 388 GrDrawTarget::PathTransformType, |
405 int count, | 389 int count, |
406 const GrStencilSettings&); | 390 const GrStencilSettings&); |
407 | 391 |
408 static DrawType PrimTypeToDrawType(GrPrimitiveType type) { | |
409 switch (type) { | |
410 case kTriangles_GrPrimitiveType: | |
411 case kTriangleStrip_GrPrimitiveType: | |
412 case kTriangleFan_GrPrimitiveType: | |
413 return kDrawTriangles_DrawType; | |
414 case kPoints_GrPrimitiveType: | |
415 return kDrawPoints_DrawType; | |
416 case kLines_GrPrimitiveType: | |
417 case kLineStrip_GrPrimitiveType: | |
418 return kDrawLines_DrawType; | |
419 default: | |
420 SkFAIL("Unexpected primitive type"); | |
421 return kDrawTriangles_DrawType; | |
422 } | |
423 } | |
424 | |
425 protected: | 392 protected: |
426 // Functions used to map clip-respecting stencil tests into normal | 393 // Functions used to map clip-respecting stencil tests into normal |
427 // stencil funcs supported by GPUs. | 394 // stencil funcs supported by GPUs. |
428 static GrStencilFunc ConvertStencilFunc(bool stencilInClip, | 395 static GrStencilFunc ConvertStencilFunc(bool stencilInClip, |
429 GrStencilFunc func); | 396 GrStencilFunc func); |
430 static void ConvertStencilFuncAndMask(GrStencilFunc func, | 397 static void ConvertStencilFuncAndMask(GrStencilFunc func, |
431 bool clipInStencil, | 398 bool clipInStencil, |
432 unsigned int clipBit, | 399 unsigned int clipBit, |
433 unsigned int userBits, | 400 unsigned int userBits, |
434 unsigned int* ref, | 401 unsigned int* ref, |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 int fGpuTrac
eMarkerCount; | 503 int fGpuTrac
eMarkerCount; |
537 GrTraceMarkerSet fActiveT
raceMarkers; | 504 GrTraceMarkerSet fActiveT
raceMarkers; |
538 GrTraceMarkerSet fStoredT
raceMarkers; | 505 GrTraceMarkerSet fStoredT
raceMarkers; |
539 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. | 506 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. |
540 GrContext* fContext
; | 507 GrContext* fContext
; |
541 | 508 |
542 typedef SkRefCnt INHERITED; | 509 typedef SkRefCnt INHERITED; |
543 }; | 510 }; |
544 | 511 |
545 #endif | 512 #endif |
OLD | NEW |