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 #include "include/private/GrRecordingContext.h"
9 #include "src/gpu/GrCaps.h"
10 #include "src/gpu/GrGpuCommandBuffer.h"
11 #include "src/gpu/GrMemoryPool.h"
12 #include "src/gpu/GrRecordingContextPriv.h"
13 #include "src/gpu/ops/GrTransferFromOp.h"
14
Make(GrRecordingContext * context,const SkIRect & srcRect,GrColorType surfaceColorType,GrColorType dstColorType,sk_sp<GrGpuBuffer> dstBuffer,size_t dstOffset)15 std::unique_ptr<GrOp> GrTransferFromOp::Make(GrRecordingContext* context,
16 const SkIRect& srcRect,
17 GrColorType surfaceColorType,
18 GrColorType dstColorType,
19 sk_sp<GrGpuBuffer> dstBuffer,
20 size_t dstOffset) {
21 GrOpMemoryPool* pool = context->priv().opMemoryPool();
22 return pool->allocate<GrTransferFromOp>(
23 srcRect, surfaceColorType, dstColorType, std::move(dstBuffer), dstOffset);
24 }
25
onExecute(GrOpFlushState * state,const SkRect & chainBounds)26 void GrTransferFromOp::onExecute(GrOpFlushState* state, const SkRect& chainBounds) {
27 state->commandBuffer()->transferFrom(
28 fSrcRect, fSurfaceColorType, fDstColorType, fDstBuffer.get(), fDstOffset);
29 }
30