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"
|
2019-01-07 05:51:00 +00:00
|
|
|
#include "ccpr/GrCCPathCache.h"
|
2017-05-12 18:09:46 +00:00
|
|
|
#include "ops/GrMeshDrawOp.h"
|
2019-01-16 18:46:02 +00:00
|
|
|
#include "text/GrStrikeCache.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();
|
|
|
|
}
|
|
|
|
|
2013-08-21 19:27:48 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2015-02-03 02:26:03 +00:00
|
|
|
|
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-11-30 05:01:06 +00:00
|
|
|
|
2017-12-05 17:05:21 +00:00
|
|
|
uint32_t GrRenderTargetContextPriv::testingOnly_getOpListID() {
|
|
|
|
return fRenderTargetContext->getOpList()->uniqueID();
|
|
|
|
}
|
|
|
|
|
2018-10-31 14:42:18 +00:00
|
|
|
void GrRenderTargetContextPriv::testingOnly_addDrawOp(std::unique_ptr<GrDrawOp> op) {
|
|
|
|
this->testingOnly_addDrawOp(GrNoClip(), std::move(op));
|
2017-11-30 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
2018-10-31 14:42:18 +00:00
|
|
|
void GrRenderTargetContextPriv::testingOnly_addDrawOp(
|
|
|
|
const GrClip& clip,
|
|
|
|
std::unique_ptr<GrDrawOp> op,
|
|
|
|
const std::function<GrRenderTargetContext::WillAddOpFn>& willAddFn) {
|
2017-05-08 14:43:33 +00:00
|
|
|
ASSERT_SINGLE_OWNER
|
2019-02-11 19:12:03 +00:00
|
|
|
if (fRenderTargetContext->fContext->abandoned()) {
|
2019-02-04 18:26:26 +00:00
|
|
|
fRenderTargetContext->fContext->priv().opMemoryPool()->release(std::move(op));
|
2018-10-31 14:42:18 +00:00
|
|
|
return;
|
2017-05-08 14:43:33 +00:00
|
|
|
}
|
|
|
|
SkDEBUGCODE(fRenderTargetContext->validate());
|
|
|
|
GR_AUDIT_TRAIL_AUTO_FRAME(fRenderTargetContext->fAuditTrail,
|
|
|
|
"GrRenderTargetContext::testingOnly_addDrawOp");
|
2018-10-31 14:42:18 +00:00
|
|
|
fRenderTargetContext->addDrawOp(clip, std::move(op), willAddFn);
|
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
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2019-01-07 05:51:00 +00:00
|
|
|
const GrCCPerFlushResources*
|
|
|
|
GrCoverageCountingPathRenderer::testingOnly_getCurrentFlushResources() {
|
|
|
|
SkASSERT(fFlushing);
|
|
|
|
if (fFlushingPaths.empty()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
// All pending paths should share the same resources.
|
|
|
|
const GrCCPerFlushResources* resources = fFlushingPaths.front()->fFlushResources.get();
|
|
|
|
#ifdef SK_DEBUG
|
|
|
|
for (const auto& flushingPaths : fFlushingPaths) {
|
|
|
|
SkASSERT(flushingPaths->fFlushResources.get() == resources);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return resources;
|
|
|
|
}
|
|
|
|
|
|
|
|
const GrCCPathCache* GrCoverageCountingPathRenderer::testingOnly_getPathCache() const {
|
|
|
|
return fPathCache.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
const GrTexture* GrCCPerFlushResources::testingOnly_frontCopyAtlasTexture() const {
|
|
|
|
if (fCopyAtlasStack.empty()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
const GrTextureProxy* proxy = fCopyAtlasStack.front().textureProxy();
|
|
|
|
return (proxy) ? proxy->peekTexture() : nullptr;
|
2018-06-18 15:51:36 +00:00
|
|
|
}
|
|
|
|
|
2019-01-07 05:51:00 +00:00
|
|
|
const GrTexture* GrCCPerFlushResources::testingOnly_frontRenderedAtlasTexture() const {
|
|
|
|
if (fRenderedAtlasStack.empty()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
const GrTextureProxy* proxy = fRenderedAtlasStack.front().textureProxy();
|
|
|
|
return (proxy) ? proxy->peekTexture() : nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
const SkTHashTable<GrCCPathCache::HashNode, const GrCCPathCache::Key&>&
|
|
|
|
GrCCPathCache::testingOnly_getHashTable() const {
|
|
|
|
return fHashTable;
|
|
|
|
}
|
|
|
|
|
|
|
|
const SkTInternalLList<GrCCPathCacheEntry>& GrCCPathCache::testingOnly_getLRU() const {
|
|
|
|
return fLRU;
|
|
|
|
}
|
|
|
|
|
|
|
|
int GrCCPathCacheEntry::testingOnly_peekOnFlushRefCnt() const { return fOnFlushRefCnt; }
|
|
|
|
|
|
|
|
int GrCCCachedAtlas::testingOnly_peekOnFlushRefCnt() const { return fOnFlushRefCnt; }
|
|
|
|
|
2018-06-18 15:51:36 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2017-05-12 18:09:46 +00:00
|
|
|
#define DRAW_OP_TEST_EXTERN(Op) \
|
2019-02-12 20:24:12 +00:00
|
|
|
extern std::unique_ptr<GrDrawOp> Op##__Test(GrPaint&&, SkRandom*, \
|
|
|
|
GrRecordingContext*, 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-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);
|
2018-11-28 20:34:34 +00:00
|
|
|
DRAW_OP_TEST_EXTERN(FillRectOp);
|
2017-07-18 23:59:24 +00:00
|
|
|
DRAW_OP_TEST_EXTERN(GrAtlasTextOp);
|
2019-02-11 19:29:34 +00:00
|
|
|
DRAW_OP_TEST_EXTERN(DrawAtlasOp);
|
|
|
|
DRAW_OP_TEST_EXTERN(DrawVerticesOp);
|
2017-07-11 12:52:13 +00:00
|
|
|
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();
|
2019-02-12 20:24:12 +00:00
|
|
|
using MakeDrawOpFn = std::unique_ptr<GrDrawOp>(GrPaint&&, SkRandom*,
|
|
|
|
GrRecordingContext*, GrFSAAType);
|
2017-05-12 18:09:46 +00:00
|
|
|
static constexpr MakeDrawOpFn* gFactories[] = {
|
2017-08-28 19:32:01 +00:00
|
|
|
DRAW_OP_TEST_ENTRY(AAConvexPathOp),
|
|
|
|
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),
|
2018-11-28 20:34:34 +00:00
|
|
|
DRAW_OP_TEST_ENTRY(FillRectOp),
|
2017-08-28 19:32:01 +00:00
|
|
|
DRAW_OP_TEST_ENTRY(GrAtlasTextOp),
|
2019-02-11 19:29:34 +00:00
|
|
|
DRAW_OP_TEST_ENTRY(DrawAtlasOp),
|
|
|
|
DRAW_OP_TEST_ENTRY(DrawVerticesOp),
|
2017-08-28 19:32:01 +00:00
|
|
|
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
|
|
|
}
|