| 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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 // representation. |callback| is invoked with the copy result when the copy | 165 // representation. |callback| is invoked with the copy result when the copy |
| 166 // operation has completed. | 166 // operation has completed. |
| 167 // Note that the src_texture will have the min/mag filter set to GL_LINEAR | 167 // Note that the src_texture will have the min/mag filter set to GL_LINEAR |
| 168 // and wrap_s/t set to CLAMP_TO_EDGE in this call. | 168 // and wrap_s/t set to CLAMP_TO_EDGE in this call. |
| 169 void CropScaleReadbackAndCleanTexture( | 169 void CropScaleReadbackAndCleanTexture( |
| 170 GLuint src_texture, | 170 GLuint src_texture, |
| 171 const gfx::Size& src_size, | 171 const gfx::Size& src_size, |
| 172 const gfx::Rect& src_subrect, | 172 const gfx::Rect& src_subrect, |
| 173 const gfx::Size& dst_size, | 173 const gfx::Size& dst_size, |
| 174 unsigned char* out, | 174 unsigned char* out, |
| 175 const SkBitmap::Config config, | 175 const SkColorType color_type, |
| 176 const base::Callback<void(bool)>& callback, | 176 const base::Callback<void(bool)>& callback, |
| 177 GLHelper::ScalerQuality quality); | 177 GLHelper::ScalerQuality quality); |
| 178 | 178 |
| 179 // Copies the block of pixels specified with |src_subrect| from |src_mailbox|, | 179 // Copies the block of pixels specified with |src_subrect| from |src_mailbox|, |
| 180 // scales it to |dst_size|, and writes it into |out|. | 180 // scales it to |dst_size|, and writes it into |out|. |
| 181 // |src_size| is the size of |src_mailbox|. The result is of format GL_BGRA | 181 // |src_size| is the size of |src_mailbox|. The result is of format GL_BGRA |
| 182 // and is potentially flipped vertically to make it a correct image | 182 // and is potentially flipped vertically to make it a correct image |
| 183 // representation. |callback| is invoked with the copy result when the copy | 183 // representation. |callback| is invoked with the copy result when the copy |
| 184 // operation has completed. | 184 // operation has completed. |
| 185 // Note that the texture bound to src_mailbox will have the min/mag filter set | 185 // Note that the texture bound to src_mailbox will have the min/mag filter set |
| 186 // to GL_LINEAR and wrap_s/t set to CLAMP_TO_EDGE in this call. src_mailbox is | 186 // to GL_LINEAR and wrap_s/t set to CLAMP_TO_EDGE in this call. src_mailbox is |
| 187 // assumed to be GL_TEXTURE_2D. | 187 // assumed to be GL_TEXTURE_2D. |
| 188 void CropScaleReadbackAndCleanMailbox( | 188 void CropScaleReadbackAndCleanMailbox( |
| 189 const gpu::Mailbox& src_mailbox, | 189 const gpu::Mailbox& src_mailbox, |
| 190 uint32 sync_point, | 190 uint32 sync_point, |
| 191 const gfx::Size& src_size, | 191 const gfx::Size& src_size, |
| 192 const gfx::Rect& src_subrect, | 192 const gfx::Rect& src_subrect, |
| 193 const gfx::Size& dst_size, | 193 const gfx::Size& dst_size, |
| 194 unsigned char* out, | 194 unsigned char* out, |
| 195 const SkBitmap::Config config, | 195 const SkColorType color_type, |
| 196 const base::Callback<void(bool)>& callback, | 196 const base::Callback<void(bool)>& callback, |
| 197 GLHelper::ScalerQuality quality); | 197 GLHelper::ScalerQuality quality); |
| 198 | 198 |
| 199 // Copies the texture data out of |texture| into |out|. |size| is the | 199 // Copies the texture data out of |texture| into |out|. |size| is the |
| 200 // size of the texture. No post processing is applied to the pixels. The | 200 // size of the texture. No post processing is applied to the pixels. The |
| 201 // texture is assumed to have a format of GL_RGBA with a pixel type of | 201 // texture is assumed to have a format of GL_RGBA with a pixel type of |
| 202 // GL_UNSIGNED_BYTE. This is a blocking call that calls glReadPixels on the | 202 // GL_UNSIGNED_BYTE. This is a blocking call that calls glReadPixels on the |
| 203 // current OpenGL context. | 203 // current OpenGL context. |
| 204 void ReadbackTextureSync(GLuint texture, | 204 void ReadbackTextureSync(GLuint texture, |
| 205 const gfx::Rect& src_rect, | 205 const gfx::Rect& src_rect, |
| 206 unsigned char* out, | 206 unsigned char* out, |
| 207 SkBitmap::Config format); | 207 SkColorType format); |
| 208 | 208 |
| 209 void ReadbackTextureAsync(GLuint texture, | 209 void ReadbackTextureAsync(GLuint texture, |
| 210 const gfx::Size& dst_size, | 210 const gfx::Size& dst_size, |
| 211 unsigned char* out, | 211 unsigned char* out, |
| 212 SkBitmap::Config config, | 212 SkColorType color_type, |
| 213 const base::Callback<void(bool)>& callback); | 213 const base::Callback<void(bool)>& callback); |
| 214 | 214 |
| 215 // Creates a copy of the specified texture. |size| is the size of the texture. | 215 // Creates a copy of the specified texture. |size| is the size of the texture. |
| 216 // Note that the src_texture will have the min/mag filter set to GL_LINEAR | 216 // Note that the src_texture will have the min/mag filter set to GL_LINEAR |
| 217 // and wrap_s/t set to CLAMP_TO_EDGE in this call. | 217 // and wrap_s/t set to CLAMP_TO_EDGE in this call. |
| 218 GLuint CopyTexture(GLuint texture, const gfx::Size& size); | 218 GLuint CopyTexture(GLuint texture, const gfx::Size& size); |
| 219 | 219 |
| 220 // Creates a scaled copy of the specified texture. |src_size| is the size of | 220 // Creates a scaled copy of the specified texture. |src_size| is the size of |
| 221 // the texture and |dst_size| is the size of the resulting copy. | 221 // the texture and |dst_size| is the size of the resulting copy. |
| 222 // Note that the src_texture will have the min/mag filter set to GL_LINEAR | 222 // Note that the src_texture will have the min/mag filter set to GL_LINEAR |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 const gfx::Rect& dst_subrect, | 315 const gfx::Rect& dst_subrect, |
| 316 bool flip_vertically, | 316 bool flip_vertically, |
| 317 bool use_mrt); | 317 bool use_mrt); |
| 318 | 318 |
| 319 // Returns the maximum number of draw buffers available, | 319 // Returns the maximum number of draw buffers available, |
| 320 // 0 if GL_EXT_draw_buffers is not available. | 320 // 0 if GL_EXT_draw_buffers is not available. |
| 321 GLint MaxDrawBuffers(); | 321 GLint MaxDrawBuffers(); |
| 322 | 322 |
| 323 // Checks whether the readbback is supported for texture with the | 323 // Checks whether the readbback is supported for texture with the |
| 324 // matching config. This doesnt check for cross format readbacks. | 324 // matching config. This doesnt check for cross format readbacks. |
| 325 bool IsReadbackConfigSupported(SkBitmap::Config texture_format); | 325 bool IsReadbackConfigSupported(SkColorType texture_format); |
| 326 | 326 |
| 327 protected: | 327 protected: |
| 328 class CopyTextureToImpl; | 328 class CopyTextureToImpl; |
| 329 | 329 |
| 330 // Creates |copy_texture_to_impl_| if NULL. | 330 // Creates |copy_texture_to_impl_| if NULL. |
| 331 void InitCopyTextToImpl(); | 331 void InitCopyTextToImpl(); |
| 332 // Creates |scaler_impl_| if NULL. | 332 // Creates |scaler_impl_| if NULL. |
| 333 void InitScalerImpl(); | 333 void InitScalerImpl(); |
| 334 | 334 |
| 335 enum ReadbackSwizzle { | 335 enum ReadbackSwizzle { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 362 virtual void ReadbackYUV(const gpu::Mailbox& mailbox, | 362 virtual void ReadbackYUV(const gpu::Mailbox& mailbox, |
| 363 uint32 sync_point, | 363 uint32 sync_point, |
| 364 const scoped_refptr<media::VideoFrame>& target, | 364 const scoped_refptr<media::VideoFrame>& target, |
| 365 const base::Callback<void(bool)>& callback) = 0; | 365 const base::Callback<void(bool)>& callback) = 0; |
| 366 virtual GLHelper::ScalerInterface* scaler() = 0; | 366 virtual GLHelper::ScalerInterface* scaler() = 0; |
| 367 }; | 367 }; |
| 368 | 368 |
| 369 } // namespace content | 369 } // namespace content |
| 370 | 370 |
| 371 #endif // CONTENT_COMMON_GPU_CLIENT_GL_HELPER_H_ | 371 #endif // CONTENT_COMMON_GPU_CLIENT_GL_HELPER_H_ |
| OLD | NEW |