Brian Salomon | ab32f65 | 2019-05-10 14:24:50 -0400 | [diff] [blame] | 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 | |
Brian Salomon | ab32f65 | 2019-05-10 14:24:50 -0400 | [diff] [blame] | 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" |
Mike Klein | ad44dd5 | 2019-05-14 14:01:39 -0500 | [diff] [blame] | 13 | #include "src/gpu/ops/GrTransferFromOp.h" |
Brian Salomon | ab32f65 | 2019-05-10 14:24:50 -0400 | [diff] [blame] | 14 | |
| 15 | std::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 | |
| 26 | void GrTransferFromOp::onExecute(GrOpFlushState* state, const SkRect& chainBounds) { |
| 27 | state->commandBuffer()->transferFrom(fSrcRect, fDstColorType, fDstBuffer.get(), fDstOffset); |
| 28 | } |