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

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

Issue 1717393002: Add "sample locations" feature to GrProcessor (Closed) Base URL: https://skia.googlesource.com/skia.git@upload_getmultisamp
Patch Set: move into GrProcessor Created 4 years, 9 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
OLDNEW
1 /* 1 /*
2 * Copyright 2010 Google Inc. 2 * Copyright 2010 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 8
9 #include "GrGpu.h" 9 #include "GrGpu.h"
10 10
(...skipping 29 matching lines...) Expand all
40 fIndexBuffer.reset(di.indexBuffer()); 40 fIndexBuffer.reset(di.indexBuffer());
41 41
42 return *this; 42 return *this;
43 } 43 }
44 44
45 //////////////////////////////////////////////////////////////////////////////// 45 ////////////////////////////////////////////////////////////////////////////////
46 46
47 GrGpu::GrGpu(GrContext* context) 47 GrGpu::GrGpu(GrContext* context)
48 : fResetTimestamp(kExpiredTimestamp+1) 48 : fResetTimestamp(kExpiredTimestamp+1)
49 , fResetBits(kAll_GrBackendState) 49 , fResetBits(kAll_GrBackendState)
50 , fContext(context) { 50 , fContext(context)
51 , fNextSamplePatternID(1) {
51 } 52 }
52 53
53 GrGpu::~GrGpu() {} 54 GrGpu::~GrGpu() {}
54 55
55 void GrGpu::contextAbandoned() {} 56 void GrGpu::contextAbandoned() {}
56 57
57 //////////////////////////////////////////////////////////////////////////////// 58 ////////////////////////////////////////////////////////////////////////////////
58 59
59 bool GrGpu::makeCopyForTextureParams(int width, int height, const GrTextureParam s& textureParams, 60 bool GrGpu::makeCopyForTextureParams(int width, int height, const GrTextureParam s& textureParams,
60 GrTextureProducer::CopyParams* copyParams) const { 61 GrTextureProducer::CopyParams* copyParams) const {
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 } 438 }
438 return false; 439 return false;
439 } 440 }
440 441
441 void GrGpu::resolveRenderTarget(GrRenderTarget* target) { 442 void GrGpu::resolveRenderTarget(GrRenderTarget* target) {
442 SkASSERT(target); 443 SkASSERT(target);
443 this->handleDirtyContext(); 444 this->handleDirtyContext();
444 this->onResolveRenderTarget(target); 445 this->onResolveRenderTarget(target);
445 } 446 }
446 447
448 const GrGpu::MultisampleSpecs& GrGpu::getMultisampleSpecs(GrRenderTarget* rt,
449 const GrStencilSetting s& stencil) {
450 skstd::unique_ptr<MultisampleSpecs>* specsPtr;
451 bool willUseRasterMultisample = rt->hasMixedSamples() && stencil.isDisabled( );
452 if (willUseRasterMultisample) {
453 int rasterSampleCnt = rt->desc().fSampleCnt;
454 SkASSERT(rasterSampleCnt > 0 && rasterSampleCnt <= this->caps()->maxRast erSamples());
455 fRasterMultisampleSpecs.resize_back(SkTMax(fRasterMultisampleSpecs.count (),
456 rasterSampleCnt));
457 specsPtr = &fRasterMultisampleSpecs[rasterSampleCnt - 1];
458 } else {
459 specsPtr = rt->renderTargetPriv().accessMultisampleSpecs();
460 }
461 if (!specsPtr->get()) {
462 MultisampleSpecs* specs = new MultisampleSpecs;
463 SkSTArray<16, SkPoint, true> samplePattern;
464 this->onGetMultisampleSpecs(rt, stencil, &specs->fEffectiveSampleCnt, &s amplePattern);
465 if (this->caps()->sampleLocationsSupport()) {
466 SkASSERT(!samplePattern.empty());
467 const auto& result = fKnownSamplePatterns.emplace(samplePattern, fNe xtSamplePatternID);
468 if (result.second) {
469 // This sample pattern didn't exist already in the map. (We don' t expect to see very
470 // many unique sample patterns).
471 SkASSERT(fKnownSamplePatterns.size() < 65535);
472 do {} while (0 == ++fNextSamplePatternID);
473 }
474 specs->fSamplePatternID = result.first->second;
475 specs->fSampleLocations = result.first->first.begin();
476 }
477 specsPtr->reset(specs);
478 }
479 return *specsPtr->get();
480 }
481
482 bool GrGpu::SamplePatternComparator::operator()(const SamplePattern& a,
483 const SamplePattern& b) const {
484 if (a.count() != b.count()) {
485 return a.count() < b.count();
486 }
487 for (int i = 0; i < a.count(); ++i) {
488 // This doesn't have geometric meaning. We just need to define an orderi ng for std::map.
489 if (a[i].x() != b[i].x()) {
490 return a[i].x() < b[i].x();
491 }
492 if (a[i].y() != b[i].y()) {
493 return a[i].y() < b[i].y();
494 }
495 }
496 return false; // Equal.
497 }
498
447 //////////////////////////////////////////////////////////////////////////////// 499 ////////////////////////////////////////////////////////////////////////////////
448 500
449 void GrGpu::draw(const DrawArgs& args, const GrVertices& vertices) { 501 void GrGpu::draw(const DrawArgs& args, const GrVertices& vertices) {
450 this->handleDirtyContext(); 502 this->handleDirtyContext();
451 if (GrXferBarrierType barrierType = args.fPipeline->xferBarrierType(*this->c aps())) { 503 if (GrXferBarrierType barrierType = args.fPipeline->xferBarrierType(*this->c aps())) {
452 this->xferBarrier(args.fPipeline->getRenderTarget(), barrierType); 504 this->xferBarrier(args.fPipeline->getRenderTarget(), barrierType);
453 } 505 }
454 506
455 GrVertices::Iterator iter; 507 GrVertices::Iterator iter;
456 const GrNonInstancedVertices* verts = iter.init(vertices); 508 const GrNonInstancedVertices* verts = iter.init(vertices);
457 do { 509 do {
458 this->onDraw(args, *verts); 510 this->onDraw(args, *verts);
459 fStats.incNumDraws(); 511 fStats.incNumDraws();
460 } while ((verts = iter.next())); 512 } while ((verts = iter.next()));
461 } 513 }
462 514
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698