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 8 #ifndef SkAutoBlitterChoose_DEFINED 9 #define SkAutoBlitterChoose_DEFINED 10 11 #include "include/private/SkMacros.h" 12 #include "src/core/SkArenaAlloc.h" 13 #include "src/core/SkBlitter.h" 14 #include "src/core/SkDraw.h" 15 #include "src/core/SkRasterClip.h" 16 17 class SkMatrix; 18 class SkPaint; 19 class SkPixmap; 20 21 class SkAutoBlitterChoose : SkNoncopyable { 22 public: SkAutoBlitterChoose()23 SkAutoBlitterChoose() {} 24 SkAutoBlitterChoose(const SkDraw& draw, const SkMatrixProvider* matrixProvider, 25 const SkPaint& paint, bool drawCoverage = false) { 26 this->choose(draw, matrixProvider, paint, drawCoverage); 27 } 28 29 SkBlitter* operator->() { return fBlitter; } get()30 SkBlitter* get() const { return fBlitter; } 31 32 SkBlitter* choose(const SkDraw& draw, const SkMatrixProvider* matrixProvider, 33 const SkPaint& paint, bool drawCoverage = false) { 34 SkASSERT(!fBlitter); 35 if (!matrixProvider) { 36 matrixProvider = draw.fMatrixProvider; 37 } 38 fBlitter = SkBlitter::Choose(draw.fDst, *matrixProvider, paint, &fAlloc, drawCoverage, 39 draw.fRC->clipShader()); 40 return fBlitter; 41 } 42 43 private: 44 // Owned by fAlloc, which will handle the delete. 45 SkBlitter* fBlitter = nullptr; 46 47 SkSTArenaAlloc<kSkBlitterContextSize> fAlloc; 48 }; 49 50 #endif 51