QGVAPConfigModel.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. // QGVAPConfigModel.h
  2. // Tencent is pleased to support the open source community by making vap available.
  3. //
  4. // Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
  5. //
  6. // Licensed under the MIT License (the "License"); you may not use this file except in
  7. // compliance with the License. You may obtain a copy of the License at
  8. //
  9. // http://opensource.org/licenses/MIT
  10. //
  11. // Unless required by applicable law or agreed to in writing, software distributed under the License is
  12. // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
  13. // either express or implied. See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. #import <Foundation/Foundation.h>
  16. #import <UIKit/UIKit.h>
  17. #import <Metal/Metal.h>
  18. typedef NS_ENUM(NSInteger, QGVAPOrientation){
  19. QGVAPOrientation_None = 0, // 兼容
  20. QGVAPOrientation_Portrait = 1, // 竖屏
  21. QGVAPOrientation_landscape = 2, // 横屏
  22. };
  23. typedef NSString * QGAGAttachmentSourceType NS_EXTENSIBLE_STRING_ENUM;//资源类型
  24. typedef NSString * QGAGAttachmentSourceLoadType NS_EXTENSIBLE_STRING_ENUM;//资源加载类型
  25. typedef NSString * QGAGAttachmentSourceStyle NS_EXTENSIBLE_STRING_ENUM;//字体
  26. typedef NSString * QGAGAttachmentFitType NS_EXTENSIBLE_STRING_ENUM;//资源适配类型
  27. //资源适配类型
  28. UIKIT_EXTERN QGAGAttachmentFitType const kQGAGAttachmentFitTypeFitXY; //按指定尺寸缩放
  29. UIKIT_EXTERN QGAGAttachmentFitType const kQGAGAttachmentFitTypeCenterFull; //默认按资源尺寸展示,如果资源尺寸小于遮罩,则等比缩放至可填满
  30. //资源类型
  31. UIKIT_EXTERN QGAGAttachmentSourceType const kQGAGAttachmentSourceTypeTextStr; //文字
  32. UIKIT_EXTERN QGAGAttachmentSourceType const kQGAGAttachmentSourceTypeImgUrl; //图片
  33. UIKIT_EXTERN QGAGAttachmentSourceType const kQGAGAttachmentSourceTypeText;
  34. UIKIT_EXTERN QGAGAttachmentSourceType const kQGAGAttachmentSourceTypeImg;
  35. UIKIT_EXTERN QGAGAttachmentSourceLoadType const QGAGAttachmentSourceLoadTypeLocal;
  36. UIKIT_EXTERN QGAGAttachmentSourceLoadType const QGAGAttachmentSourceLoadTypeNet;
  37. //字体
  38. UIKIT_EXTERN QGAGAttachmentSourceStyle const kQGAGAttachmentSourceStyleBoldText; //粗体
  39. //https://docs.qq.com/sheet/DTGl0bXdidFVkS3pn?tab=7od8yj&c=C25A0I0
  40. @class QGVAPCommonInfo,QGVAPSourceInfo,QGVAPMergedInfo;
  41. @interface QGVAPConfigModel : NSObject
  42. @property (nonatomic, strong) QGVAPCommonInfo *info;
  43. @property (nonatomic, strong) NSArray<QGVAPSourceInfo *> *resources;
  44. @property (nonatomic, strong) NSDictionary<NSNumber *, NSArray<QGVAPMergedInfo*> *> *mergedConfig; ///@{帧,@[多个融合信息]}
  45. @end
  46. #pragma mark - 整体信息
  47. @interface QGVAPCommonInfo : NSObject
  48. @property (nonatomic, assign) NSInteger version;
  49. @property (nonatomic, assign) NSInteger framesCount;
  50. @property (nonatomic, assign) CGSize size;
  51. @property (nonatomic, assign) CGSize videoSize;
  52. @property (nonatomic, assign) QGVAPOrientation targetOrientaion;
  53. @property (nonatomic, assign) NSInteger fps;
  54. @property (nonatomic, assign) BOOL isMerged;
  55. @property (nonatomic, assign) CGRect alphaAreaRect;
  56. @property (nonatomic, assign) CGRect rgbAreaRect;
  57. @end
  58. #pragma mark - 渲染资源信息
  59. @interface QGVAPSourceInfo : NSObject
  60. //原始信息
  61. @property (nonatomic, strong) QGAGAttachmentSourceType type;
  62. @property (nonatomic, strong) QGAGAttachmentSourceLoadType loadType;
  63. @property (nonatomic, strong) NSString *contentTag;
  64. @property (nonatomic, strong) NSString *contentTagValue;
  65. @property (nonatomic, strong) UIColor *color;
  66. @property (nonatomic, strong) QGAGAttachmentSourceStyle style;
  67. @property (nonatomic, assign) CGSize size;
  68. @property (nonatomic, strong) QGAGAttachmentFitType fitType;
  69. //加载内容
  70. @property (nonatomic, strong) UIImage *sourceImage;
  71. @property (nonatomic, strong) id<MTLTexture> texture;
  72. @property (nonatomic, strong) id<MTLBuffer> colorParamsBuffer;
  73. @end
  74. @interface QGVAPSourceDisplayItem : NSObject
  75. @property (nonatomic, assign) CGRect frame;
  76. @property (nonatomic, strong) QGVAPSourceInfo *sourceInfo;
  77. @end
  78. #pragma mark - 融合信息
  79. @interface QGVAPMergedInfo : NSObject
  80. @property (nonatomic, strong) QGVAPSourceInfo *source;
  81. @property (nonatomic, assign) NSInteger renderIndex;
  82. @property (nonatomic, assign) CGRect renderRect;
  83. @property (nonatomic, assign) BOOL needMask;
  84. @property (nonatomic, assign) CGRect maskRect;
  85. @property (nonatomic, assign) NSInteger maskRotation;
  86. //加载内容
  87. - (id<MTLBuffer>)vertexBufferWithContainerSize:(CGSize)size maskContianerSize:(CGSize)mSize device:(id<MTLDevice>)device;
  88. @end