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.
|
|
|
|
*/
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkString.h"
|
|
|
|
#include "include/gpu/GrBackendSurface.h"
|
|
|
|
#include "include/gpu/GrContextOptions.h"
|
2020-07-01 16:55:01 +00:00
|
|
|
#include "include/gpu/GrRecordingContext.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/private/SkTo.h"
|
|
|
|
#include "src/core/SkMathPriv.h"
|
|
|
|
#include "src/gpu/GrClip.h"
|
2020-10-14 15:23:11 +00:00
|
|
|
#include "src/gpu/GrDirectContextPriv.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "src/gpu/GrDrawOpAtlas.h"
|
|
|
|
#include "src/gpu/GrDrawingManager.h"
|
|
|
|
#include "src/gpu/GrGpu.h"
|
|
|
|
#include "src/gpu/GrGpuResourceCacheAccess.h"
|
|
|
|
#include "src/gpu/GrMemoryPool.h"
|
|
|
|
#include "src/gpu/GrRecordingContextPriv.h"
|
2019-06-18 13:58:02 +00:00
|
|
|
#include "src/gpu/GrRenderTargetProxy.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "src/gpu/GrResourceCache.h"
|
|
|
|
#include "src/gpu/GrSemaphore.h"
|
2020-12-09 21:37:04 +00:00
|
|
|
#include "src/gpu/GrSurfaceDrawContext.h"
|
2020-03-05 19:14:18 +00:00
|
|
|
#include "src/gpu/GrTexture.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "src/gpu/SkGr.h"
|
|
|
|
#include "src/gpu/ccpr/GrCoverageCountingPathRenderer.h"
|
|
|
|
#include "src/gpu/ops/GrMeshDrawOp.h"
|
|
|
|
#include "src/gpu/text/GrStrikeCache.h"
|
|
|
|
#include "src/gpu/text/GrTextBlobCache.h"
|
|
|
|
#include "src/image/SkImage_Gpu.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
|
|
|
|
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;
|
2020-03-14 21:22:45 +00:00
|
|
|
fUniqueHash.foreach([&](const GrGpuResource& resource){
|
|
|
|
if (0 == strcmp(tag, resource.getUniqueKey().tag())) {
|
2017-01-06 17:04:19 +00:00
|
|
|
++count;
|
|
|
|
}
|
2020-03-14 21:22:45 +00:00
|
|
|
});
|
2017-01-06 17:04:19 +00:00
|
|
|
return count;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-05-12 18:09:46 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#define DRAW_OP_TEST_EXTERN(Op) \
|
2020-10-07 20:46:15 +00:00
|
|
|
extern GrOp::Owner Op##__Test(GrPaint&&, SkRandom*, \
|
|
|
|
GrRecordingContext*, int numSamples)
|
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-03-24 00:53:23 +00:00
|
|
|
DRAW_OP_TEST_EXTERN(DrawAtlasOp);
|
2019-02-11 19:29:34 +00:00
|
|
|
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);
|
2020-03-25 22:18:16 +00:00
|
|
|
DRAW_OP_TEST_EXTERN(TriangulatingPathOp);
|
2017-08-28 19:32:01 +00:00
|
|
|
DRAW_OP_TEST_EXTERN(TextureOp);
|
2017-05-12 18:09:46 +00:00
|
|
|
|
2020-12-11 22:25:17 +00:00
|
|
|
void GrDrawRandomOp(SkRandom* random, GrSurfaceDrawContext* surfaceDrawContext, GrPaint&& paint) {
|
|
|
|
auto context = surfaceDrawContext->recordingContext();
|
2020-10-07 20:46:15 +00:00
|
|
|
using MakeDrawOpFn = GrOp::Owner (GrPaint&&, SkRandom*,
|
|
|
|
GrRecordingContext*, int numSamples);
|
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-03-24 00:53:23 +00:00
|
|
|
DRAW_OP_TEST_ENTRY(DrawAtlasOp),
|
2019-02-11 19:29:34 +00:00
|
|
|
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),
|
2020-03-25 22:18:16 +00:00
|
|
|
DRAW_OP_TEST_ENTRY(TriangulatingPathOp),
|
2017-08-28 19:32:01 +00:00
|
|
|
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](
|
2020-12-11 22:25:17 +00:00
|
|
|
std::move(paint), random, context, surfaceDrawContext->numSamples());
|
2020-07-09 20:02:08 +00:00
|
|
|
|
|
|
|
// Creating a GrAtlasTextOp my not produce an op if for example, it is totally outside the
|
|
|
|
// render target context.
|
2020-07-09 20:19:35 +00:00
|
|
|
if (op) {
|
2020-12-11 22:25:17 +00:00
|
|
|
surfaceDrawContext->addDrawOp(std::move(op));
|
2020-07-09 20:19:35 +00:00
|
|
|
}
|
2017-05-12 18:09:46 +00:00
|
|
|
}
|