# Gsy Render And Effects

三种渲染载体（TextureView / SurfaceView / GLSurfaceView）、显示比例（16:9/4:3/full/custom）、GL 滤镜与自定义...

- Repository: https://github.com/CarGuo/GSYVideoPlayer (21524 stars)
- Category: Engineering
- License: Apache-2.0
- Last updated: 2026-10-10
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add CarGuo/GSYVideoPlayer --skill gsy-render-and-effects -g -a claude-code -y`
Codex: `npx skills add CarGuo/GSYVideoPlayer --skill gsy-render-and-effects -g -a codex -y`
Cursor: `npx skills add CarGuo/GSYVideoPlayer --skill gsy-render-and-effects -g -a cursor -y`
Gemini CLI: `npx skills add CarGuo/GSYVideoPlayer --skill gsy-render-and-effects -g -a gemini-cli -y`

## Description

三种渲染载体（TextureView / SurfaceView / GLSurfaceView）、显示比例（16:9/4:3/full/custom）、GL 滤镜与自定义 Shader。

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# gsy-render-and-effects

## 渲染类型 `GSYVideoType.setRenderType(int)`

| 常量 | 值 | 说明 |
|---|---|---|
| `TEXTURE` | 0 | 默认，与动画/圆角/缩放兼容最好 |
| `SURFACE` | 1 | 性能最好，但和 View 动画冲突 |
| `GLSURFACE` | 2 | 必需，若要用 `setEffectFilter` |

见 [GSYVideoType#L39-L49](../../gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/utils/GSYVideoType.java)。设置时机：`setUp` 之前，全局生效。

## 显示比例 `GSYVideoType.setShowType(int)`

| 常量 | 值 | 说明 |
|---|---|---|
| `SCREEN_TYPE_DEFAULT` | 0 | 按视频原比例居中 |
| `SCREEN_TYPE_16_9` | 1 | 强制 16:9 |
| `SCREEN_TYPE_4_3` | 2 | 强制 4:3 |
| `SCREEN_TYPE_18_9` | 6 | 全面屏 |
| `SCREEN_TYPE_FULL` | 4 | 全屏裁减；`surface_container` 建议 `FrameLayout` |
| `SCREEN_MATCH_FULL` | -4 | 全屏拉伸；`surface_container` 建议 `FrameLayout` |
| `SCREEN_TYPE_CUSTOM` | -5 | 需先 `setScreenScaleRatio(float)` |

见 [GSYVideoType#L10-L29](../../gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/utils/GSYVideoType.java) 与 [GSYVideoType#L165-L167](../../gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/utils/GSYVideoType.java)。

## 硬解码开关

| 静态方法 | 说明 |
|---|---|
| `enableMediaCodec()` / `disableMediaCodec()` | IJK 硬解码总开关 [#L71-L79](../../gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/utils/GSYVideoType.java) |
| `enableMediaCodecTexture()` / `disableMediaCodecTexture()` | 硬解 + Texture 直渲染优化 [#L100-L108](../../gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/utils/GSYVideoType.java) |
| `enableSmartMediaCodec()` / `disableSmartMediaCodec()` | 硬解失败自动软解回退 [#L86-L94](../../gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/utils/GSYVideoType.java) |
| `isMediaCodec()` / `isMediaCodecTexture()` / `isSmartMediaCodec()` | 查询 |

设置时机：**`setUp` 之前**，且**部分机型**需要在 `Application.onCreate` 就配好。

## GL 滤镜

需要满足两个条件：
1. `GSYVideoType.setRenderType(GSYVideoType.GLSURFACE)`
2. `builder.setEffectFilter(new XxxEffect())` 或 `player.setEffectFilter(...)`

The rest: https://github.com/CarGuo/GSYVideoPlayer/blob/HEAD/skills/07-gsy-render-and-effects/SKILL.md
