Flutter Engine
The Flutter Engine
GrCopyRenderTask.cpp
Go to the documentation of this file.
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
9
14
17 SkIRect dstRect,
19 SkIRect srcRect,
21 GrSurfaceOrigin origin) {
24
25 // canCopySurface() should have returned true, guaranteeing this property.
26 SkASSERT(SkIRect::MakeSize(dst->dimensions()).contains(dstRect));
27 SkASSERT(SkIRect::MakeSize(src->dimensions()).contains(srcRect));
28
29 return sk_sp<GrRenderTask>(new GrCopyRenderTask(drawingMgr,
30 std::move(dst),
31 dstRect,
32 std::move(src),
33 srcRect,
34 filter,
35 origin));
36}
37
38GrCopyRenderTask::GrCopyRenderTask(GrDrawingManager* drawingMgr,
40 SkIRect dstRect,
42 SkIRect srcRect,
44 GrSurfaceOrigin origin)
45 : fSrc(std::move(src))
46 , fSrcRect(srcRect)
47 , fDstRect(dstRect)
48 , fFilter(filter)
49 , fOrigin(origin) {
50 this->addTarget(drawingMgr, std::move(dst));
51}
52
53void GrCopyRenderTask::gatherProxyIntervals(GrResourceAllocator* alloc) const {
54 if (!fSrc) {
55 alloc->incOps();
56 return;
57 }
58 // This renderTask doesn't have "normal" ops. In this case we still need to add an interval (so
59 // fEndOfOpsTaskOpIndices will remain in sync), so we create a fake op# to capture the fact that
60 // we read fSrcView and copy to target view.
61 alloc->addInterval(fSrc.get(), alloc->curOp(), alloc->curOp(),
64 alloc->addInterval(this->target(0), alloc->curOp(), alloc->curOp(),
67 alloc->incOps();
68}
69
70GrRenderTask::ExpectedOutcome GrCopyRenderTask::onMakeClosed(GrRecordingContext*,
71 SkIRect* targetUpdateBounds) {
72 // We don't expect to be marked skippable before being closed.
73 SkASSERT(fSrc);
74 *targetUpdateBounds = GrNativeRect::MakeIRectRelativeTo(
75 fOrigin,
76 this->target(0)->height(),
77 fDstRect);
79}
80
81bool GrCopyRenderTask::onExecute(GrOpFlushState* flushState) {
82 if (!fSrc) {
83 // Did nothing, just like we're supposed to.
84 return true;
85 }
86 GrSurfaceProxy* dstProxy = this->target(0);
87 if (!fSrc->isInstantiated() || !dstProxy->isInstantiated()) {
88 return false;
89 }
90 GrSurface* srcSurface = fSrc->peekSurface();
91 GrSurface* dstSurface = dstProxy->peekSurface();
92 SkIRect srcRect = GrNativeRect::MakeIRectRelativeTo(fOrigin, srcSurface->height(), fSrcRect);
93 SkIRect dstRect = GrNativeRect::MakeIRectRelativeTo(fOrigin, dstSurface->height(), fDstRect);
94 return flushState->gpu()->copySurface(dstSurface, dstRect, srcSurface, srcRect, fFilter);
95}
GrSurfaceOrigin
Definition: GrTypes.h:147
#define SkASSERT(cond)
Definition: SkAssert.h:116
SkFilterMode
static sk_sp< GrRenderTask > Make(GrDrawingManager *, sk_sp< GrSurfaceProxy > dst, SkIRect dstRect, sk_sp< GrSurfaceProxy > src, SkIRect srcRect, GrSamplerState::Filter filter, GrSurfaceOrigin)
bool copySurface(GrSurface *dst, const SkIRect &dstRect, GrSurface *src, const SkIRect &srcRect, GrSamplerState::Filter filter)
Definition: GrGpu.cpp:410
GrSurfaceProxy * target(int i) const
Definition: GrRenderTask.h:104
void addTarget(GrDrawingManager *dm, const GrSurfaceProxyView &view)
Definition: GrRenderTask.h:166
void addInterval(GrSurfaceProxy *, unsigned int start, unsigned int end, ActualUse actualUse, AllowRecycling SkDEBUGCODE(, bool isDirectDstRead=false))
unsigned int curOp() const
GrSurface * peekSurface() const
bool isInstantiated() const
int height() const
Definition: GrSurface.h:37
T * get() const
Definition: SkRefCnt.h:303
dst
Definition: cp.py:12
Definition: ref_ptr.h:256
int32_t height
static SkIRect MakeIRectRelativeTo(GrSurfaceOrigin origin, int rtHeight, SkIRect devRect)
Definition: GrNativeRect.h:31
Definition: SkRect.h:32
static constexpr SkIRect MakeSize(const SkISize &size)
Definition: SkRect.h:66
bool contains(int32_t x, int32_t y) const
Definition: SkRect.h:463