Index: ui/surface/accelerated_surface_transformer_win.h |
diff --git a/ui/surface/accelerated_surface_transformer_win.h b/ui/surface/accelerated_surface_transformer_win.h |
index e01804a43cf5ac0cd7fb1a4dc9337dc4fdc24522..b1984bbdd75e9bd335aef1e77c84fa34580200c4 100644 |
--- a/ui/surface/accelerated_surface_transformer_win.h |
+++ b/ui/surface/accelerated_surface_transformer_win.h |
@@ -56,26 +56,111 @@ class SURFACE_EXPORT AcceleratedSurfaceTransformer { |
const gfx::Rect& src_subrect, |
IDirect3DSurface9* dst_surface); |
+ // Color format conversion from RGB to planar YV12 (also known as YUV420). |
+ // |
+ // YV12 is effectively a twelve bit per pixel format consisting of a full- |
+ // size y (luminance) plane and half-width, half-height u and v (blue and |
+ // red chrominance) planes. This method will allocate three lockable surfaces, |
+ // one for each plane, and return them via the arguments |dst_y|, |dst_u|, |
+ // and |dst_v|. These surface will be created with an ARGB D3DFORMAT, but |
+ // should be interpreted as the appropriate single-byte format when locking. |
+ // |
+ // The dimensions of the outputs (when interpreted as single-component data) |
+ // are as follows: |
+ // |dst_y| : width and height exactly |dst_size| |
+ // |dst_u| : width and height are each half of |dst_size|, rounded up. |
+ // |dst_v| : width and height are each half of |dst_size|, rounded up. |
+ // |
+ // If |src_texture|'s dimensions do not match |dst_size|, the source will be |
+ // bilinearly interpolated during conversion. |
+ // |
+ // Returns true if successful. Caller must be certain to free the buffers |
+ // even if this function returns false. |
+ bool TransformRGBToYV12( |
+ IDirect3DTexture9* src_texture, |
+ const gfx::Size& dst_size, |
+ IDirect3DSurface9** dst_y, |
+ IDirect3DSurface9** dst_u, |
+ IDirect3DSurface9** dst_v); |
+ |
private: |
+ friend class AcceleratedSurfaceTransformerTest; |
+ |
enum ShaderCombo { |
- SIMPLE_TEXTURE, |
+ ONE_TEXTURE_FLIP_Y, |
+ RGB_TO_YV12_FAST__PASS_1_OF_2, |
+ RGB_TO_YV12_FAST__PASS_2_OF_2, |
+ RGB_TO_YV12_SLOW__PASS_1_OF_3, |
+ RGB_TO_YV12_SLOW__PASS_2_OF_3, |
+ RGB_TO_YV12_SLOW__PASS_3_OF_3, |
NUM_SHADERS |
}; |
+ // Efficient RGB->YV12 in two passes, but requires a device capable of writing |
+ // multiple render targets at the same time. |
+ // |
+ // Returns true if successful. |
+ bool TransformRGBToYV12_MRT( |
+ IDirect3DTexture9* src_surface, |
+ const gfx::Size& dst_size, |
+ const gfx::Size& packed_y_size, |
+ const gfx::Size& packed_uv_size, |
+ IDirect3DSurface9* dst_y, |
+ IDirect3DSurface9* dst_u, |
+ IDirect3DSurface9* dst_v); |
+ |
+ // Slower, less efficient RGB->YV12; does not require the device to have |
+ // multiple render target capability. Runs at about half speed of the fast |
+ // path. |
+ // |
+ // Returns true if successful. |
+ bool TransformRGBToYV12_WithoutMRT( |
+ IDirect3DTexture9* src_surface, |
+ const gfx::Size& dst_size, |
+ const gfx::Size& packed_y_size, |
+ const gfx::Size& packed_uv_size, |
+ IDirect3DSurface9* dst_y, |
+ IDirect3DSurface9* dst_u, |
+ IDirect3DSurface9* dst_v); |
+ |
+ // Helper to allocate appropriately size YUV buffers, accounting for various |
+ // roundings. The sizes of the buffers (in terms of ARGB pixels) are returned |
+ // as |packed_y_size| and |packed_uv_size|. |
+ // |
+ // Returns true if successful. Caller must be certain to free the buffers |
+ // even if this function returns false. |
+ bool AllocYUVBuffers( |
+ const gfx::Size& dst_size, |
+ gfx::Size* packed_y_size, |
+ gfx::Size* packed_uv_size, |
+ IDirect3DSurface9** dst_y, |
+ IDirect3DSurface9** dst_u, |
+ IDirect3DSurface9** dst_v); |
+ |
// Set the active vertex and pixel shader combination. |
+ // |
+ // Returns true if successful. |
bool SetShaderCombo(ShaderCombo combo); |
// Intitializes a vertex and pixel shader combination from compiled bytecode. |
- bool InitShaderCombo(const BYTE vertex_shader_instructions[], |
- const BYTE pixel_shader_instructions[], |
- ShaderCombo shader_combo_name); |
+ // |
+ // Returns true if successful. |
+ bool InitShaderCombo(ShaderCombo shader_combo_name, |
+ const BYTE vertex_shader_instructions[], |
+ const BYTE pixel_shader_instructions[]); |
+ |
+ bool DoInit(IDirect3DDevice9* device); |
+ |
+ void DrawScreenAlignedQuad(const gfx::Size& dst_size); |
+ bool device_supports_multiple_render_targets(); |
miu
2012/12/27 21:40:17
nit: const method, since this is just a simple get
ncarter (slow)
2013/01/07 22:49:10
Done.
|
IDirect3DDevice9* device(); |
base::win::ScopedComPtr<IDirect3DDevice9> device_; |
base::win::ScopedComPtr<IDirect3DVertexShader9> vertex_shaders_[NUM_SHADERS]; |
base::win::ScopedComPtr<IDirect3DPixelShader9> pixel_shaders_[NUM_SHADERS]; |
+ bool device_supports_multiple_render_targets_; |
DISALLOW_COPY_AND_ASSIGN(AcceleratedSurfaceTransformer); |
}; |
-#endif // UI_SURFACE_ACCELERATED_SURFACE_TRANSFORMER_WIN_H_ |
+#endif // UI_SURFACE_ACCELERATED_SURFACE_TRANSFORMER_WIN_H_ |