GrGLGpuCommandBuffer.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * Copyright 2017 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/gl/GrGLGpuCommandBuffer.h"
  8. #include "src/gpu/GrContextPriv.h"
  9. #include "src/gpu/GrFixedClip.h"
  10. #include "src/gpu/GrRenderTargetPriv.h"
  11. void GrGLGpuRTCommandBuffer::begin() {
  12. if (GrLoadOp::kClear == fColorLoadAndStoreInfo.fLoadOp) {
  13. fGpu->clear(GrFixedClip::Disabled(), fColorLoadAndStoreInfo.fClearColor,
  14. fRenderTarget, fOrigin);
  15. }
  16. if (GrLoadOp::kClear == fStencilLoadAndStoreInfo.fLoadOp) {
  17. GrStencilAttachment* sb = fRenderTarget->renderTargetPriv().getStencilAttachment();
  18. if (sb && (sb->isDirty() || fRenderTarget->alwaysClearStencil())) {
  19. fGpu->clearStencil(fRenderTarget, 0x0);
  20. }
  21. }
  22. }
  23. void GrGLGpuRTCommandBuffer::set(GrRenderTarget* rt, GrSurfaceOrigin origin,
  24. const GrGpuRTCommandBuffer::LoadAndStoreInfo& colorInfo,
  25. const GrGpuRTCommandBuffer::StencilLoadAndStoreInfo& stencilInfo) {
  26. SkASSERT(fGpu);
  27. SkASSERT(!fRenderTarget);
  28. SkASSERT(fGpu == rt->getContext()->priv().getGpu());
  29. this->INHERITED::set(rt, origin);
  30. fColorLoadAndStoreInfo = colorInfo;
  31. fStencilLoadAndStoreInfo = stencilInfo;
  32. }