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

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: addressed comments Created 4 years, 10 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 28 matching lines...) Expand all
39 fIndexBuffer.reset(di.indexBuffer()); 39 fIndexBuffer.reset(di.indexBuffer());
40 40
41 return *this; 41 return *this;
42 } 42 }
43 43
44 //////////////////////////////////////////////////////////////////////////////// 44 ////////////////////////////////////////////////////////////////////////////////
45 45
46 GrGpu::GrGpu(GrContext* context) 46 GrGpu::GrGpu(GrContext* context)
47 : fResetTimestamp(kExpiredTimestamp+1) 47 : fResetTimestamp(kExpiredTimestamp+1)
48 , fResetBits(kAll_GrBackendState) 48 , fResetBits(kAll_GrBackendState)
49 , fNextSamplePatternID(1)
49 , fContext(context) { 50 , fContext(context) {
50 } 51 }
51 52
52 GrGpu::~GrGpu() {} 53 GrGpu::~GrGpu() {}
53 54
54 void GrGpu::contextAbandoned() {} 55 void GrGpu::contextAbandoned() {}
55 56
56 //////////////////////////////////////////////////////////////////////////////// 57 ////////////////////////////////////////////////////////////////////////////////
57 58
58 bool GrGpu::makeCopyForTextureParams(int width, int height, const GrTextureParam s& textureParams, 59 bool GrGpu::makeCopyForTextureParams(int width, int height, const GrTextureParam s& textureParams,
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 } 363 }
363 return false; 364 return false;
364 } 365 }
365 366
366 void GrGpu::resolveRenderTarget(GrRenderTarget* target) { 367 void GrGpu::resolveRenderTarget(GrRenderTarget* target) {
367 SkASSERT(target); 368 SkASSERT(target);
368 this->handleDirtyContext(); 369 this->handleDirtyContext();
369 this->onResolveRenderTarget(target); 370 this->onResolveRenderTarget(target);
370 } 371 }
371 372
373 const GrGpu::MultisampleSpecs& GrGpu::getMultisampleSpecs(GrRenderTarget* rt,
374 const GrStencilSetting s& stencil) {
375 skstd::unique_ptr<MultisampleSpecs>* specsPtr;
376 bool willUseRasterMultisample = rt->hasMixedSamples() && stencil.isDisabled( );
377 if (willUseRasterMultisample) {
378 int rasterSampleCnt = rt->desc().fSampleCnt;
379 SkASSERT(rasterSampleCnt > 0);
380 fRasterMultisampleSpecs.resize_back(SkTMax(fRasterMultisampleSpecs.count (),
381 rasterSampleCnt));
382 specsPtr = &fRasterMultisampleSpecs[rasterSampleCnt - 1];
383 } else {
384 specsPtr = rt->renderTargetPriv().accessMultisampleSpecs();
385 }
386 if (!specsPtr->get()) {
387 MultisampleSpecs* specs = new MultisampleSpecs;
388 SkSTArray<16, SkPoint, true> samplePattern;
389 this->onGetMultisampleSpecs(rt, stencil, &specs->fEffectiveSampleCnt, &s amplePattern);
390 if (this->caps()->sampleLocationsSupport()) {
391 SkASSERT(!samplePattern.empty());
392 const auto& result = fKnownSamplePatterns.emplace(samplePattern, fNe xtSamplePatternID);
393 if (result.second) {
394 // This sample pattern didn't exist already in the map. (We don' t expect to see very
395 // many unique sample patterns).
396 SkASSERT(fKnownSamplePatterns.size() < 65535);
397 do {} while (0 == ++fNextSamplePatternID);
398 }
399 specs->fSamplePatternID = result.first->second;
400 specs->fSampleLocations = result.first->first.begin();
401 }
402 specsPtr->reset(specs);
403 }
404 return *specsPtr->get();
405 }
406
407 bool GrGpu::SamplePatternComparator::operator()(const SamplePattern& a,
408 const SamplePattern& b) const {
409 if (a.count() != b.count()) {
410 return a.count() < b.count();
411 }
412 for (int i = 0; i < a.count(); ++i) {
413 // This doesn't have geometric meaning. We just need to define an orderi ng for std::map.
414 if (a[i].x() != b[i].x()) {
415 return a[i].x() < b[i].x();
416 }
417 if (a[i].y() != b[i].y()) {
418 return a[i].y() < b[i].y();
419 }
420 }
421 return false; // Equal.
422 }
423
372 //////////////////////////////////////////////////////////////////////////////// 424 ////////////////////////////////////////////////////////////////////////////////
373 425
374 void GrGpu::draw(const DrawArgs& args, const GrVertices& vertices) { 426 void GrGpu::draw(const DrawArgs& args, const GrVertices& vertices) {
375 this->handleDirtyContext(); 427 this->handleDirtyContext();
376 if (GrXferBarrierType barrierType = args.fPipeline->xferBarrierType(*this->c aps())) { 428 if (GrXferBarrierType barrierType = args.fPipeline->xferBarrierType(*this->c aps())) {
377 this->xferBarrier(args.fPipeline->getRenderTarget(), barrierType); 429 this->xferBarrier(args.fPipeline->getRenderTarget(), barrierType);
378 } 430 }
379 431
380 GrVertices::Iterator iter; 432 GrVertices::Iterator iter;
381 const GrNonInstancedVertices* verts = iter.init(vertices); 433 const GrNonInstancedVertices* verts = iter.init(vertices);
382 do { 434 do {
383 this->onDraw(args, *verts); 435 this->onDraw(args, *verts);
384 fStats.incNumDraws(); 436 fStats.incNumDraws();
385 } while ((verts = iter.next())); 437 } while ((verts = iter.next()));
386 } 438 }
387 439
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698