skia2/experimental/graphite/src/CopyTask.cpp
Greg Daniel 55a69d1de0 [graphite] Store ResourceProvider on Recorder instead of Gpu.
By being on Recorder, more calls can directly access the ResourceProvider
without needing the Context or Gpu. A different ResourceProvider is
created for each Recorder. Each ResourceProvider stores a ref to the
GlobalCache so that it can access shared resources. Eventually each
ResourceProvider will also have its own ResourceCache for all non shared
Resources.

A big win of this change is that Context can be removed from Recorder.

Bug: skia:12754
Change-Id: Ib6ac71c617de4d6b6b2ac4956580e65d4d7e6f7a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/502637
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2022-02-02 19:34:39 +00:00

51 lines
2.1 KiB
C++

/*
* Copyright 2021 Google LLC
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "experimental/graphite/src/CopyTask.h"
#include "experimental/graphite/src/Buffer.h"
#include "experimental/graphite/src/CommandBuffer.h"
#include "experimental/graphite/src/Texture.h"
namespace skgpu {
sk_sp<CopyTextureToBufferTask> CopyTextureToBufferTask::Make(sk_sp<Texture> texture,
SkIRect srcRect,
sk_sp<Buffer> buffer,
size_t bufferOffset,
size_t bufferRowBytes) {
return sk_sp<CopyTextureToBufferTask>(new CopyTextureToBufferTask(std::move(texture),
srcRect,
std::move(buffer),
bufferOffset,
bufferRowBytes));
}
CopyTextureToBufferTask::CopyTextureToBufferTask(sk_sp<Texture> texture,
SkIRect srcRect,
sk_sp<Buffer> buffer,
size_t bufferOffset,
size_t bufferRowBytes)
: fTexture(std::move(texture))
, fSrcRect(srcRect)
, fBuffer(std::move(buffer))
, fBufferOffset(bufferOffset)
, fBufferRowBytes(bufferRowBytes) {
}
CopyTextureToBufferTask::~CopyTextureToBufferTask() {}
void CopyTextureToBufferTask::addCommands(ResourceProvider*, CommandBuffer* commandBuffer) {
commandBuffer->copyTextureToBuffer(std::move(fTexture),
fSrcRect,
std::move(fBuffer),
fBufferOffset,
fBufferRowBytes);
}
} // namespace skgpu