Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_COMMON_GPU_CLIENT_GL_HELPER_H_ | 5 #ifndef CONTENT_COMMON_GPU_CLIENT_GL_HELPER_H_ |
| 6 #define CONTENT_COMMON_GPU_CLIENT_GL_HELPER_H_ | 6 #define CONTENT_COMMON_GPU_CLIENT_GL_HELPER_H_ |
| 7 | 7 |
| 8 #include "base/atomicops.h" | 8 #include "base/atomicops.h" |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 162 // Image quality is nearly as good as the BEST option. | 162 // Image quality is nearly as good as the BEST option. |
| 163 SCALER_QUALITY_GOOD = 2, | 163 SCALER_QUALITY_GOOD = 2, |
| 164 | 164 |
| 165 // Bicubic upscale + N * 50% bicubic downscales. | 165 // Bicubic upscale + N * 50% bicubic downscales. |
| 166 // Produces very good quality scaled images, but it's | 166 // Produces very good quality scaled images, but it's |
| 167 // 2-8x slower than the "GOOD" quality, so it's not always | 167 // 2-8x slower than the "GOOD" quality, so it's not always |
| 168 // worth it. | 168 // worth it. |
| 169 SCALER_QUALITY_BEST = 3, | 169 SCALER_QUALITY_BEST = 3, |
| 170 }; | 170 }; |
| 171 | 171 |
| 172 enum FormatSupport { | |
| 173 FORMAT_NOT_SUPPORTED = 0, | |
| 174 FORMAT_SUPPORTED, | |
| 175 FORMAT_NONE, | |
|
no sievers
2014/02/19 19:09:39
nit: FORMAT_NONE -> FORMAT_SUPPORT_UNKNOWN
sivag
2014/02/21 11:40:51
Done.
| |
| 176 }; | |
| 177 | |
| 172 // Copies the block of pixels specified with |src_subrect| from |src_texture|, | 178 // Copies the block of pixels specified with |src_subrect| from |src_texture|, |
| 173 // scales it to |dst_size|, and writes it into |out|. | 179 // scales it to |dst_size|, and writes it into |out|. |
| 174 // |src_size| is the size of |src_texture|. The result is of format GL_BGRA | 180 // |src_size| is the size of |src_texture|. The result is of format GL_BGRA |
| 175 // and is potentially flipped vertically to make it a correct image | 181 // and is potentially flipped vertically to make it a correct image |
| 176 // representation. |callback| is invoked with the copy result when the copy | 182 // representation. |callback| is invoked with the copy result when the copy |
| 177 // operation has completed. | 183 // operation has completed. |
| 178 // Note that the src_texture will have the min/mag filter set to GL_LINEAR | 184 // Note that the src_texture will have the min/mag filter set to GL_LINEAR |
| 179 // and wrap_s/t set to CLAMP_TO_EDGE in this call. | 185 // and wrap_s/t set to CLAMP_TO_EDGE in this call. |
| 180 void CropScaleReadbackAndCleanTexture( | 186 void CropScaleReadbackAndCleanTexture( |
| 181 GLuint src_texture, | 187 GLuint src_texture, |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 270 // Resizes the texture's size to |size|. | 276 // Resizes the texture's size to |size|. |
| 271 void ResizeTexture(GLuint texture, const gfx::Size& size); | 277 void ResizeTexture(GLuint texture, const gfx::Size& size); |
| 272 | 278 |
| 273 // Copies the framebuffer data given in |rect| to |texture|. | 279 // Copies the framebuffer data given in |rect| to |texture|. |
| 274 void CopyTextureSubImage(GLuint texture, const gfx::Rect& rect); | 280 void CopyTextureSubImage(GLuint texture, const gfx::Rect& rect); |
| 275 | 281 |
| 276 // Copies the all framebuffer data to |texture|. |size| specifies the | 282 // Copies the all framebuffer data to |texture|. |size| specifies the |
| 277 // size of the framebuffer. | 283 // size of the framebuffer. |
| 278 void CopyTextureFullImage(GLuint texture, const gfx::Size& size); | 284 void CopyTextureFullImage(GLuint texture, const gfx::Size& size); |
| 279 | 285 |
| 280 // Check whether rgb565 readback is supported or not. | 286 // Checks whether the readback using passed texture format |
| 281 bool CanUseRgb565Readback(); | 287 // is supported or not. |
|
no sievers
2014/02/19 19:09:39
nit: I think the comment could still be a bit clea
sivag
2014/02/21 11:40:51
Done.
| |
| 288 bool IsReadBackConfigSupported(const SkBitmap::Config& bitmap_format); | |
| 282 | 289 |
| 283 // A scaler will cache all intermediate textures and programs | 290 // A scaler will cache all intermediate textures and programs |
| 284 // needed to scale from a specified size to a destination size. | 291 // needed to scale from a specified size to a destination size. |
| 285 // If the source or destination sizes changes, you must create | 292 // If the source or destination sizes changes, you must create |
| 286 // a new scaler. | 293 // a new scaler. |
| 287 class CONTENT_EXPORT ScalerInterface { | 294 class CONTENT_EXPORT ScalerInterface { |
| 288 public: | 295 public: |
| 289 ScalerInterface() {} | 296 ScalerInterface() {} |
| 290 virtual ~ScalerInterface() {} | 297 virtual ~ScalerInterface() {} |
| 291 | 298 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 321 const gfx::Rect& src_subrect, | 328 const gfx::Rect& src_subrect, |
| 322 const gfx::Size& dst_size, | 329 const gfx::Size& dst_size, |
| 323 const gfx::Rect& dst_subrect, | 330 const gfx::Rect& dst_subrect, |
| 324 bool flip_vertically, | 331 bool flip_vertically, |
| 325 bool use_mrt); | 332 bool use_mrt); |
| 326 | 333 |
| 327 // Returns the maximum number of draw buffers available, | 334 // Returns the maximum number of draw buffers available, |
| 328 // 0 if GL_EXT_draw_buffers is not available. | 335 // 0 if GL_EXT_draw_buffers is not available. |
| 329 GLint MaxDrawBuffers(); | 336 GLint MaxDrawBuffers(); |
| 330 | 337 |
| 338 private: | |
| 339 // Helper functions for checking the supported texture formats. | |
| 340 bool SupportsFormat(GLint format, GLint type); | |
| 341 | |
| 331 protected: | 342 protected: |
| 332 class CopyTextureToImpl; | 343 class CopyTextureToImpl; |
| 333 | 344 |
| 334 // Creates |copy_texture_to_impl_| if NULL. | 345 // Creates |copy_texture_to_impl_| if NULL. |
| 335 void InitCopyTextToImpl(); | 346 void InitCopyTextToImpl(); |
| 336 // Creates |scaler_impl_| if NULL. | 347 // Creates |scaler_impl_| if NULL. |
| 337 void InitScalerImpl(); | 348 void InitScalerImpl(); |
| 338 | 349 |
| 339 gpu::gles2::GLES2Interface* gl_; | 350 gpu::gles2::GLES2Interface* gl_; |
| 340 gpu::ContextSupport* context_support_; | 351 gpu::ContextSupport* context_support_; |
| 341 scoped_ptr<CopyTextureToImpl> copy_texture_to_impl_; | 352 scoped_ptr<CopyTextureToImpl> copy_texture_to_impl_; |
| 342 scoped_ptr<GLHelperScaling> scaler_impl_; | 353 scoped_ptr<GLHelperScaling> scaler_impl_; |
| 343 bool initialized_565_format_check_; | 354 FormatSupport format_support_table_[SkBitmap::kConfigCount]; |
| 344 bool support_565_format_; | |
| 345 | 355 |
| 346 DISALLOW_COPY_AND_ASSIGN(GLHelper); | 356 DISALLOW_COPY_AND_ASSIGN(GLHelper); |
| 347 }; | 357 }; |
| 348 | 358 |
| 349 // Similar to a ScalerInterface, a yuv readback pipeline will | 359 // Similar to a ScalerInterface, a yuv readback pipeline will |
| 350 // cache a scaler and all intermediate textures and frame buffers | 360 // cache a scaler and all intermediate textures and frame buffers |
| 351 // needed to scale, crop, letterbox and read back a texture from | 361 // needed to scale, crop, letterbox and read back a texture from |
| 352 // the GPU into CPU-accessible RAM. A single readback pipeline | 362 // the GPU into CPU-accessible RAM. A single readback pipeline |
| 353 // can handle multiple outstanding readbacks at the same time, but | 363 // can handle multiple outstanding readbacks at the same time, but |
| 354 // if the source or destination sizes change, you'll need to create | 364 // if the source or destination sizes change, you'll need to create |
| 355 // a new readback pipeline. | 365 // a new readback pipeline. |
| 356 class CONTENT_EXPORT ReadbackYUVInterface { | 366 class CONTENT_EXPORT ReadbackYUVInterface { |
| 357 public: | 367 public: |
| 358 ReadbackYUVInterface() {} | 368 ReadbackYUVInterface() {} |
| 359 virtual ~ReadbackYUVInterface() {} | 369 virtual ~ReadbackYUVInterface() {} |
| 360 | 370 |
| 361 // Note that |target| must use YV12 format. | 371 // Note that |target| must use YV12 format. |
| 362 virtual void ReadbackYUV(const gpu::Mailbox& mailbox, | 372 virtual void ReadbackYUV(const gpu::Mailbox& mailbox, |
| 363 uint32 sync_point, | 373 uint32 sync_point, |
| 364 const scoped_refptr<media::VideoFrame>& target, | 374 const scoped_refptr<media::VideoFrame>& target, |
| 365 const base::Callback<void(bool)>& callback) = 0; | 375 const base::Callback<void(bool)>& callback) = 0; |
| 366 virtual GLHelper::ScalerInterface* scaler() = 0; | 376 virtual GLHelper::ScalerInterface* scaler() = 0; |
| 367 }; | 377 }; |
| 368 | 378 |
| 369 } // namespace content | 379 } // namespace content |
| 370 | 380 |
| 371 #endif // CONTENT_COMMON_GPU_CLIENT_GL_HELPER_H_ | 381 #endif // CONTENT_COMMON_GPU_CLIENT_GL_HELPER_H_ |
| OLD | NEW |