blob: a728887bd07675ec6570f4a9e61c34806da2bc0f [file] [log] [blame]
Brian Salomonab32f652019-05-10 14:24:50 -04001/*
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
Brian Salomonab32f652019-05-10 14:24:50 -04008#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"
Mike Kleinad44dd52019-05-14 14:01:39 -050013#include "src/gpu/ops/GrTransferFromOp.h"
Brian Salomonab32f652019-05-10 14:24:50 -040014
15std::unique_ptr<GrOp> GrTransferFromOp::Make(GrRecordingContext* context,
16 const SkIRect& srcRect,
17 GrColorType dstColorType,
18 sk_sp<GrGpuBuffer> dstBuffer,
19 size_t dstOffset) {
20 SkASSERT(context->priv().caps()->transferFromOffsetAlignment(dstColorType));
21 SkASSERT(dstOffset % context->priv().caps()->transferFromOffsetAlignment(dstColorType) == 0);
22 GrOpMemoryPool* pool = context->priv().opMemoryPool();
23 return pool->allocate<GrTransferFromOp>(srcRect, dstColorType, std::move(dstBuffer), dstOffset);
24}
25
26void GrTransferFromOp::onExecute(GrOpFlushState* state, const SkRect& chainBounds) {
27 state->commandBuffer()->transferFrom(fSrcRect, fDstColorType, fDstBuffer.get(), fDstOffset);
28}