| 1 |
/* |
| 2 |
* Copyright 2019 Google LLC |
| 3 |
* |
| 4 |
* Use of this source code is governed by a BSD-style license that can be |
| 5 |
* found in the LICENSE file. |
| 6 |
*/ |
| 7 |
|
| 8 |
#ifndef GrTextureResolveRenderTask_DEFINED |
| 9 |
#define GrTextureResolveRenderTask_DEFINED |
| 10 |
|
| 11 |
#include "include/core/SkRect.h" |
| 12 |
#include "include/core/SkRefCnt.h" |
| 13 |
#include "include/private/base/SkDebug.h" |
| 14 |
#include "include/private/base/SkTArray.h" |
| 15 |
#include "include/private/gpu/ganesh/GrTypesPriv.h" |
| 16 |
#include "src/gpu/ganesh/GrCaps.h" |
| 17 |
#include "src/gpu/ganesh/GrRenderTask.h" |
| 18 |
#include "src/gpu/ganesh/GrSurfaceProxy.h" |
| 19 |
|
| 20 |
class GrDrawingManager; |
| 21 |
class GrOpFlushState; |
| 22 |
class GrRecordingContext; |
| 23 |
class GrResourceAllocator; |
| 24 |
|
| 25 |
class GrTextureResolveRenderTask final : public GrRenderTask { |
| 26 |
public: |
| 27 |
GrTextureResolveRenderTask() : GrRenderTask() {} |
| 28 |
|
| 29 |
void addProxy(GrDrawingManager*, sk_sp<GrSurfaceProxy> proxy, |
| 30 |
GrSurfaceProxy::ResolveFlags, const GrCaps&); |
| 31 |
#if defined(GPU_TEST_UTILS) |
| 32 |
GrSurfaceProxy::ResolveFlags flagsForProxy(sk_sp<GrSurfaceProxy>) const; |
| 33 |
#endif |
| 34 |
|
| 35 |
private: |
| 36 |
bool onIsUsed(GrSurfaceProxy* proxy) const override { |
| 37 |
return false; |
| 38 |
} |
| 39 |
void gatherProxyIntervals(GrResourceAllocator*) const override; |
| 40 |
|
| 41 |
ExpectedOutcome onMakeClosed(GrRecordingContext*, SkIRect*) override { |
| 42 |
return ExpectedOutcome::kTargetUnchanged; |
| 43 |
} |
| 44 |
|
| 45 |
bool onExecute(GrOpFlushState*) override; |
| 46 |
|
| •47 |
// addProxy() optimistically marks the proxy resolved/clean at recording time. If the flush |
| 48 |
// is dropped before this task executes (or a per-target operation fails) we must restore the |
| 49 |
// proxy's dirty state so a later flush will re-record the resolve. |
| 50 |
bool requiresExplicitCleanup() const override { return true; } |
| 51 |
void endFlush(GrDrawingManager*) override; |
| 52 |
|
| 53 |
#if defined(GPU_TEST_UTILS) |
| 54 |
const char* name() const final { return "TextureResolve"; } |
| 55 |
#endif |
| 56 |
#ifdef SK_DEBUG |
| 57 |
void visitProxies_debugOnly(const GrVisitProxyFunc&) const override; |
| 58 |
#endif |
| 59 |
|
| 60 |
struct Resolve { |
| 61 |
Resolve(GrSurfaceProxy::ResolveFlags flags) : fFlags(flags) {} |
| 62 |
GrSurfaceProxy::ResolveFlags fFlags; |
| 63 |
SkIRect fMSAAResolveRect; |
| 64 |
}; |
| 65 |
|
| 66 |
skia_private::STArray<4, Resolve> fResolves; |
| 67 |
}; |
| 68 |
|
| 69 |
#endif |