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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "GrTest.h"
|
2015-07-28 16:58:39 +00:00
|
|
|
|
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"
|
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"
|
2015-02-13 22:20:05 +00:00
|
|
|
#include "GrGpuResourceCacheAccess.h"
|
2016-07-21 16:21:04 +00:00
|
|
|
#include "GrPipelineBuilder.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"
|
2015-12-09 02:53:44 +00:00
|
|
|
|
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"
|
2013-08-21 19:27:48 +00:00
|
|
|
|
2016-12-16 19:24:34 +00:00
|
|
|
#include "text/GrAtlasGlyphCache.h"
|
2015-12-11 14:11:21 +00:00
|
|
|
#include "text/GrTextBlobCache.h"
|
|
|
|
|
2017-05-05 15:26:15 +00:00
|
|
|
#include <algorithm>
|
|
|
|
|
2015-08-21 18:08:00 +00:00
|
|
|
namespace GrTest {
|
|
|
|
void SetupAlwaysEvictAtlas(GrContext* context) {
|
|
|
|
// These sizes were selected because they allow each atlas to hold a single plot and will thus
|
|
|
|
// stress the atlas
|
2016-12-16 23:59:19 +00:00
|
|
|
int dim = GrDrawOpAtlas::kGlyphMaxDim;
|
|
|
|
GrDrawOpAtlasConfig configs[3];
|
2015-08-21 18:08:00 +00:00
|
|
|
configs[kA8_GrMaskFormat].fWidth = dim;
|
|
|
|
configs[kA8_GrMaskFormat].fHeight = dim;
|
2016-02-22 19:25:32 +00:00
|
|
|
configs[kA8_GrMaskFormat].fLog2Width = SkNextLog2(dim);
|
|
|
|
configs[kA8_GrMaskFormat].fLog2Height = SkNextLog2(dim);
|
2015-08-21 18:08:00 +00:00
|
|
|
configs[kA8_GrMaskFormat].fPlotWidth = dim;
|
|
|
|
configs[kA8_GrMaskFormat].fPlotHeight = dim;
|
|
|
|
|
|
|
|
configs[kA565_GrMaskFormat].fWidth = dim;
|
|
|
|
configs[kA565_GrMaskFormat].fHeight = dim;
|
2016-02-22 19:25:32 +00:00
|
|
|
configs[kA565_GrMaskFormat].fLog2Width = SkNextLog2(dim);
|
|
|
|
configs[kA565_GrMaskFormat].fLog2Height = SkNextLog2(dim);
|
2015-08-21 18:08:00 +00:00
|
|
|
configs[kA565_GrMaskFormat].fPlotWidth = dim;
|
|
|
|
configs[kA565_GrMaskFormat].fPlotHeight = dim;
|
|
|
|
|
|
|
|
configs[kARGB_GrMaskFormat].fWidth = dim;
|
|
|
|
configs[kARGB_GrMaskFormat].fHeight = dim;
|
2016-02-22 19:25:32 +00:00
|
|
|
configs[kARGB_GrMaskFormat].fLog2Width = SkNextLog2(dim);
|
|
|
|
configs[kARGB_GrMaskFormat].fLog2Height = SkNextLog2(dim);
|
2015-08-21 18:08:00 +00:00
|
|
|
configs[kARGB_GrMaskFormat].fPlotWidth = dim;
|
|
|
|
configs[kARGB_GrMaskFormat].fPlotHeight = dim;
|
|
|
|
|
|
|
|
context->setTextContextAtlasSizes_ForTesting(configs);
|
|
|
|
}
|
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
|
|
|
|
|
|
|
GrBackendTexture CreateBackendTexture(GrBackend backend, int width, int height,
|
|
|
|
GrPixelConfig config, GrBackendObject handle) {
|
|
|
|
if (kOpenGL_GrBackend == backend) {
|
|
|
|
GrGLTextureInfo* glInfo = (GrGLTextureInfo*)(handle);
|
2017-04-26 17:29:21 +00:00
|
|
|
return GrBackendTexture(width, height, config, *glInfo);
|
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
|
|
|
} else {
|
|
|
|
SkASSERT(kVulkan_GrBackend == backend);
|
|
|
|
GrVkImageInfo* vkInfo = (GrVkImageInfo*)(handle);
|
2017-04-26 17:29:21 +00:00
|
|
|
return GrBackendTexture(width, height, *vkInfo);
|
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
|
|
|
}
|
|
|
|
}
|
2015-08-21 18:08:00 +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();
|
|
|
|
}
|
|
|
|
|
2015-08-03 17:17:44 +00:00
|
|
|
void GrContext::setTextBlobCacheLimit_ForTesting(size_t bytes) {
|
|
|
|
fTextBlobCache->setBudget(bytes);
|
|
|
|
}
|
|
|
|
|
2016-12-16 23:59:19 +00:00
|
|
|
void GrContext::setTextContextAtlasSizes_ForTesting(const GrDrawOpAtlasConfig* configs) {
|
2016-12-16 19:24:34 +00:00
|
|
|
fAtlasGlyphCache->setAtlasSizes_ForTesting(configs);
|
2015-08-19 15:16:43 +00:00
|
|
|
}
|
|
|
|
|
2013-08-21 19:27:48 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2013-12-18 17:25:33 +00:00
|
|
|
void GrContext::purgeAllUnlockedResources() {
|
2015-02-11 18:49:59 +00:00
|
|
|
fResourceCache->purgeAllUnlocked();
|
2013-12-18 17:25:33 +00:00
|
|
|
}
|
2014-11-05 22:47:41 +00:00
|
|
|
|
2015-12-02 17:05:37 +00:00
|
|
|
void GrContext::resetGpuStats() const {
|
|
|
|
#if GR_GPU_STATS
|
|
|
|
fGpu->stats()->reset();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-02-03 02:26:03 +00:00
|
|
|
void GrContext::dumpCacheStats(SkString* out) const {
|
|
|
|
#if GR_CACHE_STATS
|
2015-02-11 18:49:59 +00:00
|
|
|
fResourceCache->dumpStats(out);
|
2015-02-03 02:26:03 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-12-02 22:08:25 +00:00
|
|
|
void GrContext::dumpCacheStatsKeyValuePairs(SkTArray<SkString>* keys,
|
|
|
|
SkTArray<double>* values) const {
|
|
|
|
#if GR_CACHE_STATS
|
|
|
|
fResourceCache->dumpStatsKeyValuePairs(keys, values);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-02-03 02:26:03 +00:00
|
|
|
void GrContext::printCacheStats() const {
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void GrContext::dumpGpuStats(SkString* out) const {
|
|
|
|
#if GR_GPU_STATS
|
|
|
|
return fGpu->stats()->dump(out);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-12-02 17:05:37 +00:00
|
|
|
void GrContext::dumpGpuStatsKeyValuePairs(SkTArray<SkString>* keys,
|
|
|
|
SkTArray<double>* values) const {
|
|
|
|
#if GR_GPU_STATS
|
|
|
|
return fGpu->stats()->dumpKeyValuePairs(keys, values);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-02-03 02:26:03 +00:00
|
|
|
void GrContext::printGpuStats() const {
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2017-01-20 15:03:25 +00:00
|
|
|
sk_sp<SkImage> GrContext::getFontAtlasImage_ForTesting(GrMaskFormat format) {
|
2016-12-16 19:24:34 +00:00
|
|
|
GrAtlasGlyphCache* cache = this->getAtlasGlyphCache();
|
2015-11-08 16:07:24 +00:00
|
|
|
|
2017-02-28 21:20:03 +00:00
|
|
|
sk_sp<GrTextureProxy> proxy = cache->getProxy(format);
|
|
|
|
if (!proxy) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2017-03-09 21:36:32 +00:00
|
|
|
SkASSERT(proxy->priv().isExact());
|
|
|
|
sk_sp<SkImage> image(new SkImage_Gpu(this, kNeedNewImageUniqueID, kPremul_SkAlphaType,
|
|
|
|
std::move(proxy), 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
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#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-04-03 14:38:00 +00:00
|
|
|
uint32_t GrRenderTargetContextPriv::testingOnly_addLegacyMeshDrawOp(
|
|
|
|
GrPaint&& paint,
|
|
|
|
GrAAType aaType,
|
|
|
|
std::unique_ptr<GrLegacyMeshDrawOp> op,
|
|
|
|
const GrUserStencilSettings* uss,
|
|
|
|
bool snapToCenters) {
|
2016-01-13 15:47:38 +00:00
|
|
|
ASSERT_SINGLE_OWNER
|
2017-03-08 16:50:55 +00:00
|
|
|
if (fRenderTargetContext->drawingManager()->wasAbandoned()) {
|
|
|
|
return SK_InvalidUniqueID;
|
|
|
|
}
|
2017-04-03 14:38:00 +00:00
|
|
|
SkDEBUGCODE(fRenderTargetContext->validate();) GR_AUDIT_TRAIL_AUTO_FRAME(
|
|
|
|
fRenderTargetContext->fAuditTrail, "GrRenderTargetContext::testingOnly_addMeshDrawOp");
|
2016-01-13 15:47:38 +00:00
|
|
|
|
2017-01-11 18:42:54 +00:00
|
|
|
GrPipelineBuilder pipelineBuilder(std::move(paint), aaType);
|
2016-06-23 21:07:00 +00:00
|
|
|
if (uss) {
|
|
|
|
pipelineBuilder.setUserStencil(uss);
|
2016-05-13 17:25:00 +00:00
|
|
|
}
|
2017-01-19 14:55:19 +00:00
|
|
|
pipelineBuilder.setSnapVerticesToPixelCenters(snapToCenters);
|
2016-06-23 21:07:00 +00:00
|
|
|
|
2017-04-04 19:13:25 +00:00
|
|
|
return fRenderTargetContext->addLegacyMeshDrawOp(std::move(pipelineBuilder), GrNoClip(),
|
|
|
|
std::move(op));
|
2016-01-13 15:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#undef ASSERT_SINGLE_OWNER
|
|
|
|
|
2016-08-10 18:09:07 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2016-10-28 17:25:24 +00:00
|
|
|
GrRenderTarget::Flags GrRenderTargetProxy::testingOnly_getFlags() const {
|
2017-02-28 21:11:04 +00:00
|
|
|
return fRenderTargetFlags;
|
2016-08-10 18:09:07 +00:00
|
|
|
}
|
|
|
|
|
2014-11-05 22:47:41 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Code for the mock context. It's built on a mock GrGpu class that does nothing.
|
|
|
|
////
|
|
|
|
|
|
|
|
#include "GrGpu.h"
|
|
|
|
|
2015-01-22 18:16:09 +00:00
|
|
|
class GrPipeline;
|
2014-11-11 00:03:14 +00:00
|
|
|
|
2016-01-08 17:12:44 +00:00
|
|
|
class MockCaps : public GrCaps {
|
|
|
|
public:
|
|
|
|
explicit MockCaps(const GrContextOptions& options) : INHERITED(options) {}
|
|
|
|
bool isConfigTexturable(GrPixelConfig config) const override { return false; }
|
|
|
|
bool isConfigRenderable(GrPixelConfig config, bool withMSAA) const override { return false; }
|
2016-11-29 16:59:17 +00:00
|
|
|
bool canConfigBeImageStorage(GrPixelConfig) const override { return false; }
|
2017-04-07 14:08:53 +00:00
|
|
|
bool initDescForDstCopy(const GrRenderTargetProxy* src, GrSurfaceDesc* desc,
|
|
|
|
bool* rectsMustMatch, bool* disallowSubrect) const override {
|
2017-03-06 21:17:12 +00:00
|
|
|
return false;
|
|
|
|
}
|
2016-11-29 16:59:17 +00:00
|
|
|
|
2016-01-08 17:12:44 +00:00
|
|
|
private:
|
|
|
|
typedef GrCaps INHERITED;
|
|
|
|
};
|
|
|
|
|
2014-11-05 22:47:41 +00:00
|
|
|
class MockGpu : public GrGpu {
|
|
|
|
public:
|
2015-05-22 21:01:46 +00:00
|
|
|
MockGpu(GrContext* context, const GrContextOptions& options) : INHERITED(context) {
|
2016-01-08 17:12:44 +00:00
|
|
|
fCaps.reset(new MockCaps(options));
|
2015-05-22 21:01:46 +00:00
|
|
|
}
|
2015-03-26 01:17:31 +00:00
|
|
|
~MockGpu() override {}
|
2014-11-05 22:47:41 +00:00
|
|
|
|
2015-07-28 20:26:15 +00:00
|
|
|
bool onGetReadPixelsInfo(GrSurface* srcSurface, int readWidth, int readHeight, size_t rowBytes,
|
|
|
|
GrPixelConfig readConfig, DrawPreference*,
|
|
|
|
ReadPixelTempDrawInfo*) override { return false; }
|
|
|
|
|
2016-02-16 21:00:01 +00:00
|
|
|
bool onGetWritePixelsInfo(GrSurface* dstSurface, int width, int height,
|
2015-07-28 20:26:15 +00:00
|
|
|
GrPixelConfig srcConfig, DrawPreference*,
|
|
|
|
WritePixelTempDrawInfo*) override { return false; }
|
2015-07-23 15:07:21 +00:00
|
|
|
|
2015-08-21 18:53:29 +00:00
|
|
|
bool onCopySurface(GrSurface* dst,
|
|
|
|
GrSurface* src,
|
|
|
|
const SkIRect& srcRect,
|
2016-09-27 13:34:10 +00:00
|
|
|
const SkIPoint& dstPoint) override { return false; }
|
2014-11-26 20:28:00 +00:00
|
|
|
|
2016-11-01 14:03:59 +00:00
|
|
|
void onQueryMultisampleSpecs(GrRenderTarget* rt, const GrStencilSettings&,
|
|
|
|
int* effectiveSampleCnt, SamplePattern*) override {
|
2016-03-07 21:58:26 +00:00
|
|
|
*effectiveSampleCnt = rt->desc().fSampleCnt;
|
|
|
|
}
|
|
|
|
|
2016-11-30 18:38:32 +00:00
|
|
|
GrGpuCommandBuffer* createCommandBuffer(const GrGpuCommandBuffer::LoadAndStoreInfo&,
|
2016-06-23 15:37:05 +00:00
|
|
|
const GrGpuCommandBuffer::LoadAndStoreInfo&) override {
|
2016-06-08 21:02:27 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2016-09-27 13:34:10 +00:00
|
|
|
void drawDebugWireRect(GrRenderTarget*, const SkIRect&, GrColor) override {}
|
2015-12-03 20:58:06 +00:00
|
|
|
|
2017-03-01 22:01:09 +00:00
|
|
|
GrFence SK_WARN_UNUSED_RESULT insertFence() override { return 0; }
|
|
|
|
bool waitFence(GrFence, uint64_t) override { return true; }
|
2016-09-30 15:39:02 +00:00
|
|
|
void deleteFence(GrFence) const override {}
|
|
|
|
|
2017-03-01 22:01:09 +00:00
|
|
|
sk_sp<GrSemaphore> SK_WARN_UNUSED_RESULT makeSemaphore() override { return nullptr; }
|
2017-04-28 17:57:38 +00:00
|
|
|
void insertSemaphore(sk_sp<GrSemaphore> semaphore, bool flush) override {}
|
2017-03-01 22:01:09 +00:00
|
|
|
void waitSemaphore(sk_sp<GrSemaphore> semaphore) override {}
|
|
|
|
|
2014-11-26 18:20:45 +00:00
|
|
|
private:
|
2015-03-26 01:17:31 +00:00
|
|
|
void onResetContext(uint32_t resetBits) override {}
|
2014-11-05 22:47:41 +00:00
|
|
|
|
2015-08-12 18:14:50 +00:00
|
|
|
void xferBarrier(GrRenderTarget*, GrXferBarrierType) override {}
|
|
|
|
|
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
|
|
|
GrTexture* onCreateTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted,
|
2016-02-26 21:20:48 +00:00
|
|
|
const SkTArray<GrMipLevel>& texels) override {
|
2015-08-27 14:41:13 +00:00
|
|
|
return nullptr;
|
2014-11-05 22:47:41 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted,
|
2016-02-26 21:20:48 +00:00
|
|
|
const SkTArray<GrMipLevel>& texels) override {
|
2015-08-27 14:41:13 +00:00
|
|
|
return nullptr;
|
2014-11-05 22:47:41 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
sk_sp<GrTexture> onWrapBackendTexture(const GrBackendTexture&,
|
|
|
|
GrSurfaceOrigin,
|
|
|
|
GrBackendTextureFlags,
|
|
|
|
int sampleCnt,
|
|
|
|
GrWrapOwnership) override {
|
2016-10-27 16:30:08 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
2014-11-05 22:47:41 +00:00
|
|
|
|
2017-05-01 13:50:58 +00:00
|
|
|
sk_sp<GrRenderTarget> onWrapBackendRenderTarget(const GrBackendRenderTarget&,
|
|
|
|
GrSurfaceOrigin) override {
|
2015-08-27 14:41:13 +00:00
|
|
|
return nullptr;
|
2014-11-26 18:20:45 +00:00
|
|
|
}
|
2014-11-05 22:47:41 +00:00
|
|
|
|
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
|
|
|
sk_sp<GrRenderTarget> onWrapBackendTextureAsRenderTarget(const GrBackendTexture&,
|
|
|
|
GrSurfaceOrigin,
|
|
|
|
int sampleCnt) override {
|
Add wrapBackendTextureAsRenderTarget API
Skia's GrTextureProvider currently exposes two APIs for wrapping backend
objects:
* wrapBackendTexture - wraps a texture into a GrTexture. Depending on
flags, this GrTexture can be converted to a GrRenderTarget. Skia
manages the render target objects it may create to provide a render
target for the texture. This allows Skia to create stencil buffers
if needed and manager MSAA resolves.
* wrapBackendRenderTarget - wraps a FBO into a GrRenderTarget. This
object cannot be converted to a GrTexture. Skia does not manage
the render target objects for such a GrRenderTarget, and as such
cannot attach stencil buffers or perform MSAA resolves on the
created GrRenderTarget.
Given these two options, wrapBackendTexture provides more versatility
and allows Skia more room for optimization. Chrome currently uses
wrapBackendTexture for this reason.
While these two functions cover most cases, they do not provide a way
for Skia to wrap a texture into a render target (and gain the MSAA and
stencil buffer management), without also creating a GrTexture. This is
problematic in cases where a texture can be bound to a render target,
but cannot be textured from, as is the case in Chrome's limited support
for GL_TEXTURE_RECTANGLE.
To address this, a new function is created:
* wrapBackendTextureAsRenderTarget - wraps a texture into a
GrRenderTarget. As with wrapBackendTexture, the created render
target objects are fully managed by Skia. Unlike wrapBackendTexture
no GrTexture is created, and the created object will never be
textured from.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1709163003
Review URL: https://codereview.chromium.org/1709163003
2016-02-24 22:49:51 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2016-04-19 17:00:02 +00:00
|
|
|
GrBuffer* onCreateBuffer(size_t, GrBufferType, GrAccessPattern, const void*) override {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2015-12-03 17:15:47 +00:00
|
|
|
|
2016-07-29 15:14:20 +00:00
|
|
|
gr_instanced::InstancedRendering* onCreateInstancedRendering() override { return nullptr; }
|
|
|
|
|
2015-07-30 14:34:27 +00:00
|
|
|
bool onReadPixels(GrSurface* surface,
|
2014-11-26 20:28:00 +00:00
|
|
|
int left, int top, int width, int height,
|
|
|
|
GrPixelConfig,
|
|
|
|
void* buffer,
|
2015-03-26 01:17:31 +00:00
|
|
|
size_t rowBytes) override {
|
2014-11-05 22:47:41 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-07-30 14:34:27 +00:00
|
|
|
bool onWritePixels(GrSurface* surface,
|
|
|
|
int left, int top, int width, int height,
|
2016-02-26 21:20:48 +00:00
|
|
|
GrPixelConfig config, const SkTArray<GrMipLevel>& texels) override {
|
2014-11-05 22:47:41 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-04-20 17:33:27 +00:00
|
|
|
bool onTransferPixels(GrSurface* surface,
|
2016-01-05 18:41:27 +00:00
|
|
|
int left, int top, int width, int height,
|
2016-03-25 19:15:03 +00:00
|
|
|
GrPixelConfig config, GrBuffer* transferBuffer,
|
2016-01-05 18:41:27 +00:00
|
|
|
size_t offset, size_t rowBytes) override {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-03-26 01:17:31 +00:00
|
|
|
void onResolveRenderTarget(GrRenderTarget* target) override { return; }
|
2014-11-05 22:47:41 +00:00
|
|
|
|
2015-09-14 19:56:10 +00:00
|
|
|
GrStencilAttachment* createStencilAttachmentForRenderTarget(const GrRenderTarget*,
|
|
|
|
int width,
|
|
|
|
int height) override {
|
|
|
|
return nullptr;
|
2014-11-05 22:47:41 +00:00
|
|
|
}
|
|
|
|
|
2015-03-26 01:17:31 +00:00
|
|
|
void clearStencil(GrRenderTarget* target) override {}
|
2014-11-05 22:47:41 +00:00
|
|
|
|
2015-07-14 18:02:52 +00:00
|
|
|
GrBackendObject createTestingOnlyBackendTexture(void* pixels, int w, int h,
|
2016-06-24 16:22:31 +00:00
|
|
|
GrPixelConfig config, bool isRT) override {
|
2016-01-26 17:10:48 +00:00
|
|
|
return 0;
|
2015-07-14 18:02:52 +00:00
|
|
|
}
|
2015-11-11 20:40:42 +00:00
|
|
|
bool isTestingOnlyBackendTexture(GrBackendObject ) const override { return false; }
|
2016-02-05 15:17:34 +00:00
|
|
|
void deleteTestingOnlyBackendTexture(GrBackendObject, bool abandonTexture) override {}
|
2015-07-13 14:19:57 +00:00
|
|
|
|
2014-11-05 22:47:41 +00:00
|
|
|
typedef GrGpu INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
GrContext* GrContext::CreateMockContext() {
|
2015-08-26 20:07:48 +00:00
|
|
|
GrContext* context = new GrContext;
|
2014-11-05 22:47:41 +00:00
|
|
|
|
|
|
|
context->initMockContext();
|
|
|
|
return context;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GrContext::initMockContext() {
|
2015-05-22 21:01:46 +00:00
|
|
|
GrContextOptions options;
|
2016-03-25 19:15:03 +00:00
|
|
|
options.fBufferMapThreshold = 0;
|
2015-08-27 14:41:13 +00:00
|
|
|
SkASSERT(nullptr == fGpu);
|
2015-08-26 20:07:48 +00:00
|
|
|
fGpu = new MockGpu(this, options);
|
2014-11-05 22:47:41 +00:00
|
|
|
SkASSERT(fGpu);
|
2015-11-30 21:27:47 +00:00
|
|
|
this->initCommon(options);
|
2014-11-05 22:47:41 +00:00
|
|
|
|
|
|
|
// We delete these because we want to test the cache starting with zero resources. Also, none of
|
|
|
|
// these objects are required for any of tests that use this context. TODO: make stop allocating
|
|
|
|
// resources in the buffer pools.
|
2015-10-17 14:43:27 +00:00
|
|
|
fDrawingManager->abandon();
|
2014-11-05 22:47:41 +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);
|
|
|
|
}
|