Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: src/gpu/GrGpu.h

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

Powered by Google App Engine
This is Rietveld 408576698