GrTransferFromOp.cpp 1.2 KB

12345678910111213141516171819202122232425262728
  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. #include "include/private/GrRecordingContext.h"
  8. #include "src/gpu/GrCaps.h"
  9. #include "src/gpu/GrGpuCommandBuffer.h"
  10. #include "src/gpu/GrMemoryPool.h"
  11. #include "src/gpu/GrRecordingContextPriv.h"
  12. #include "src/gpu/ops/GrTransferFromOp.h"
  13. std::unique_ptr<GrOp> GrTransferFromOp::Make(GrRecordingContext* context,
  14. const SkIRect& srcRect,
  15. GrColorType dstColorType,
  16. sk_sp<GrGpuBuffer> dstBuffer,
  17. size_t dstOffset) {
  18. SkASSERT(context->priv().caps()->transferFromOffsetAlignment(dstColorType));
  19. SkASSERT(dstOffset % context->priv().caps()->transferFromOffsetAlignment(dstColorType) == 0);
  20. GrOpMemoryPool* pool = context->priv().opMemoryPool();
  21. return pool->allocate<GrTransferFromOp>(srcRect, dstColorType, std::move(dstBuffer), dstOffset);
  22. }
  23. void GrTransferFromOp::onExecute(GrOpFlushState* state, const SkRect& chainBounds) {
  24. state->commandBuffer()->transferFrom(fSrcRect, fDstColorType, fDstBuffer.get(), fDstOffset);
  25. }