GPUImage(五):GPUImageView

1636 ワード

GPUImageViewは応答チェーンの終点であり、GPUImageOutputから継承する必要はないが、GPUImageInputプロトコルを実現するUIViewである.
GPUImageViewのインタフェースは非常に簡単で、GPUImageFillModeType充填モードをほぼ1つ設定するだけで、充填モードは3種類あります:GPUImageViewのframeビット全画面で、GPUImageVideoCameraの割合がAVCaptureSessionPreset 640 x 480の場合の効果kGPUImageFillModePreserveAspectRatio(デフォルト):ソース画像のアスペクト比を維持し、空白部分に設定した背景色を追加します.
Maintains the aspect ratio of the source image, adding bars of the specified background color
画像はAppから
**kGPUImageFillModesStretch*:押し出して画像をビューに埋め込むと、画像の割合が損なわれる可能性があります
Stretch to fill the full view, which may distort the image outside of its normal aspect ratio
**
画像はAppから
kGPU ImageFillModePreserveAspectRatioAndFill*:ソースピクチャのスケールを維持し、中心にスケールし、画面全体に画像を敷き詰める
Maintains the aspect ratio of the source image, zooming in on its center to fill the view
画像はAppから
Initメソッド
+ (Class)layerClass 
- (id)initWithFrame:(CGRect)frame
-(id)initWithCoder:(NSCoder *)coder
- (void)commonInit;
- (void)layoutSubviews;

この初期化方法はGPUImageFilter実装と同様であり,主に表示フレームキャッシュを呼び出す方法である.
表示fbosの管理
- (void)createDisplayFramebuffer;
- (void)destroyDisplayFramebuffer;
- (void)setDisplayFramebuffer;
- (void)presentFramebuffer;

フレームキャッシュおよびレンダリングキャッシュの作成および破棄
塗りつぶしモードの操作
- (void)recalculateViewGeometry;
- (void)setBackgroundColorRed:(GLfloat)redComponent green:(GLfloat)greenComponent blue:(GLfloat)blueComponent alpha:(GLfloat)alphaComponent;

  • 充填モードに基づいて画像頂点位置データ
  • を再計算する.
  • 背景色
  • を設定する.
  • 異なる回転モードにおけるテクスチャ座標
  • を計算する.
    GPUImageInputエージェントの実装方法
    この参照GPUImageFilterの解釈