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 "GrPipelineBuilder.h" | 11 #include "GrPipelineBuilder.h" |
12 #include "GrProgramDesc.h" | 12 #include "GrProgramDesc.h" |
13 #include "GrStencil.h" | 13 #include "GrStencil.h" |
14 #include "GrTraceMarker.h" | |
15 #include "GrXferProcessor.h" | 14 #include "GrXferProcessor.h" |
16 #include "SkPath.h" | 15 #include "SkPath.h" |
17 | 16 |
18 class GrBatchTracker; | 17 class GrBatchTracker; |
19 class GrContext; | 18 class GrContext; |
20 class GrGLContext; | 19 class GrGLContext; |
21 class GrIndexBuffer; | 20 class GrIndexBuffer; |
22 class GrNonInstancedVertices; | 21 class GrNonInstancedVertices; |
23 class GrPath; | 22 class GrPath; |
24 class GrPathRange; | 23 class GrPathRange; |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 void incRenderTargetBinds() {} | 355 void incRenderTargetBinds() {} |
357 void incShaderCompilations() {} | 356 void incShaderCompilations() {} |
358 void incTextureCreates() {} | 357 void incTextureCreates() {} |
359 void incTextureUploads() {} | 358 void incTextureUploads() {} |
360 void incStencilAttachmentCreates() {} | 359 void incStencilAttachmentCreates() {} |
361 #endif | 360 #endif |
362 }; | 361 }; |
363 | 362 |
364 Stats* stats() { return &fStats; } | 363 Stats* stats() { return &fStats; } |
365 | 364 |
366 /** | |
367 * Called at start and end of gpu trace marking | |
368 * GR_CREATE_GPU_TRACE_MARKER(marker_str, target) will automatically call th
ese at the start | |
369 * and end of a code block respectively | |
370 */ | |
371 void addGpuTraceMarker(const GrGpuTraceMarker* marker); | |
372 void removeGpuTraceMarker(const GrGpuTraceMarker* marker); | |
373 | |
374 /** | |
375 * Takes the current active set of markers and stores them for later use. An
y current marker | |
376 * in the active set is removed from the active set and the targets remove f
unction is called. | |
377 * These functions do not work as a stack so you cannot call save a second t
ime before calling | |
378 * restore. Also, it is assumed that when restore is called the current acti
ve set of markers | |
379 * is empty. When the stored markers are added back into the active set, the
targets add marker | |
380 * is called. | |
381 */ | |
382 void saveActiveTraceMarkers(); | |
383 void restoreActiveTraceMarkers(); | |
384 | |
385 // creation and deletion of raw texture for testing | 365 // creation and deletion of raw texture for testing |
386 // only to be used in GPU-specific tests | 366 // only to be used in GPU-specific tests |
387 virtual GrBackendObject createTestingOnlyBackendTexture(void* pixels, int w,
int h, | 367 virtual GrBackendObject createTestingOnlyBackendTexture(void* pixels, int w,
int h, |
388 GrPixelConfig config
) const = 0; | 368 GrPixelConfig config
) const = 0; |
389 virtual bool isTestingOnlyBackendTexture(GrBackendObject id) const = 0; | 369 virtual bool isTestingOnlyBackendTexture(GrBackendObject id) const = 0; |
390 virtual void deleteTestingOnlyBackendTexture(GrBackendObject id) const = 0; | 370 virtual void deleteTestingOnlyBackendTexture(GrBackendObject id) const = 0; |
391 | 371 |
392 // Given a rt, find or create a stencil buffer and attach it | 372 // Given a rt, find or create a stencil buffer and attach it |
393 bool attachStencilAttachmentToRenderTarget(GrRenderTarget* target); | 373 bool attachStencilAttachmentToRenderTarget(GrRenderTarget* target); |
394 | 374 |
(...skipping 15 matching lines...) Expand all Loading... |
410 static void ElevateDrawPreference(GrGpu::DrawPreference* preference, | 390 static void ElevateDrawPreference(GrGpu::DrawPreference* preference, |
411 GrGpu::DrawPreference elevation) { | 391 GrGpu::DrawPreference elevation) { |
412 GR_STATIC_ASSERT(GrGpu::kCallerPrefersDraw_DrawPreference > GrGpu::kNoDr
aw_DrawPreference); | 392 GR_STATIC_ASSERT(GrGpu::kCallerPrefersDraw_DrawPreference > GrGpu::kNoDr
aw_DrawPreference); |
413 GR_STATIC_ASSERT(GrGpu::kGpuPrefersDraw_DrawPreference > | 393 GR_STATIC_ASSERT(GrGpu::kGpuPrefersDraw_DrawPreference > |
414 GrGpu::kCallerPrefersDraw_DrawPreference); | 394 GrGpu::kCallerPrefersDraw_DrawPreference); |
415 GR_STATIC_ASSERT(GrGpu::kRequireDraw_DrawPreference > | 395 GR_STATIC_ASSERT(GrGpu::kRequireDraw_DrawPreference > |
416 GrGpu::kGpuPrefersDraw_DrawPreference); | 396 GrGpu::kGpuPrefersDraw_DrawPreference); |
417 *preference = SkTMax(*preference, elevation); | 397 *preference = SkTMax(*preference, elevation); |
418 } | 398 } |
419 | 399 |
420 const GrTraceMarkerSet& getActiveTraceMarkers() const { return fActiveTraceM
arkers; } | |
421 | |
422 Stats fStats; | 400 Stats fStats; |
423 SkAutoTDelete<GrPathRendering> fPathRendering; | 401 SkAutoTDelete<GrPathRendering> fPathRendering; |
424 // Subclass must initialize this in its constructor. | 402 // Subclass must initialize this in its constructor. |
425 SkAutoTUnref<const GrCaps> fCaps; | 403 SkAutoTUnref<const GrCaps> fCaps; |
426 | 404 |
427 private: | 405 private: |
428 // called when the 3D context state is unknown. Subclass should emit any | 406 // called when the 3D context state is unknown. Subclass should emit any |
429 // assumed 3D context state and dirty any state cache. | 407 // assumed 3D context state and dirty any state cache. |
430 virtual void onResetContext(uint32_t resetBits) = 0; | 408 virtual void onResetContext(uint32_t resetBits) = 0; |
431 | 409 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 // Should attach the SB to the RT. Returns false if compatible sb could | 470 // Should attach the SB to the RT. Returns false if compatible sb could |
493 // not be created. | 471 // not be created. |
494 virtual bool createStencilAttachmentForRenderTarget(GrRenderTarget*, int wid
th, int height) = 0; | 472 virtual bool createStencilAttachmentForRenderTarget(GrRenderTarget*, int wid
th, int height) = 0; |
495 | 473 |
496 // attaches an existing SB to an existing RT. | 474 // attaches an existing SB to an existing RT. |
497 virtual bool attachStencilAttachmentToRenderTarget(GrStencilAttachment*, GrR
enderTarget*) = 0; | 475 virtual bool attachStencilAttachmentToRenderTarget(GrStencilAttachment*, GrR
enderTarget*) = 0; |
498 | 476 |
499 // clears target's entire stencil buffer to 0 | 477 // clears target's entire stencil buffer to 0 |
500 virtual void clearStencil(GrRenderTarget* target) = 0; | 478 virtual void clearStencil(GrRenderTarget* target) = 0; |
501 | 479 |
502 virtual void didAddGpuTraceMarker() = 0; | |
503 virtual void didRemoveGpuTraceMarker() = 0; | |
504 | |
505 void resetContext() { | 480 void resetContext() { |
506 this->onResetContext(fResetBits); | 481 this->onResetContext(fResetBits); |
507 fResetBits = 0; | 482 fResetBits = 0; |
508 ++fResetTimestamp; | 483 ++fResetTimestamp; |
509 } | 484 } |
510 | 485 |
511 void handleDirtyContext() { | 486 void handleDirtyContext() { |
512 if (fResetBits) { | 487 if (fResetBits) { |
513 this->resetContext(); | 488 this->resetContext(); |
514 } | 489 } |
515 } | 490 } |
516 | 491 |
517 ResetTimestamp fResetTi
mestamp; | 492 ResetTimestamp fResetTi
mestamp; |
518 uint32_t fResetBi
ts; | 493 uint32_t fResetBi
ts; |
519 // To keep track that we always have at least as many debug marker adds as r
emoves | |
520 int fGpuTrac
eMarkerCount; | |
521 GrTraceMarkerSet fActiveT
raceMarkers; | |
522 GrTraceMarkerSet fStoredT
raceMarkers; | |
523 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. | 494 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. |
524 GrContext* fContext
; | 495 GrContext* fContext
; |
525 | 496 |
526 friend class GrPathRendering; | 497 friend class GrPathRendering; |
527 typedef SkRefCnt INHERITED; | 498 typedef SkRefCnt INHERITED; |
528 }; | 499 }; |
529 | 500 |
530 #endif | 501 #endif |
OLD | NEW |