LKS_AttrModificationPatchHandler.m 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #ifdef SHOULD_COMPILE_LOOKIN_SERVER
  2. //
  3. // LKS_AttrModificationPatchHandler.m
  4. // LookinServer
  5. //
  6. // Created by Li Kai on 2019/6/12.
  7. // https://lookin.work
  8. //
  9. #import "LKS_AttrModificationPatchHandler.h"
  10. #import "LookinDisplayItemDetail.h"
  11. #import "LookinServerDefines.h"
  12. @implementation LKS_AttrModificationPatchHandler
  13. + (void)handleLayerOids:(NSArray<NSNumber *> *)oids lowImageQuality:(BOOL)lowImageQuality block:(void (^)(LookinDisplayItemDetail *detail, NSUInteger tasksTotalCount, NSError *error))block {
  14. if (!block) {
  15. NSAssert(NO, @"");
  16. return;
  17. }
  18. if (![oids isKindOfClass:[NSArray class]]) {
  19. block(nil, 1, LookinErr_Inner);
  20. return;
  21. }
  22. [oids enumerateObjectsUsingBlock:^(NSNumber * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  23. unsigned long oid = [obj unsignedLongValue];
  24. LookinDisplayItemDetail *detail = [LookinDisplayItemDetail new];
  25. detail.displayItemOid = oid;
  26. CALayer *layer = (CALayer *)[NSObject lks_objectWithOid:oid];
  27. if (![layer isKindOfClass:[CALayer class]]) {
  28. block(nil, idx + 1, LookinErr_ObjNotFound);
  29. *stop = YES;
  30. return;
  31. }
  32. if (idx == 0) {
  33. detail.soloScreenshot = [layer lks_soloScreenshotWithLowQuality:lowImageQuality];
  34. detail.groupScreenshot = [layer lks_groupScreenshotWithLowQuality:lowImageQuality];
  35. } else {
  36. detail.groupScreenshot = [layer lks_groupScreenshotWithLowQuality:lowImageQuality];
  37. }
  38. block(detail, oids.count, nil);
  39. }];
  40. }
  41. @end
  42. #endif /* SHOULD_COMPILE_LOOKIN_SERVER */