Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 SamplePattern pattern; | |
| 389 this->onGetMultisampleSpecs(rt, stencil, &specs->fEffectiveSampleCnt, &p attern); | |
| 390 if (this->caps()->sampleLocationsSupport()) { | |
| 391 SkASSERT(!pattern.empty()); | |
| 392 const auto& result = fKnownSamplePatterns.emplace(pattern, fNextSamp lePatternID); | |
| 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::SamplePattern::operator <(const SamplePattern& other) const { | |
| 408 if (this->count() != other.count()) { | |
| 409 return this->count() < other.count(); | |
| 410 } | |
| 411 for (int i = 0; i < this->count(); ++i) { | |
| 412 if ((*this)[i].x() != other[i].x()) { | |
| 413 return (*this)[i].x() < other[i].x(); | |
| 414 } | |
| 415 if ((*this)[i].y() != other[i].y()) { | |
| 416 return (*this)[i].y() < other[i].y(); | |
| 417 } | |
|
Mark Kilgard
2016/02/22 18:41:04
should you use SkPoint::operator< instead if it ex
Chris Dalton
2016/02/22 19:10:43
This particular test doesn't have any real geometr
Chris Dalton
2016/02/22 22:17:55
Done.
| |
| 418 } | |
| 419 return false; // Equal. | |
| 420 } | |
| 421 | |
| 372 //////////////////////////////////////////////////////////////////////////////// | 422 //////////////////////////////////////////////////////////////////////////////// |
| 373 | 423 |
| 374 void GrGpu::draw(const DrawArgs& args, const GrVertices& vertices) { | 424 void GrGpu::draw(const DrawArgs& args, const GrVertices& vertices) { |
| 375 this->handleDirtyContext(); | 425 this->handleDirtyContext(); |
| 376 if (GrXferBarrierType barrierType = args.fPipeline->xferBarrierType(*this->c aps())) { | 426 if (GrXferBarrierType barrierType = args.fPipeline->xferBarrierType(*this->c aps())) { |
| 377 this->xferBarrier(args.fPipeline->getRenderTarget(), barrierType); | 427 this->xferBarrier(args.fPipeline->getRenderTarget(), barrierType); |
| 378 } | 428 } |
| 379 | 429 |
| 380 GrVertices::Iterator iter; | 430 GrVertices::Iterator iter; |
| 381 const GrNonInstancedVertices* verts = iter.init(vertices); | 431 const GrNonInstancedVertices* verts = iter.init(vertices); |
| 382 do { | 432 do { |
| 383 this->onDraw(args, *verts); | 433 this->onDraw(args, *verts); |
| 384 fStats.incNumDraws(); | 434 fStats.incNumDraws(); |
| 385 } while ((verts = iter.next())); | 435 } while ((verts = iter.next())); |
| 386 } | 436 } |
| 387 | 437 |
| OLD | NEW |