1 /*
2 * Copyright 2021 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 "experimental/graphite/src/CopyTask.h"
9
10 #include "experimental/graphite/src/Buffer.h"
11 #include "experimental/graphite/src/CommandBuffer.h"
12 #include "experimental/graphite/src/Texture.h"
13
14 namespace skgpu {
15
Make(sk_sp<Texture> texture,SkIRect srcRect,sk_sp<Buffer> buffer,size_t bufferOffset,size_t bufferRowBytes)16 sk_sp<CopyTextureToBufferTask> CopyTextureToBufferTask::Make(sk_sp<Texture> texture,
17 SkIRect srcRect,
18 sk_sp<Buffer> buffer,
19 size_t bufferOffset,
20 size_t bufferRowBytes) {
21 return sk_sp<CopyTextureToBufferTask>(new CopyTextureToBufferTask(std::move(texture),
22 srcRect,
23 std::move(buffer),
24 bufferOffset,
25 bufferRowBytes));
26 }
27
CopyTextureToBufferTask(sk_sp<Texture> texture,SkIRect srcRect,sk_sp<Buffer> buffer,size_t bufferOffset,size_t bufferRowBytes)28 CopyTextureToBufferTask::CopyTextureToBufferTask(sk_sp<Texture> texture,
29 SkIRect srcRect,
30 sk_sp<Buffer> buffer,
31 size_t bufferOffset,
32 size_t bufferRowBytes)
33 : fTexture(std::move(texture))
34 , fSrcRect(srcRect)
35 , fBuffer(std::move(buffer))
36 , fBufferOffset(bufferOffset)
37 , fBufferRowBytes(bufferRowBytes) {
38 }
39
~CopyTextureToBufferTask()40 CopyTextureToBufferTask::~CopyTextureToBufferTask() {}
41
addCommands(ResourceProvider *,CommandBuffer * commandBuffer)42 void CopyTextureToBufferTask::addCommands(ResourceProvider*, CommandBuffer* commandBuffer) {
43 commandBuffer->copyTextureToBuffer(std::move(fTexture),
44 fSrcRect,
45 std::move(fBuffer),
46 fBufferOffset,
47 fBufferRowBytes);
48 }
49
50 } // namespace skgpu
51
52