Skip to content

Commit

Permalink
Format codes
Browse files Browse the repository at this point in the history
  • Loading branch information
kevingpqi123 authored and domchen committed Feb 9, 2022
1 parent 5f4c7e4 commit 9e1df3a
Show file tree
Hide file tree
Showing 23 changed files with 75 additions and 45 deletions.
2 changes: 1 addition & 1 deletion codeformat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ find tgfx/include -iname '*.h' -print0 | xargs clang-format -i
# shellcheck disable=SC2038
find tgfx/src -iname "*.h" -print -o -iname "*.cpp" -print | xargs clang-format -i
# shellcheck disable=SC2038
find src -name "*.cpp" -print -o -name "*.h" -print | xargs clang-format -i
find src -name "*.cpp" -print -o -name "*.h" -print -o -name "*.mm" -print -o -name "*.m" -print | xargs clang-format -i
# shellcheck disable=SC2038
find test \( -path test/framework/lzma \) -prune -o -name "*.cpp" -print -o -name "*.h" -print | xargs clang-format -i

Expand Down
3 changes: 2 additions & 1 deletion src/platform/cocoa/PAG.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@

#import <Foundation/Foundation.h>

__attribute__((visibility("default"))) @interface PAG : NSObject
__attribute__((visibility("default")))
@interface PAG : NSObject
/**
* Get SDK version information.
*/
Expand Down
3 changes: 2 additions & 1 deletion src/platform/cocoa/PAGComposition.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
#import <Foundation/Foundation.h>
#import "PAGLayer.h"

__attribute__((visibility("default"))) @interface PAGComposition : PAGLayer
__attribute__((visibility("default")))
@interface PAGComposition : PAGLayer

/**
* Make a empty PAGComposition with specified size.
Expand Down
3 changes: 2 additions & 1 deletion src/platform/cocoa/PAGFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
#import "PAGText.h"
#import "PAGTimeStretchMode.h"

__attribute__((visibility("default"))) @interface PAGFile : PAGComposition
__attribute__((visibility("default")))
@interface PAGFile : PAGComposition
/**
* The maximum tag level current SDK supports.
*/
Expand Down
3 changes: 2 additions & 1 deletion src/platform/cocoa/PAGFont.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@

#import <Foundation/Foundation.h>

__attribute__((visibility("default"))) @interface PAGFont : NSObject
__attribute__((visibility("default")))
@interface PAGFont : NSObject

/**
* A string with the name of the font family.
Expand Down
3 changes: 2 additions & 1 deletion src/platform/cocoa/PAGImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
#import <Foundation/Foundation.h>
#import "PAGScaleMode.h"

__attribute__((visibility("default"))) @interface PAGImage : NSObject
__attribute__((visibility("default")))
@interface PAGImage : NSObject
/**
* Creates a PAGImage object from a CGImage object, return null if it's not valid CGImage object.
*/
Expand Down
3 changes: 2 additions & 1 deletion src/platform/cocoa/PAGImageLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
@class PAGImage;
@class PAGVideoRange;

__attribute__((visibility("default"))) @interface PAGImageLayer : PAGLayer
__attribute__((visibility("default")))
@interface PAGImageLayer : PAGLayer
/**
* Make a PAGImageLayer with size and duration(in microseconds).
*/
Expand Down
3 changes: 2 additions & 1 deletion src/platform/cocoa/PAGLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ typedef NS_ENUM(NSInteger, PAGLayerType) {
@class PAGComposition;
@class PAGFile;

__attribute__((visibility("default"))) @interface PAGLayer : NSObject
__attribute__((visibility("default")))
@interface PAGLayer : NSObject

/**
* Returns the type of layer.
Expand Down
3 changes: 2 additions & 1 deletion src/platform/cocoa/PAGMarker.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@

#import <Foundation/Foundation.h>

__attribute__((visibility("default"))) @interface PAGMarker : NSObject
__attribute__((visibility("default")))
@interface PAGMarker : NSObject

@property(nonatomic) long long startTime;
@property(nonatomic) long long duration;
Expand Down
3 changes: 2 additions & 1 deletion src/platform/cocoa/PAGPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
#import "PAGScaleMode.h"
#import "PAGSurface.h"

__attribute__((visibility("default"))) @interface PAGPlayer : NSObject
__attribute__((visibility("default")))
@interface PAGPlayer : NSObject
/**
* Returns the current PAGComposition for PAGPlayer to render as content.
*/
Expand Down
3 changes: 2 additions & 1 deletion src/platform/cocoa/PAGShapeLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#import <Foundation/Foundation.h>
#import "PAGLayer.h"

__attribute__((visibility("default"))) @interface PAGShapeLayer : PAGLayer
__attribute__((visibility("default")))
@interface PAGShapeLayer : PAGLayer

@end
3 changes: 2 additions & 1 deletion src/platform/cocoa/PAGSolidLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
#import "CocoaUtils.h"
#import "PAGLayer.h"

__attribute__((visibility("default"))) @interface PAGSolidLayer : PAGLayer
__attribute__((visibility("default")))
@interface PAGSolidLayer : PAGLayer

/**
* Returns the layer's solid color.
Expand Down
3 changes: 2 additions & 1 deletion src/platform/cocoa/PAGText.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ enum {
/**
* The PAGText object stores a value for a TextLayer's Source Text property.
*/
__attribute__((visibility("default"))) @interface PAGText : NSObject
__attribute__((visibility("default")))
@interface PAGText : NSObject

/**
* When true, the text layer shows a fill.
Expand Down
3 changes: 2 additions & 1 deletion src/platform/cocoa/PAGTextLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@

@class PAGFont;

__attribute__((visibility("default"))) @interface PAGTextLayer : PAGLayer
__attribute__((visibility("default")))
@interface PAGTextLayer : PAGLayer

/**
* Returns the TextLayer’s fill color.
Expand Down
3 changes: 2 additions & 1 deletion src/platform/cocoa/PAGVideoDecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@

#import <Foundation/Foundation.h>

__attribute__((visibility("default"))) @interface PAGVideoDecoder : NSObject
__attribute__((visibility("default")))
@interface PAGVideoDecoder : NSObject

/**
* Register a software decoder factory to implement the decoder fallback mechanism.
Expand Down
3 changes: 2 additions & 1 deletion src/platform/cocoa/PAGVideoRange.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
/**
* Represents a time range from the content of PAGImageLayer.
*/
__attribute__((visibility("default"))) @interface PAGVideoRange : NSObject
__attribute__((visibility("default")))
@interface PAGVideoRange : NSObject

/**
* The start time of the source video, in microseconds.
Expand Down
3 changes: 2 additions & 1 deletion src/platform/ios/PAGSurface.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
#import <QuartzCore/QuartzCore.h>
#import "PAGImageLayer.h"

__attribute__((visibility("default"))) @interface PAGSurface : NSObject
__attribute__((visibility("default")))
@interface PAGSurface : NSObject

/**
* Creates a new PAGSurface from specified CAEAGLLayer. The GPU context will be created internally
Expand Down
3 changes: 2 additions & 1 deletion src/platform/ios/PAGView.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@

@end

__attribute__((visibility("default"))) @interface PAGView : UIView
__attribute__((visibility("default")))
@interface PAGView : UIView

/**
* Default is NO.
Expand Down
6 changes: 3 additions & 3 deletions src/platform/ios/PAGView.mm
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ + (NSOperationQueue*)FlushQueue {
return pag::flushQueue;
}

/// 函数用于在执行 exit() 函数时把渲染任务全部完成,防止 PAG 的全局函数被析构,导致 PAG 野指针 crash。
/// 注意这里注册需要等待 PAG 执行一次后再进行注册。因此需要等到 bufferPerpared 并再执行一次 flush 后,
/// 否则 PAG 的 static 对象仍然会先析构
/// 函数用于在执行 exit() 函数时把渲染任务全部完成,防止 PAG 的全局函数被析构,导致 PAG 野指针
/// crash。 注意这里注册需要等待 PAG 执行一次后再进行注册。因此需要等到 bufferPerpared 并再执行一次
/// flush 后, 否则 PAG 的 static 对象仍然会先析构
+ (void)RegisterFlushQueueDestoryMethod {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
Expand Down
48 changes: 29 additions & 19 deletions src/platform/ios/private/GPUDecoder.mm
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@

namespace pag {

GPUDecoder::GPUDecoder(const VideoConfig& config) : sourceColorSpace(config.colorSpace),
destinationColorSpace(config.colorSpace),
colorRange(config.colorRange) {
GPUDecoder::GPUDecoder(const VideoConfig& config)
: sourceColorSpace(config.colorSpace),
destinationColorSpace(config.colorSpace),
colorRange(config.colorRange) {
isInitialized = initVideoToolBox(config.headers, config.mimeType);
}

Expand Down Expand Up @@ -147,11 +148,11 @@ void initParameterSets(const std::vector<std::shared_ptr<ByteData>>& headers,
CFDictionaryRef attrs = NULL;
const void* keys[] = {kCVPixelBufferPixelFormatTypeKey, kCVPixelBufferOpenGLESCompatibilityKey,
kCVPixelBufferIOSurfacePropertiesKey};

uint32_t openGLESCompatibility = true;
uint32_t pixelFormatType =
colorRange == YUVColorRange::JPEG ? kCVPixelFormatType_420YpCbCr8BiPlanarFullRange
: kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange;
uint32_t pixelFormatType = colorRange == YUVColorRange::JPEG
? kCVPixelFormatType_420YpCbCr8BiPlanarFullRange
: kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange;

CFNumberRef pixelFormatTypeValue = CFNumberCreate(NULL, kCFNumberSInt32Type, &pixelFormatType);
CFNumberRef openGLESCompatibilityValue =
Expand All @@ -178,18 +179,25 @@ void initParameterSets(const std::vector<std::shared_ptr<ByteData>>& headers,

if (@available(iOS 10.0, *)) {
if (sourceColorSpace == YUVColorSpace::Rec2020) {
CFStringRef destinationColorPrimaries = CFStringCreateWithCString(kCFAllocatorDefault, "DestinationColorPrimaries", kCFStringEncodingUTF8);
CFStringRef destinationTransferFunction = CFStringCreateWithCString(kCFAllocatorDefault, "DestinationTransferFunction", kCFStringEncodingUTF8);
CFStringRef destinationYCbCrMatrix = CFStringCreateWithCString(kCFAllocatorDefault, "DestinationYCbCrMatrix", kCFStringEncodingUTF8);
CFStringRef pixelTransferProperties = CFStringCreateWithCString(kCFAllocatorDefault, "PixelTransferProperties", kCFStringEncodingUTF8);

CFMutableDictionaryRef pixelTransferPropertiesParam = CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
&kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
CFDictionarySetValue(pixelTransferPropertiesParam, destinationColorPrimaries, kCVImageBufferColorPrimaries_ITU_R_709_2);
CFDictionarySetValue(pixelTransferPropertiesParam, destinationTransferFunction, kCVImageBufferTransferFunction_ITU_R_709_2);
CFDictionarySetValue(pixelTransferPropertiesParam, destinationYCbCrMatrix, kCVImageBufferYCbCrMatrix_ITU_R_709_2);
CFStringRef destinationColorPrimaries = CFStringCreateWithCString(
kCFAllocatorDefault, "DestinationColorPrimaries", kCFStringEncodingUTF8);
CFStringRef destinationTransferFunction = CFStringCreateWithCString(
kCFAllocatorDefault, "DestinationTransferFunction", kCFStringEncodingUTF8);
CFStringRef destinationYCbCrMatrix = CFStringCreateWithCString(
kCFAllocatorDefault, "DestinationYCbCrMatrix", kCFStringEncodingUTF8);
CFStringRef pixelTransferProperties = CFStringCreateWithCString(
kCFAllocatorDefault, "PixelTransferProperties", kCFStringEncodingUTF8);

CFMutableDictionaryRef pixelTransferPropertiesParam = CFDictionaryCreateMutable(
kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
CFDictionarySetValue(pixelTransferPropertiesParam, destinationColorPrimaries,
kCVImageBufferColorPrimaries_ITU_R_709_2);
CFDictionarySetValue(pixelTransferPropertiesParam, destinationTransferFunction,
kCVImageBufferTransferFunction_ITU_R_709_2);
CFDictionarySetValue(pixelTransferPropertiesParam, destinationYCbCrMatrix,
kCVImageBufferYCbCrMatrix_ITU_R_709_2);
VTSessionSetProperty(session, pixelTransferProperties, pixelTransferPropertiesParam);

CFRelease(destinationColorPrimaries);
CFRelease(destinationTransferFunction);
CFRelease(destinationYCbCrMatrix);
Expand Down Expand Up @@ -264,7 +272,9 @@ void initParameterSets(const std::vector<std::shared_ptr<ByteData>>& headers,
if (status == kVTInvalidSessionErr) {
cleanResources();
isInitialized = resetVideoToolBox();
LOGI("GPUDecoder: Resetting VideoToolBox session, which may be caused by app entered background, initialized = %d", isInitialized);
LOGI("GPUDecoder: Resetting VideoToolBox session, which may be caused by app entered "
"background, initialized = %d",
isInitialized);
} else {
LOGE("GPUDecoder:Decode failed status = %d", (int)status);
}
Expand Down
7 changes: 4 additions & 3 deletions src/platform/ios/private/VideoImage.mm
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,14 @@
}
videoImageMap.erase(result);
}
auto videoImage = std::shared_ptr<VideoImage>(new VideoImage(pixelBuffer, colorSpace, colorRange));
auto videoImage =
std::shared_ptr<VideoImage>(new VideoImage(pixelBuffer, colorSpace, colorRange));
videoImageMap[pixelBuffer] = videoImage;
return videoImage;
}

VideoImage::VideoImage(CVPixelBufferRef pixelBuffer,
YUVColorSpace colorSpace, YUVColorRange colorRange)
VideoImage::VideoImage(CVPixelBufferRef pixelBuffer, YUVColorSpace colorSpace,
YUVColorRange colorRange)
: VideoBuffer(static_cast<int>(CVPixelBufferGetWidth(pixelBuffer)),
static_cast<int>(CVPixelBufferGetHeight(pixelBuffer))),
pixelBuffer(pixelBuffer),
Expand Down
3 changes: 2 additions & 1 deletion src/platform/mac/PAGSurface.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
#import <QuartzCore/QuartzCore.h>
#import "PAGImageLayer.h"

__attribute__((visibility("default"))) @interface PAGSurface : NSObject
__attribute__((visibility("default")))
@interface PAGSurface : NSObject

+ (PAGSurface*)FromView:(NSView*)view;

Expand Down
3 changes: 2 additions & 1 deletion src/platform/mac/PAGView.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@

@end

__attribute__((visibility("default"))) @interface PAGView : NSView
__attribute__((visibility("default")))
@interface PAGView : NSView

/**
* Adds a listener to the set of listeners that are sent events through the life of an animation,
Expand Down

0 comments on commit 9e1df3a

Please sign in to comment.