2013-08-21 19:27:48 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2013 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
Revert "Revert "Plumb GrBackendTexture throughout skia.""
This reverts commit 7fa5c31c2c9af834bee66d5fcf476e250076c8d6.
Reason for revert: Relanding this change now that other fixes have landed.
Original change's description:
> Revert "Plumb GrBackendTexture throughout skia."
>
> This reverts commit 7da62b9059f3c1d31624a0e4da96ee5f908f9c12.
>
> Reason for revert: fix android roll
>
> Original change's description:
> > Plumb GrBackendTexture throughout skia.
> >
> > Bug: skia:
> > Change-Id: I1bae6768ee7229818a83ba608035a1f7867e6875
> > Reviewed-on: https://skia-review.googlesource.com/13645
> > Commit-Queue: Greg Daniel <egdaniel@google.com>
> > Reviewed-by: Robert Phillips <robertphillips@google.com>
> >
>
> TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com,brianosman@google.com,reviews@skia.org,stani@google.com
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
>
> Change-Id: I5cb8763cc837c83ebc6d10366fe2dd3efe35fb89
> Reviewed-on: https://skia-review.googlesource.com/13773
> Reviewed-by: Stan Iliev <stani@google.com>
> Commit-Queue: Stan Iliev <stani@google.com>
>
TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com,reviews@skia.org,brianosman@google.com,stani@google.com
# Not skipping CQ checks because original CL landed > 1 day ago.
Change-Id: I92bc074e4fe37fa5c83186afadc472c03802e8f2
Reviewed-on: https://skia-review.googlesource.com/13975
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2017-04-20 16:41:55 +00:00
|
|
|
#include "GrBackendSurface.h"
|
2018-09-25 13:31:10 +00:00
|
|
|
#include "GrClip.h"
|
2015-05-22 21:01:46 +00:00
|
|
|
#include "GrContextOptions.h"
|
2017-05-05 15:26:15 +00:00
|
|
|
#include "GrContextPriv.h"
|
2016-12-16 23:59:19 +00:00
|
|
|
#include "GrDrawOpAtlas.h"
|
2015-10-17 14:43:27 +00:00
|
|
|
#include "GrDrawingManager.h"
|
2017-06-15 16:07:18 +00:00
|
|
|
#include "GrGpu.h"
|
2015-02-13 22:20:05 +00:00
|
|
|
#include "GrGpuResourceCacheAccess.h"
|
2018-06-19 17:09:54 +00:00
|
|
|
#include "GrMemoryPool.h"
|
2017-05-12 18:09:46 +00:00
|
|
|
#include "GrRenderTargetContext.h"
|
2016-12-16 23:59:19 +00:00
|
|
|
#include "GrRenderTargetContextPriv.h"
|
2016-08-10 18:09:07 +00:00
|
|
|
#include "GrRenderTargetProxy.h"
|
2015-02-11 18:49:59 +00:00
|
|
|
#include "GrResourceCache.h"
|
2017-03-01 22:01:09 +00:00
|
|
|
#include "GrSemaphore.h"
|
2017-05-12 18:09:46 +00:00
|
|
|
#include "GrSurfaceContextPriv.h"
|
2017-06-13 16:44:56 +00:00
|
|
|
#include "GrTexture.h"
|
2017-03-07 21:58:08 +00:00
|
|
|
#include "SkGr.h"
|
2016-12-20 13:57:26 +00:00
|
|
|
#include "SkImage_Gpu.h"
|
2016-06-08 00:21:10 +00:00
|
|
|
#include "SkMathPriv.h"
|
2015-02-03 02:26:03 +00:00
|
|
|
#include "SkString.h"
|
2018-06-13 13:59:02 +00:00
|
|
|
#include "SkTo.h"
|
2018-06-18 15:51:36 +00:00
|
|
|
#include "ccpr/GrCoverageCountingPathRenderer.h"
|
2017-05-12 18:09:46 +00:00
|
|
|
#include "ops/GrMeshDrawOp.h"
|
2018-03-01 16:36:45 +00:00
|
|
|
#include "text/GrGlyphCache.h"
|
2015-12-11 14:11:21 +00:00
|
|
|
#include "text/GrTextBlobCache.h"
|
2018-09-19 15:31:27 +00:00
|
|
|
|
2018-06-13 13:59:02 +00:00
|
|
|
#include <algorithm>
|
2015-12-11 14:11:21 +00:00
|
|
|
|
2016-11-08 13:49:39 +00:00
|
|
|
bool GrSurfaceProxy::isWrapped_ForTesting() const {
|
|
|
|
return SkToBool(fTarget);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GrRenderTargetContext::isWrapped_ForTesting() const {
|
|
|
|
return fRenderTargetProxy->isWrapped_ForTesting();
|
|
|
|
}
|
|
|
|
|
2018-03-06 13:20:37 +00:00
|
|
|
void GrContextPriv::setTextBlobCacheLimit_ForTesting(size_t bytes) {
|
|
|
|
fContext->fTextBlobCache->setBudget(bytes);
|
2015-08-03 17:17:44 +00:00
|
|
|
}
|
|
|
|
|
2013-08-21 19:27:48 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2018-03-06 13:20:37 +00:00
|
|
|
void GrContextPriv::purgeAllUnlockedResources_ForTesting() {
|
|
|
|
fContext->fResourceCache->purgeAllUnlocked();
|
2013-12-18 17:25:33 +00:00
|
|
|
}
|
2014-11-05 22:47:41 +00:00
|
|
|
|
2018-03-06 13:20:37 +00:00
|
|
|
void GrContextPriv::resetGpuStats() const {
|
2015-12-02 17:05:37 +00:00
|
|
|
#if GR_GPU_STATS
|
2018-03-06 13:20:37 +00:00
|
|
|
fContext->fGpu->stats()->reset();
|
2015-12-02 17:05:37 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2018-03-06 13:20:37 +00:00
|
|
|
void GrContextPriv::dumpCacheStats(SkString* out) const {
|
2015-02-03 02:26:03 +00:00
|
|
|
#if GR_CACHE_STATS
|
2018-03-06 13:20:37 +00:00
|
|
|
fContext->fResourceCache->dumpStats(out);
|
2015-02-03 02:26:03 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2018-03-06 13:20:37 +00:00
|
|
|
void GrContextPriv::dumpCacheStatsKeyValuePairs(SkTArray<SkString>* keys,
|
|
|
|
SkTArray<double>* values) const {
|
2015-12-02 22:08:25 +00:00
|
|
|
#if GR_CACHE_STATS
|
2018-03-06 13:20:37 +00:00
|
|
|
fContext->fResourceCache->dumpStatsKeyValuePairs(keys, values);
|
2015-12-02 22:08:25 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2018-03-06 13:20:37 +00:00
|
|
|
void GrContextPriv::printCacheStats() const {
|
2015-02-03 02:26:03 +00:00
|
|
|
SkString out;
|
|
|
|
this->dumpCacheStats(&out);
|
2015-02-19 14:32:12 +00:00
|
|
|
SkDebugf("%s", out.c_str());
|
2015-02-03 02:26:03 +00:00
|
|
|
}
|
|
|
|
|
2018-03-06 13:20:37 +00:00
|
|
|
void GrContextPriv::dumpGpuStats(SkString* out) const {
|
2015-02-03 02:26:03 +00:00
|
|
|
#if GR_GPU_STATS
|
2018-03-06 13:20:37 +00:00
|
|
|
return fContext->fGpu->stats()->dump(out);
|
2015-02-03 02:26:03 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2018-03-06 13:20:37 +00:00
|
|
|
void GrContextPriv::dumpGpuStatsKeyValuePairs(SkTArray<SkString>* keys,
|
|
|
|
SkTArray<double>* values) const {
|
2015-12-02 17:05:37 +00:00
|
|
|
#if GR_GPU_STATS
|
2018-03-06 13:20:37 +00:00
|
|
|
return fContext->fGpu->stats()->dumpKeyValuePairs(keys, values);
|
2015-12-02 17:05:37 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2018-03-06 13:20:37 +00:00
|
|
|
void GrContextPriv::printGpuStats() const {
|
2015-02-03 02:26:03 +00:00
|
|
|
SkString out;
|
|
|
|
this->dumpGpuStats(&out);
|
2015-02-19 14:32:12 +00:00
|
|
|
SkDebugf("%s", out.c_str());
|
2015-02-03 02:26:03 +00:00
|
|
|
}
|
|
|
|
|
2018-03-06 13:20:37 +00:00
|
|
|
sk_sp<SkImage> GrContextPriv::getFontAtlasImage_ForTesting(GrMaskFormat format, unsigned int index) {
|
2018-03-07 20:13:18 +00:00
|
|
|
auto atlasManager = this->getAtlasManager();
|
|
|
|
if (!atlasManager) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2015-11-08 16:07:24 +00:00
|
|
|
|
2018-05-16 18:54:41 +00:00
|
|
|
unsigned int numActiveProxies;
|
|
|
|
const sk_sp<GrTextureProxy>* proxies = atlasManager->getProxies(format, &numActiveProxies);
|
|
|
|
if (index >= numActiveProxies || !proxies || !proxies[index]) {
|
2017-02-28 21:20:03 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2018-01-22 17:45:47 +00:00
|
|
|
SkASSERT(proxies[index]->priv().isExact());
|
2018-05-24 18:08:31 +00:00
|
|
|
sk_sp<SkImage> image(new SkImage_Gpu(sk_ref_sp(fContext), kNeedNewImageUniqueID,
|
|
|
|
kPremul_SkAlphaType, proxies[index], nullptr,
|
|
|
|
SkBudgeted::kNo));
|
2016-12-20 13:57:26 +00:00
|
|
|
return image;
|
2015-12-09 02:53:44 +00:00
|
|
|
}
|
2015-11-08 16:07:24 +00:00
|
|
|
|
2015-02-03 02:26:03 +00:00
|
|
|
#if GR_GPU_STATS
|
|
|
|
void GrGpu::Stats::dump(SkString* out) {
|
|
|
|
out->appendf("Render Target Binds: %d\n", fRenderTargetBinds);
|
|
|
|
out->appendf("Shader Compilations: %d\n", fShaderCompilations);
|
2015-02-03 05:19:50 +00:00
|
|
|
out->appendf("Textures Created: %d\n", fTextureCreates);
|
|
|
|
out->appendf("Texture Uploads: %d\n", fTextureUploads);
|
2016-01-05 18:41:27 +00:00
|
|
|
out->appendf("Transfers to Texture: %d\n", fTransfersToTexture);
|
2015-04-16 18:22:42 +00:00
|
|
|
out->appendf("Stencil Buffer Creates: %d\n", fStencilAttachmentCreates);
|
2015-09-08 20:42:05 +00:00
|
|
|
out->appendf("Number of draws: %d\n", fNumDraws);
|
2015-02-03 02:26:03 +00:00
|
|
|
}
|
2015-12-02 17:05:37 +00:00
|
|
|
|
|
|
|
void GrGpu::Stats::dumpKeyValuePairs(SkTArray<SkString>* keys, SkTArray<double>* values) {
|
|
|
|
keys->push_back(SkString("render_target_binds")); values->push_back(fRenderTargetBinds);
|
|
|
|
keys->push_back(SkString("shader_compilations")); values->push_back(fShaderCompilations);
|
|
|
|
keys->push_back(SkString("texture_uploads")); values->push_back(fTextureUploads);
|
|
|
|
keys->push_back(SkString("number_of_draws")); values->push_back(fNumDraws);
|
2016-03-23 18:50:26 +00:00
|
|
|
keys->push_back(SkString("number_of_failed_draws")); values->push_back(fNumFailedDraws);
|
2015-12-02 17:05:37 +00:00
|
|
|
}
|
|
|
|
|
2015-02-03 02:26:03 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if GR_CACHE_STATS
|
2015-11-09 21:51:06 +00:00
|
|
|
void GrResourceCache::getStats(Stats* stats) const {
|
|
|
|
stats->reset();
|
2015-02-03 02:26:03 +00:00
|
|
|
|
2015-11-09 21:51:06 +00:00
|
|
|
stats->fTotal = this->getResourceCount();
|
|
|
|
stats->fNumNonPurgeable = fNonpurgeableResources.count();
|
|
|
|
stats->fNumPurgeable = fPurgeableQueue.count();
|
2015-02-03 02:26:03 +00:00
|
|
|
|
2015-02-17 23:09:34 +00:00
|
|
|
for (int i = 0; i < fNonpurgeableResources.count(); ++i) {
|
2015-11-09 21:51:06 +00:00
|
|
|
stats->update(fNonpurgeableResources[i]);
|
2015-02-17 23:09:34 +00:00
|
|
|
}
|
|
|
|
for (int i = 0; i < fPurgeableQueue.count(); ++i) {
|
2015-11-09 21:51:06 +00:00
|
|
|
stats->update(fPurgeableQueue.at(i));
|
2015-02-03 02:26:03 +00:00
|
|
|
}
|
2015-11-09 21:51:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GrResourceCache::dumpStats(SkString* out) const {
|
|
|
|
this->validate();
|
|
|
|
|
|
|
|
Stats stats;
|
|
|
|
|
|
|
|
this->getStats(&stats);
|
2015-02-03 02:26:03 +00:00
|
|
|
|
|
|
|
float countUtilization = (100.f * fBudgetedCount) / fMaxCount;
|
|
|
|
float byteUtilization = (100.f * fBudgetedBytes) / fMaxBytes;
|
|
|
|
|
|
|
|
out->appendf("Budget: %d items %d bytes\n", fMaxCount, (int)fMaxBytes);
|
|
|
|
out->appendf("\t\tEntry Count: current %d"
|
Refactor to separate backend object lifecycle and GpuResource budget decision
Refactor GrGpuResource to contain two different pieces of state:
a) instance is budgeted or not budgeted
b) instance references wrapped backend objects or not
The "object lifecycle" was also attached to backend object
handles (ids), which made the code a bit unclear. Backend objects
would be associated with GrGpuResource::LifeCycle, even though
GrGpuResource::LifeCycle refers to the GpuResource, and individual
backend objects in one GpuResource might be governed with different
"lifecycle".
Mark the budgeted/not budgeted with SkBudgeted::kYes, SkBudgeted::kNo.
This was previously GrGpuResource::kCached_LifeCycle,
GrGpuResource::kUncached_LifeCycle.
Mark the "references wrapped object" with boolean. This was previously
GrGpuResource::kBorrowed_LifeCycle,
GrGpuResource::kAdopted_LifeCycle for GrGpuResource.
Associate the backend object ownership status with
GrBackendObjectOwnership for the backend object handles.
The resource type leaf constuctors, such has GrGLTexture or
GrGLTextureRenderTarget take "budgeted" parameter. This parameter
is passed to GrGpuResource::registerWithCache().
The resource type intermediary constructors, such as GrGLTexture
constructors for class GrGLTextureRenderTarget do not take "budgeted"
parameters, intermediary construtors do not call registerWithCache.
Removes the need for tagging GrGpuResource -derived subclass
constructors with "Derived" parameter.
Makes instances that wrap backend objects be registered with
a new function GrGpuResource::registerWithCacheWrapped().
Removes "budgeted" parameter from classes such as StencilAttahment, as
they are always cached and never wrap any external backend objects.
Removes the use of concept "external" from the member function names.
The API refers to the objects as "wrapped", so make all related
functions use the term consistently.
No change in functionality. Resources referencing wrapped objects are
always inserted to the cache with budget decision kNo.
BUG=594928
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1862043002
Review URL: https://codereview.chromium.org/1862043002
2016-04-22 08:48:29 +00:00
|
|
|
" (%d budgeted, %d wrapped, %d locked, %d scratch %.2g%% full), high %d\n",
|
|
|
|
stats.fTotal, fBudgetedCount, stats.fWrapped, stats.fNumNonPurgeable,
|
|
|
|
stats.fScratch, countUtilization, fHighWaterCount);
|
2015-02-03 02:26:03 +00:00
|
|
|
out->appendf("\t\tEntry Bytes: current %d (budgeted %d, %.2g%% full, %d unbudgeted) high %d\n",
|
2015-02-17 23:09:34 +00:00
|
|
|
SkToInt(fBytes), SkToInt(fBudgetedBytes), byteUtilization,
|
|
|
|
SkToInt(stats.fUnbudgetedSize), SkToInt(fHighWaterBytes));
|
2015-02-03 02:26:03 +00:00
|
|
|
}
|
|
|
|
|
2015-12-02 22:08:25 +00:00
|
|
|
void GrResourceCache::dumpStatsKeyValuePairs(SkTArray<SkString>* keys,
|
|
|
|
SkTArray<double>* values) const {
|
|
|
|
this->validate();
|
|
|
|
|
|
|
|
Stats stats;
|
|
|
|
this->getStats(&stats);
|
|
|
|
|
|
|
|
keys->push_back(SkString("gpu_cache_purgable_entries")); values->push_back(stats.fNumPurgeable);
|
|
|
|
}
|
|
|
|
|
2015-02-03 02:26:03 +00:00
|
|
|
#endif
|
|
|
|
|
2015-02-19 19:38:44 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void GrResourceCache::changeTimestamp(uint32_t newTimestamp) { fTimestamp = newTimestamp; }
|
2015-02-03 02:26:03 +00:00
|
|
|
|
2017-01-06 17:04:19 +00:00
|
|
|
#ifdef SK_DEBUG
|
|
|
|
int GrResourceCache::countUniqueKeysWithTag(const char* tag) const {
|
|
|
|
int count = 0;
|
|
|
|
UniqueHash::ConstIter iter(&fUniqueHash);
|
|
|
|
while (!iter.done()) {
|
|
|
|
if (0 == strcmp(tag, (*iter).getUniqueKey().tag())) {
|
|
|
|
++count;
|
|
|
|
}
|
|
|
|
++iter;
|
|
|
|
}
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-01-13 15:47:38 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2018-09-27 15:28:03 +00:00
|
|
|
sk_sp<GrTextureProxy> GrProxyProvider::testingOnly_createInstantiatedProxy(
|
|
|
|
const GrSurfaceDesc& desc, GrSurfaceOrigin origin, SkBackingFit fit, SkBudgeted budgeted) {
|
|
|
|
sk_sp<GrTexture> tex;
|
|
|
|
|
|
|
|
if (SkBackingFit::kApprox == fit) {
|
|
|
|
tex = fResourceProvider->createApproxTexture(desc, GrResourceProvider::Flags::kNone);
|
|
|
|
} else {
|
|
|
|
tex = fResourceProvider->createTexture(desc, budgeted, GrResourceProvider::Flags::kNone);
|
|
|
|
}
|
|
|
|
if (!tex) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return this->createWrapped(std::move(tex), origin);
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2016-01-13 15:47:38 +00:00
|
|
|
#define ASSERT_SINGLE_OWNER \
|
2017-04-10 12:19:26 +00:00
|
|
|
SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fRenderTargetContext->singleOwner());)
|
2016-01-13 15:47:38 +00:00
|
|
|
|
2017-11-30 05:01:06 +00:00
|
|
|
|
2017-12-05 17:05:21 +00:00
|
|
|
uint32_t GrRenderTargetContextPriv::testingOnly_getOpListID() {
|
|
|
|
return fRenderTargetContext->getOpList()->uniqueID();
|
|
|
|
}
|
|
|
|
|
2017-05-08 14:43:33 +00:00
|
|
|
uint32_t GrRenderTargetContextPriv::testingOnly_addDrawOp(std::unique_ptr<GrDrawOp> op) {
|
2017-11-30 05:01:06 +00:00
|
|
|
return this->testingOnly_addDrawOp(GrNoClip(), std::move(op));
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t GrRenderTargetContextPriv::testingOnly_addDrawOp(const GrClip& clip,
|
|
|
|
std::unique_ptr<GrDrawOp> op) {
|
2017-05-08 14:43:33 +00:00
|
|
|
ASSERT_SINGLE_OWNER
|
|
|
|
if (fRenderTargetContext->drawingManager()->wasAbandoned()) {
|
2018-06-19 17:09:54 +00:00
|
|
|
fRenderTargetContext->fContext->contextPriv().opMemoryPool()->release(std::move(op));
|
2017-05-08 14:43:33 +00:00
|
|
|
return SK_InvalidUniqueID;
|
|
|
|
}
|
|
|
|
SkDEBUGCODE(fRenderTargetContext->validate());
|
|
|
|
GR_AUDIT_TRAIL_AUTO_FRAME(fRenderTargetContext->fAuditTrail,
|
|
|
|
"GrRenderTargetContext::testingOnly_addDrawOp");
|
2017-11-30 05:01:06 +00:00
|
|
|
return fRenderTargetContext->addDrawOp(clip, std::move(op));
|
2017-05-08 14:43:33 +00:00
|
|
|
}
|
|
|
|
|
2016-01-13 15:47:38 +00:00
|
|
|
#undef ASSERT_SINGLE_OWNER
|
|
|
|
|
2016-08-10 18:09:07 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2018-03-16 20:47:25 +00:00
|
|
|
GrInternalSurfaceFlags GrSurfaceProxy::testingOnly_getFlags() const {
|
|
|
|
return fSurfaceFlags;
|
2016-08-10 18:09:07 +00:00
|
|
|
}
|
|
|
|
|
2017-05-12 18:09:46 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2017-05-05 15:26:15 +00:00
|
|
|
void GrContextPriv::testingOnly_flushAndRemoveOnFlushCallbackObject(GrOnFlushCallbackObject* cb) {
|
|
|
|
fContext->flush();
|
|
|
|
fContext->fDrawingManager->testingOnly_removeOnFlushCallbackObject(cb);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GrDrawingManager::testingOnly_removeOnFlushCallbackObject(GrOnFlushCallbackObject* cb) {
|
|
|
|
int n = std::find(fOnFlushCBObjects.begin(), fOnFlushCBObjects.end(), cb) -
|
|
|
|
fOnFlushCBObjects.begin();
|
|
|
|
SkASSERT(n < fOnFlushCBObjects.count());
|
|
|
|
fOnFlushCBObjects.removeShuffle(n);
|
|
|
|
}
|
2017-05-12 18:09:46 +00:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2018-06-24 19:08:57 +00:00
|
|
|
void GrCoverageCountingPathRenderer::testingOnly_drawPathDirectly(const DrawPathArgs& args) {
|
|
|
|
// Call onDrawPath() directly: We want to test paths that might fail onCanDrawPath() simply for
|
|
|
|
// performance reasons, and GrPathRenderer::drawPath() assert that this call returns true.
|
|
|
|
// The test is responsible to not draw any paths that CCPR is not actually capable of.
|
|
|
|
this->onDrawPath(args);
|
|
|
|
}
|
|
|
|
|
2018-06-18 15:51:36 +00:00
|
|
|
const GrUniqueKey& GrCoverageCountingPathRenderer::testingOnly_getStashedAtlasKey() const {
|
|
|
|
return fStashedAtlasKey;
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2017-05-12 18:09:46 +00:00
|
|
|
#define DRAW_OP_TEST_EXTERN(Op) \
|
2017-07-11 12:52:13 +00:00
|
|
|
extern std::unique_ptr<GrDrawOp> Op##__Test(GrPaint&&, SkRandom*, GrContext*, GrFSAAType)
|
2017-05-12 18:09:46 +00:00
|
|
|
#define DRAW_OP_TEST_ENTRY(Op) Op##__Test
|
|
|
|
|
2017-06-15 20:21:49 +00:00
|
|
|
DRAW_OP_TEST_EXTERN(AAConvexPathOp);
|
2017-07-11 12:52:13 +00:00
|
|
|
DRAW_OP_TEST_EXTERN(AAFillRectOp);
|
2017-07-13 20:42:55 +00:00
|
|
|
DRAW_OP_TEST_EXTERN(AAFlatteningConvexPathOp);
|
2017-07-07 17:29:28 +00:00
|
|
|
DRAW_OP_TEST_EXTERN(AAHairlineOp);
|
2017-06-15 13:59:23 +00:00
|
|
|
DRAW_OP_TEST_EXTERN(AAStrokeRectOp);
|
2017-07-11 12:52:13 +00:00
|
|
|
DRAW_OP_TEST_EXTERN(CircleOp);
|
2017-07-12 19:27:54 +00:00
|
|
|
DRAW_OP_TEST_EXTERN(DashOp);
|
2017-07-13 20:40:46 +00:00
|
|
|
DRAW_OP_TEST_EXTERN(DefaultPathOp);
|
2017-05-15 20:45:49 +00:00
|
|
|
DRAW_OP_TEST_EXTERN(DIEllipseOp);
|
|
|
|
DRAW_OP_TEST_EXTERN(EllipseOp);
|
2017-07-18 23:59:24 +00:00
|
|
|
DRAW_OP_TEST_EXTERN(GrAtlasTextOp);
|
2017-07-12 15:51:27 +00:00
|
|
|
DRAW_OP_TEST_EXTERN(GrDrawAtlasOp);
|
2017-07-12 18:11:22 +00:00
|
|
|
DRAW_OP_TEST_EXTERN(GrDrawVerticesOp);
|
2017-07-11 12:52:13 +00:00
|
|
|
DRAW_OP_TEST_EXTERN(NonAAFillRectOp);
|
|
|
|
DRAW_OP_TEST_EXTERN(NonAALatticeOp);
|
2017-06-15 13:59:23 +00:00
|
|
|
DRAW_OP_TEST_EXTERN(NonAAStrokeRectOp);
|
2017-07-13 15:20:51 +00:00
|
|
|
DRAW_OP_TEST_EXTERN(ShadowRRectOp);
|
2017-07-11 19:52:02 +00:00
|
|
|
DRAW_OP_TEST_EXTERN(SmallPathOp);
|
2017-07-11 19:53:05 +00:00
|
|
|
DRAW_OP_TEST_EXTERN(RegionOp);
|
2017-05-15 20:45:49 +00:00
|
|
|
DRAW_OP_TEST_EXTERN(RRectOp);
|
2017-07-11 13:03:10 +00:00
|
|
|
DRAW_OP_TEST_EXTERN(TesselatingPathOp);
|
2017-08-28 19:32:01 +00:00
|
|
|
DRAW_OP_TEST_EXTERN(TextureOp);
|
2017-05-12 18:09:46 +00:00
|
|
|
|
|
|
|
void GrDrawRandomOp(SkRandom* random, GrRenderTargetContext* renderTargetContext, GrPaint&& paint) {
|
|
|
|
GrContext* context = renderTargetContext->surfPriv().getContext();
|
|
|
|
using MakeDrawOpFn = std::unique_ptr<GrDrawOp>(GrPaint&&, SkRandom*, GrContext*, GrFSAAType);
|
|
|
|
static constexpr MakeDrawOpFn* gFactories[] = {
|
2017-08-28 19:32:01 +00:00
|
|
|
DRAW_OP_TEST_ENTRY(AAConvexPathOp),
|
|
|
|
DRAW_OP_TEST_ENTRY(AAFillRectOp),
|
|
|
|
DRAW_OP_TEST_ENTRY(AAFlatteningConvexPathOp),
|
|
|
|
DRAW_OP_TEST_ENTRY(AAHairlineOp),
|
|
|
|
DRAW_OP_TEST_ENTRY(AAStrokeRectOp),
|
|
|
|
DRAW_OP_TEST_ENTRY(CircleOp),
|
|
|
|
DRAW_OP_TEST_ENTRY(DashOp),
|
|
|
|
DRAW_OP_TEST_ENTRY(DefaultPathOp),
|
|
|
|
DRAW_OP_TEST_ENTRY(DIEllipseOp),
|
|
|
|
DRAW_OP_TEST_ENTRY(EllipseOp),
|
|
|
|
DRAW_OP_TEST_ENTRY(GrAtlasTextOp),
|
|
|
|
DRAW_OP_TEST_ENTRY(GrDrawAtlasOp),
|
|
|
|
DRAW_OP_TEST_ENTRY(GrDrawVerticesOp),
|
|
|
|
DRAW_OP_TEST_ENTRY(NonAAFillRectOp),
|
|
|
|
DRAW_OP_TEST_ENTRY(NonAALatticeOp),
|
|
|
|
DRAW_OP_TEST_ENTRY(NonAAStrokeRectOp),
|
|
|
|
DRAW_OP_TEST_ENTRY(ShadowRRectOp),
|
|
|
|
DRAW_OP_TEST_ENTRY(SmallPathOp),
|
|
|
|
DRAW_OP_TEST_ENTRY(RegionOp),
|
|
|
|
DRAW_OP_TEST_ENTRY(RRectOp),
|
|
|
|
DRAW_OP_TEST_ENTRY(TesselatingPathOp),
|
|
|
|
DRAW_OP_TEST_ENTRY(TextureOp),
|
2017-05-12 18:09:46 +00:00
|
|
|
};
|
|
|
|
|
2017-07-14 19:27:56 +00:00
|
|
|
static constexpr size_t kTotal = SK_ARRAY_COUNT(gFactories);
|
2017-05-12 18:09:46 +00:00
|
|
|
uint32_t index = random->nextULessThan(static_cast<uint32_t>(kTotal));
|
2017-07-14 19:27:56 +00:00
|
|
|
auto op = gFactories[index](
|
|
|
|
std::move(paint), random, context, renderTargetContext->fsaaType());
|
|
|
|
SkASSERT(op);
|
|
|
|
renderTargetContext->priv().testingOnly_addDrawOp(std::move(op));
|
2017-05-12 18:09:46 +00:00
|
|
|
}
|