dec_group_border.h (1416B)
1 // Copyright (c) the JPEG XL Project Authors. All rights reserved. 2 // 3 // Use of this source code is governed by a BSD-style 4 // license that can be found in the LICENSE file. 5 6 #ifndef LIB_JXL_DEC_GROUP_BORDER_H_ 7 #define LIB_JXL_DEC_GROUP_BORDER_H_ 8 9 #include <atomic> 10 #include <cstddef> 11 #include <cstdint> 12 #include <vector> 13 14 #include "lib/jxl/base/rect.h" 15 #include "lib/jxl/frame_dimensions.h" 16 17 namespace jxl { 18 19 class GroupBorderAssigner { 20 public: 21 // Prepare the GroupBorderAssigner to handle a given frame. 22 void Init(const FrameDimensions& frame_dim); 23 // Marks a group as done, and returns the (at most 3) rects to run 24 // FinalizeImageRect on. `block_rect` must be the rect corresponding 25 // to the given `group_id`, measured in blocks. 26 void GroupDone(size_t group_id, size_t padx, size_t pady, 27 Rect* rects_to_finalize, size_t* num_to_finalize); 28 // Marks a group as not-done, for running re-paints. 29 void ClearDone(size_t group_id); 30 31 static constexpr size_t kMaxToFinalize = 3; 32 33 private: 34 FrameDimensions frame_dim_; 35 std::vector<std::atomic<uint8_t>> counters_; 36 37 // Constants to identify group positions relative to the corners. 38 static constexpr uint8_t kTopLeft = 0x01; 39 static constexpr uint8_t kTopRight = 0x02; 40 static constexpr uint8_t kBottomRight = 0x04; 41 static constexpr uint8_t kBottomLeft = 0x08; 42 }; 43 44 } // namespace jxl 45 46 #endif // LIB_JXL_DEC_GROUP_BORDER_H_