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 "GrGpuCommandBuffer.h" | 11 #include "GrGpuCommandBuffer.h" |
12 #include "GrProgramDesc.h" | 12 #include "GrProgramDesc.h" |
13 #include "GrSwizzle.h" | 13 #include "GrSwizzle.h" |
14 #include "GrAllocator.h" | 14 #include "GrAllocator.h" |
15 #include "GrTextureParamsAdjuster.h" | 15 #include "GrTextureParamsAdjuster.h" |
16 #include "GrTypes.h" | 16 #include "GrTypes.h" |
17 #include "GrXferProcessor.h" | 17 #include "GrXferProcessor.h" |
18 #include "SkPath.h" | 18 #include "SkPath.h" |
19 #include "SkTArray.h" | 19 #include "SkTArray.h" |
20 #include <map> | |
21 | 20 |
22 class GrBatchTracker; | 21 class GrBatchTracker; |
23 class GrBuffer; | 22 class GrBuffer; |
24 class GrContext; | 23 class GrContext; |
25 struct GrContextOptions; | 24 struct GrContextOptions; |
26 class GrGLContext; | 25 class GrGLContext; |
27 class GrMesh; | 26 class GrMesh; |
28 class GrNonInstancedVertices; | 27 class GrNonInstancedVertices; |
29 class GrPath; | 28 class GrPath; |
30 class GrPathRange; | 29 class GrPathRange; |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 // Called to perform a surface to surface copy. Fallbacks to issuing a draw
from the src to dst | 334 // Called to perform a surface to surface copy. Fallbacks to issuing a draw
from the src to dst |
336 // take place at the GrDrawTarget level and this function implement faster c
opy paths. The rect | 335 // take place at the GrDrawTarget level and this function implement faster c
opy paths. The rect |
337 // and point are pre-clipped. The src rect and implied dst rect are guarante
ed to be within the | 336 // and point are pre-clipped. The src rect and implied dst rect are guarante
ed to be within the |
338 // src/dst bounds and non-empty. | 337 // src/dst bounds and non-empty. |
339 bool copySurface(GrSurface* dst, | 338 bool copySurface(GrSurface* dst, |
340 GrSurface* src, | 339 GrSurface* src, |
341 const SkIRect& srcRect, | 340 const SkIRect& srcRect, |
342 const SkIPoint& dstPoint); | 341 const SkIPoint& dstPoint); |
343 | 342 |
344 struct MultisampleSpecs { | 343 struct MultisampleSpecs { |
345 MultisampleSpecs(uint8_t uniqueID, int effectiveSampleCnt, const SkPoint
* locations) | |
346 : fUniqueID(uniqueID), | |
347 fEffectiveSampleCnt(effectiveSampleCnt), | |
348 fSampleLocations(locations) {} | |
349 | |
350 // Nonzero ID that uniquely identifies these multisample specs. | 344 // Nonzero ID that uniquely identifies these multisample specs. |
351 uint8_t fUniqueID; | 345 uint8_t fUniqueID; |
352 // The actual number of samples the GPU will run. NOTE: this value can b
e greater than the | 346 // The actual number of samples the GPU will run. NOTE: this value can b
e greater than the |
353 // the render target's sample count. | 347 // the render target's sample count. |
354 int fEffectiveSampleCnt; | 348 int fEffectiveSampleCnt; |
355 // If sample locations are supported, points to the subpixel locations a
t which the GPU will | 349 // If sample locations are supported, contains the subpixel locations at
which the GPU will |
356 // sample. Pixel center is at (.5, .5), and (0, 0) indicates the top lef
t corner. | 350 // sample. Pixel center is at (.5, .5) and (0, 0) indicates the top left
corner. |
357 const SkPoint* fSampleLocations; | 351 SkAutoTDeleteArray<const SkPoint> fSampleLocations; |
358 }; | 352 }; |
359 | 353 |
360 // Finds a render target's multisample specs. The stencil settings are only
needed to flush the | 354 // Finds a render target's multisample specs. The stencil settings are only
needed to flush the |
361 // draw state prior to querying multisample information; they should not hav
e any effect on the | 355 // draw state prior to querying multisample information; they should not hav
e any effect on the |
362 // multisample information itself. | 356 // multisample information itself. |
363 const MultisampleSpecs& getMultisampleSpecs(GrRenderTarget*, const GrStencil
Settings&); | 357 const MultisampleSpecs& getMultisampleSpecs(GrRenderTarget*, const GrStencil
Settings&); |
364 | 358 |
365 // Creates a GrGpuCommandBuffer in which the GrDrawTarget can send draw comm
ands to instead of | 359 // Creates a GrGpuCommandBuffer in which the GrDrawTarget can send draw comm
ands to instead of |
366 // directly to the Gpu object. | 360 // directly to the Gpu object. |
367 virtual GrGpuCommandBuffer* createCommandBuffer( | 361 virtual GrGpuCommandBuffer* createCommandBuffer( |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 } | 497 } |
504 | 498 |
505 // Handles cases where a surface will be updated without a call to flushRend
erTarget | 499 // Handles cases where a surface will be updated without a call to flushRend
erTarget |
506 void didWriteToSurface(GrSurface* surface, const SkIRect* bounds, uint32_t m
ipLevels = 1) const; | 500 void didWriteToSurface(GrSurface* surface, const SkIRect* bounds, uint32_t m
ipLevels = 1) const; |
507 | 501 |
508 Stats fStats; | 502 Stats fStats; |
509 SkAutoTDelete<GrPathRendering> fPathRendering; | 503 SkAutoTDelete<GrPathRendering> fPathRendering; |
510 // Subclass must initialize this in its constructor. | 504 // Subclass must initialize this in its constructor. |
511 SkAutoTUnref<const GrCaps> fCaps; | 505 SkAutoTUnref<const GrCaps> fCaps; |
512 | 506 |
513 typedef SkTArray<SkPoint, true> SamplePattern; | |
514 | |
515 private: | 507 private: |
516 // called when the 3D context state is unknown. Subclass should emit any | 508 // called when the 3D context state is unknown. Subclass should emit any |
517 // assumed 3D context state and dirty any state cache. | 509 // assumed 3D context state and dirty any state cache. |
518 virtual void onResetContext(uint32_t resetBits) = 0; | 510 virtual void onResetContext(uint32_t resetBits) = 0; |
519 | 511 |
520 // Called before certain draws in order to guarantee coherent results from d
st reads. | 512 // Called before certain draws in order to guarantee coherent results from d
st reads. |
521 virtual void xferBarrier(GrRenderTarget*, GrXferBarrierType) = 0; | 513 virtual void xferBarrier(GrRenderTarget*, GrXferBarrierType) = 0; |
522 | 514 |
523 // overridden by backend-specific derived class to create objects. | 515 // overridden by backend-specific derived class to create objects. |
524 // Texture size and sample size will have already been validated in base cla
ss before | 516 // Texture size and sample size will have already been validated in base cla
ss before |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 // overridden by backend-specific derived class to perform the resolve | 562 // overridden by backend-specific derived class to perform the resolve |
571 virtual void onResolveRenderTarget(GrRenderTarget* target) = 0; | 563 virtual void onResolveRenderTarget(GrRenderTarget* target) = 0; |
572 | 564 |
573 // overridden by backend specific derived class to perform the copy surface | 565 // overridden by backend specific derived class to perform the copy surface |
574 virtual bool onCopySurface(GrSurface* dst, | 566 virtual bool onCopySurface(GrSurface* dst, |
575 GrSurface* src, | 567 GrSurface* src, |
576 const SkIRect& srcRect, | 568 const SkIRect& srcRect, |
577 const SkIPoint& dstPoint) = 0; | 569 const SkIPoint& dstPoint) = 0; |
578 | 570 |
579 // overridden by backend specific derived class to perform the multisample q
ueries | 571 // overridden by backend specific derived class to perform the multisample q
ueries |
580 virtual void onGetMultisampleSpecs(GrRenderTarget*, const GrStencilSettings&
, | 572 virtual void onGetMultisampleSpecs(GrRenderTarget*, |
581 int* effectiveSampleCnt, SamplePattern*)
= 0; | 573 const GrStencilSettings&, |
| 574 int* effectiveSampleCnt, |
| 575 SkAutoTDeleteArray<SkPoint>* sampleLocati
ons) = 0; |
582 | 576 |
583 void resetContext() { | 577 void resetContext() { |
584 this->onResetContext(fResetBits); | 578 this->onResetContext(fResetBits); |
585 fResetBits = 0; | 579 fResetBits = 0; |
586 ++fResetTimestamp; | 580 ++fResetTimestamp; |
587 } | 581 } |
588 | 582 |
589 struct SamplePatternComparator { | 583 ResetTimestamp fResetTi
mestamp; |
590 bool operator()(const SamplePattern&, const SamplePattern&) const; | 584 uint32_t fResetBi
ts; |
591 }; | 585 SkTArray<const MultisampleSpecs*, true> fMultisa
mpleSpecsMap; |
592 | 586 GrTAllocator<MultisampleSpecs> fMultisa
mpleSpecsAllocator; |
593 ResetTimestamp fResetTimestamp; | |
594 uint32_t fResetBits; | |
595 std::map<SamplePattern, uint8_t, SamplePatternComparator> fMultisampleSpec
sIdMap; | |
596 SkSTArray<1, MultisampleSpecs, true> fMultisampleSpec
s; | |
597 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. | 587 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. |
598 GrContext* fContext; | 588 GrContext* fContext
; |
599 | 589 |
600 friend class GrPathRendering; | 590 friend class GrPathRendering; |
601 friend class gr_instanced::InstancedRendering; | 591 friend class gr_instanced::InstancedRendering; |
602 typedef SkRefCnt INHERITED; | 592 typedef SkRefCnt INHERITED; |
603 }; | 593 }; |
604 | 594 |
605 #endif | 595 #endif |
OLD | NEW |