GrDrawableOp.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. * Copyright 2018 Google Inc.
  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 "src/gpu/ops/GrDrawableOp.h"
  8. #include "include/core/SkDrawable.h"
  9. #include "include/private/GrRecordingContext.h"
  10. #include "src/gpu/GrGpuCommandBuffer.h"
  11. #include "src/gpu/GrMemoryPool.h"
  12. #include "src/gpu/GrOpFlushState.h"
  13. #include "src/gpu/GrRecordingContextPriv.h"
  14. std::unique_ptr<GrDrawableOp> GrDrawableOp::Make(
  15. GrRecordingContext* context, std::unique_ptr<SkDrawable::GpuDrawHandler> drawable,
  16. const SkRect& bounds) {
  17. GrOpMemoryPool* pool = context->priv().opMemoryPool();
  18. return pool->allocate<GrDrawableOp>(std::move(drawable), bounds);
  19. }
  20. GrDrawableOp::GrDrawableOp(std::unique_ptr<SkDrawable::GpuDrawHandler> drawable,
  21. const SkRect& bounds)
  22. : INHERITED(ClassID())
  23. , fDrawable(std::move(drawable)) {
  24. this->setBounds(bounds, HasAABloat::kNo, IsZeroArea::kNo);
  25. }
  26. void GrDrawableOp::onExecute(GrOpFlushState* state, const SkRect& chainBounds) {
  27. SkASSERT(state->commandBuffer());
  28. state->rtCommandBuffer()->executeDrawable(std::move(fDrawable));
  29. }