1 /* 2 * Copyright 2022 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 8 #ifndef skgpu_graphite_CommandTypes_DEFINED 9 #define skgpu_graphite_CommandTypes_DEFINED 10 11 #include "include/core/SkRect.h" 12 #include "include/gpu/graphite/GraphiteTypes.h" 13 14 namespace skgpu::graphite { 15 16 // specifies a single region for copying, either from buffer to texture, or vice versa 17 struct BufferTextureCopyData { 18 size_t fBufferOffset; 19 size_t fBufferRowBytes; 20 SkIRect fRect; 21 unsigned int fMipLevel; 22 }; 23 24 // Specifies a scissor, which can only be subsequently queried given a translation and clip which 25 // are assumed to be applied to all commands in the render pass in which the scissor is set. 26 class Scissor { 27 public: Scissor(const SkIRect & rect)28 explicit Scissor(const SkIRect& rect) : fRect(rect) {} 29 getRect(const SkIVector & replayTranslation,const SkIRect & replayClip)30 SkIRect getRect(const SkIVector& replayTranslation, const SkIRect& replayClip) const { 31 SkIRect rect = fRect.makeOffset(replayTranslation); 32 if (!rect.intersect(replayClip)) { 33 rect.setEmpty(); 34 } 35 return rect; 36 } 37 38 private: 39 const SkIRect fRect; 40 }; 41 42 }; // namespace skgpu::graphite 43 44 #endif // skgpu_graphite_DrawTypes_DEFINED 45