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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 | 137 |
138 ~ScopedFlush() { gl_->Flush(); } | 138 ~ScopedFlush() { gl_->Flush(); } |
139 | 139 |
140 private: | 140 private: |
141 gpu::gles2::GLES2Interface* gl_; | 141 gpu::gles2::GLES2Interface* gl_; |
142 | 142 |
143 DISALLOW_COPY_AND_ASSIGN(ScopedFlush); | 143 DISALLOW_COPY_AND_ASSIGN(ScopedFlush); |
144 }; | 144 }; |
145 | 145 |
146 class ReadbackYUVInterface; | 146 class ReadbackYUVInterface; |
| 147 class GLHelperReadbackSupport; |
147 | 148 |
148 // Provides higher level operations on top of the gpu::gles2::GLES2Interface | 149 // Provides higher level operations on top of the gpu::gles2::GLES2Interface |
149 // interfaces. | 150 // interfaces. |
150 class CONTENT_EXPORT GLHelper { | 151 class CONTENT_EXPORT GLHelper { |
151 public: | 152 public: |
152 GLHelper(gpu::gles2::GLES2Interface* gl, | 153 GLHelper(gpu::gles2::GLES2Interface* gl, |
153 gpu::ContextSupport* context_support); | 154 gpu::ContextSupport* context_support); |
154 ~GLHelper(); | 155 ~GLHelper(); |
155 | 156 |
156 enum ScalerQuality { | 157 enum ScalerQuality { |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 // Resizes the texture's size to |size|. | 271 // Resizes the texture's size to |size|. |
271 void ResizeTexture(GLuint texture, const gfx::Size& size); | 272 void ResizeTexture(GLuint texture, const gfx::Size& size); |
272 | 273 |
273 // Copies the framebuffer data given in |rect| to |texture|. | 274 // Copies the framebuffer data given in |rect| to |texture|. |
274 void CopyTextureSubImage(GLuint texture, const gfx::Rect& rect); | 275 void CopyTextureSubImage(GLuint texture, const gfx::Rect& rect); |
275 | 276 |
276 // Copies the all framebuffer data to |texture|. |size| specifies the | 277 // Copies the all framebuffer data to |texture|. |size| specifies the |
277 // size of the framebuffer. | 278 // size of the framebuffer. |
278 void CopyTextureFullImage(GLuint texture, const gfx::Size& size); | 279 void CopyTextureFullImage(GLuint texture, const gfx::Size& size); |
279 | 280 |
280 // Check whether rgb565 readback is supported or not. | |
281 bool CanUseRgb565Readback(); | |
282 | |
283 // A scaler will cache all intermediate textures and programs | 281 // A scaler will cache all intermediate textures and programs |
284 // needed to scale from a specified size to a destination size. | 282 // needed to scale from a specified size to a destination size. |
285 // If the source or destination sizes changes, you must create | 283 // If the source or destination sizes changes, you must create |
286 // a new scaler. | 284 // a new scaler. |
287 class CONTENT_EXPORT ScalerInterface { | 285 class CONTENT_EXPORT ScalerInterface { |
288 public: | 286 public: |
289 ScalerInterface() {} | 287 ScalerInterface() {} |
290 virtual ~ScalerInterface() {} | 288 virtual ~ScalerInterface() {} |
291 | 289 |
292 // Note that the src_texture will have the min/mag filter set to GL_LINEAR | 290 // Note that the src_texture will have the min/mag filter set to GL_LINEAR |
(...skipping 28 matching lines...) Expand all Loading... |
321 const gfx::Rect& src_subrect, | 319 const gfx::Rect& src_subrect, |
322 const gfx::Size& dst_size, | 320 const gfx::Size& dst_size, |
323 const gfx::Rect& dst_subrect, | 321 const gfx::Rect& dst_subrect, |
324 bool flip_vertically, | 322 bool flip_vertically, |
325 bool use_mrt); | 323 bool use_mrt); |
326 | 324 |
327 // Returns the maximum number of draw buffers available, | 325 // Returns the maximum number of draw buffers available, |
328 // 0 if GL_EXT_draw_buffers is not available. | 326 // 0 if GL_EXT_draw_buffers is not available. |
329 GLint MaxDrawBuffers(); | 327 GLint MaxDrawBuffers(); |
330 | 328 |
| 329 // Checks whether the readbback is supported for texture with the |
| 330 // matching config. This doesnt check for cross format readbacks. |
| 331 bool IsReadbackConfigSupported(SkBitmap::Config texture_format); |
| 332 |
331 protected: | 333 protected: |
332 class CopyTextureToImpl; | 334 class CopyTextureToImpl; |
333 | 335 |
334 // Creates |copy_texture_to_impl_| if NULL. | 336 // Creates |copy_texture_to_impl_| if NULL. |
335 void InitCopyTextToImpl(); | 337 void InitCopyTextToImpl(); |
336 // Creates |scaler_impl_| if NULL. | 338 // Creates |scaler_impl_| if NULL. |
337 void InitScalerImpl(); | 339 void InitScalerImpl(); |
338 | 340 |
339 gpu::gles2::GLES2Interface* gl_; | 341 gpu::gles2::GLES2Interface* gl_; |
340 gpu::ContextSupport* context_support_; | 342 gpu::ContextSupport* context_support_; |
341 scoped_ptr<CopyTextureToImpl> copy_texture_to_impl_; | 343 scoped_ptr<CopyTextureToImpl> copy_texture_to_impl_; |
342 scoped_ptr<GLHelperScaling> scaler_impl_; | 344 scoped_ptr<GLHelperScaling> scaler_impl_; |
343 bool initialized_565_format_check_; | 345 scoped_ptr<GLHelperReadbackSupport> readback_support_; |
344 bool support_565_format_; | |
345 | 346 |
346 DISALLOW_COPY_AND_ASSIGN(GLHelper); | 347 DISALLOW_COPY_AND_ASSIGN(GLHelper); |
347 }; | 348 }; |
348 | 349 |
349 // Similar to a ScalerInterface, a yuv readback pipeline will | 350 // Similar to a ScalerInterface, a yuv readback pipeline will |
350 // cache a scaler and all intermediate textures and frame buffers | 351 // cache a scaler and all intermediate textures and frame buffers |
351 // needed to scale, crop, letterbox and read back a texture from | 352 // needed to scale, crop, letterbox and read back a texture from |
352 // the GPU into CPU-accessible RAM. A single readback pipeline | 353 // the GPU into CPU-accessible RAM. A single readback pipeline |
353 // can handle multiple outstanding readbacks at the same time, but | 354 // can handle multiple outstanding readbacks at the same time, but |
354 // if the source or destination sizes change, you'll need to create | 355 // if the source or destination sizes change, you'll need to create |
355 // a new readback pipeline. | 356 // a new readback pipeline. |
356 class CONTENT_EXPORT ReadbackYUVInterface { | 357 class CONTENT_EXPORT ReadbackYUVInterface { |
357 public: | 358 public: |
358 ReadbackYUVInterface() {} | 359 ReadbackYUVInterface() {} |
359 virtual ~ReadbackYUVInterface() {} | 360 virtual ~ReadbackYUVInterface() {} |
360 | 361 |
361 // Note that |target| must use YV12 format. | 362 // Note that |target| must use YV12 format. |
362 virtual void ReadbackYUV(const gpu::Mailbox& mailbox, | 363 virtual void ReadbackYUV(const gpu::Mailbox& mailbox, |
363 uint32 sync_point, | 364 uint32 sync_point, |
364 const scoped_refptr<media::VideoFrame>& target, | 365 const scoped_refptr<media::VideoFrame>& target, |
365 const base::Callback<void(bool)>& callback) = 0; | 366 const base::Callback<void(bool)>& callback) = 0; |
366 virtual GLHelper::ScalerInterface* scaler() = 0; | 367 virtual GLHelper::ScalerInterface* scaler() = 0; |
367 }; | 368 }; |
368 | 369 |
369 } // namespace content | 370 } // namespace content |
370 | 371 |
371 #endif // CONTENT_COMMON_GPU_CLIENT_GL_HELPER_H_ | 372 #endif // CONTENT_COMMON_GPU_CLIENT_GL_HELPER_H_ |
OLD | NEW |