1cb93a386Sopenharmony_ci/* 2cb93a386Sopenharmony_ci * Copyright 2021 Google LLC 3cb93a386Sopenharmony_ci * 4cb93a386Sopenharmony_ci * Use of this source code is governed by a BSD-style license that can be 5cb93a386Sopenharmony_ci * found in the LICENSE file. 6cb93a386Sopenharmony_ci */ 7cb93a386Sopenharmony_ci 8cb93a386Sopenharmony_ci#include "experimental/graphite/src/CopyTask.h" 9cb93a386Sopenharmony_ci 10cb93a386Sopenharmony_ci#include "experimental/graphite/src/Buffer.h" 11cb93a386Sopenharmony_ci#include "experimental/graphite/src/CommandBuffer.h" 12cb93a386Sopenharmony_ci#include "experimental/graphite/src/Texture.h" 13cb93a386Sopenharmony_ci 14cb93a386Sopenharmony_cinamespace skgpu { 15cb93a386Sopenharmony_ci 16cb93a386Sopenharmony_cisk_sp<CopyTextureToBufferTask> CopyTextureToBufferTask::Make(sk_sp<Texture> texture, 17cb93a386Sopenharmony_ci SkIRect srcRect, 18cb93a386Sopenharmony_ci sk_sp<Buffer> buffer, 19cb93a386Sopenharmony_ci size_t bufferOffset, 20cb93a386Sopenharmony_ci size_t bufferRowBytes) { 21cb93a386Sopenharmony_ci return sk_sp<CopyTextureToBufferTask>(new CopyTextureToBufferTask(std::move(texture), 22cb93a386Sopenharmony_ci srcRect, 23cb93a386Sopenharmony_ci std::move(buffer), 24cb93a386Sopenharmony_ci bufferOffset, 25cb93a386Sopenharmony_ci bufferRowBytes)); 26cb93a386Sopenharmony_ci} 27cb93a386Sopenharmony_ci 28cb93a386Sopenharmony_ciCopyTextureToBufferTask::CopyTextureToBufferTask(sk_sp<Texture> texture, 29cb93a386Sopenharmony_ci SkIRect srcRect, 30cb93a386Sopenharmony_ci sk_sp<Buffer> buffer, 31cb93a386Sopenharmony_ci size_t bufferOffset, 32cb93a386Sopenharmony_ci size_t bufferRowBytes) 33cb93a386Sopenharmony_ci : fTexture(std::move(texture)) 34cb93a386Sopenharmony_ci , fSrcRect(srcRect) 35cb93a386Sopenharmony_ci , fBuffer(std::move(buffer)) 36cb93a386Sopenharmony_ci , fBufferOffset(bufferOffset) 37cb93a386Sopenharmony_ci , fBufferRowBytes(bufferRowBytes) { 38cb93a386Sopenharmony_ci} 39cb93a386Sopenharmony_ci 40cb93a386Sopenharmony_ciCopyTextureToBufferTask::~CopyTextureToBufferTask() {} 41cb93a386Sopenharmony_ci 42cb93a386Sopenharmony_civoid CopyTextureToBufferTask::addCommands(ResourceProvider*, CommandBuffer* commandBuffer) { 43cb93a386Sopenharmony_ci commandBuffer->copyTextureToBuffer(std::move(fTexture), 44cb93a386Sopenharmony_ci fSrcRect, 45cb93a386Sopenharmony_ci std::move(fBuffer), 46cb93a386Sopenharmony_ci fBufferOffset, 47cb93a386Sopenharmony_ci fBufferRowBytes); 48cb93a386Sopenharmony_ci} 49cb93a386Sopenharmony_ci 50cb93a386Sopenharmony_ci} // namespace skgpu 51cb93a386Sopenharmony_ci 52