| 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 #include "content/common/gpu/client/gl_helper.h" | 5 #include "content/common/gpu/client/gl_helper.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <queue> | 10 #include <queue> |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 ReadbackSwizzle swizzle, | 182 ReadbackSwizzle swizzle, |
| 183 const base::Callback<void(bool)>& callback); | 183 const base::Callback<void(bool)>& callback); |
| 184 | 184 |
| 185 GLuint CopyAndScaleTexture(GLuint texture, | 185 GLuint CopyAndScaleTexture(GLuint texture, |
| 186 const gfx::Size& src_size, | 186 const gfx::Size& src_size, |
| 187 const gfx::Size& dst_size, | 187 const gfx::Size& dst_size, |
| 188 bool vertically_flip_texture, | 188 bool vertically_flip_texture, |
| 189 GLHelper::ScalerQuality quality); | 189 GLHelper::ScalerQuality quality); |
| 190 | 190 |
| 191 ReadbackYUVInterface* CreateReadbackPipelineYUV( | 191 ReadbackYUVInterface* CreateReadbackPipelineYUV( |
| 192 GLHelper::ScalerQuality quality, | |
| 193 const gfx::Size& src_size, | 192 const gfx::Size& src_size, |
| 194 const gfx::Rect& src_subrect, | 193 const gfx::Rect& src_subrect, |
| 195 const gfx::Size& dst_size, | 194 const gfx::Size& dst_size, |
| 196 bool flip_vertically, | 195 bool flip_vertically, |
| 197 bool use_mrt); | 196 bool use_mrt); |
| 198 | 197 |
| 199 // Returns the maximum number of draw buffers available, | 198 // Returns the maximum number of draw buffers available, |
| 200 // 0 if GL_EXT_draw_buffers is not available. | 199 // 0 if GL_EXT_draw_buffers is not available. |
| 201 GLint MaxDrawBuffers() const { return max_draw_buffers_; } | 200 GLint MaxDrawBuffers() const { return max_draw_buffers_; } |
| 202 | 201 |
| (...skipping 1120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1323 DCHECK(readback_support_.get()); | 1322 DCHECK(readback_support_.get()); |
| 1324 GLenum format, type; | 1323 GLenum format, type; |
| 1325 size_t bytes_per_pixel; | 1324 size_t bytes_per_pixel; |
| 1326 FormatSupport support = readback_support_->GetReadbackConfig( | 1325 FormatSupport support = readback_support_->GetReadbackConfig( |
| 1327 color_type, false, &format, &type, &bytes_per_pixel); | 1326 color_type, false, &format, &type, &bytes_per_pixel); |
| 1328 | 1327 |
| 1329 return (support == GLHelperReadbackSupport::SUPPORTED); | 1328 return (support == GLHelperReadbackSupport::SUPPORTED); |
| 1330 } | 1329 } |
| 1331 | 1330 |
| 1332 ReadbackYUVInterface* GLHelper::CopyTextureToImpl::CreateReadbackPipelineYUV( | 1331 ReadbackYUVInterface* GLHelper::CopyTextureToImpl::CreateReadbackPipelineYUV( |
| 1333 GLHelper::ScalerQuality quality, | |
| 1334 const gfx::Size& src_size, | 1332 const gfx::Size& src_size, |
| 1335 const gfx::Rect& src_subrect, | 1333 const gfx::Rect& src_subrect, |
| 1336 const gfx::Size& dst_size, | 1334 const gfx::Size& dst_size, |
| 1337 bool flip_vertically, | 1335 bool flip_vertically, |
| 1338 bool use_mrt) { | 1336 bool use_mrt) { |
| 1339 helper_->InitScalerImpl(); | 1337 helper_->InitScalerImpl(); |
| 1340 // Just query if the best readback configuration needs a swizzle In | 1338 // Just query if the best readback configuration needs a swizzle In |
| 1341 // ReadbackPlane() we will choose GL_RGBA/GL_BGRA_EXT based on swizzle | 1339 // ReadbackPlane() we will choose GL_RGBA/GL_BGRA_EXT based on swizzle |
| 1342 GLenum format, type; | 1340 GLenum format, type; |
| 1343 size_t bytes_per_pixel; | 1341 size_t bytes_per_pixel; |
| 1344 FormatSupport supported = GetReadbackConfig( | 1342 FormatSupport supported = GetReadbackConfig( |
| 1345 kRGBA_8888_SkColorType, true, &format, &type, &bytes_per_pixel); | 1343 kRGBA_8888_SkColorType, true, &format, &type, &bytes_per_pixel); |
| 1346 DCHECK((format == GL_RGBA || format == GL_BGRA_EXT) && | 1344 DCHECK((format == GL_RGBA || format == GL_BGRA_EXT) && |
| 1347 type == GL_UNSIGNED_BYTE); | 1345 type == GL_UNSIGNED_BYTE); |
| 1348 | 1346 |
| 1349 ReadbackSwizzle swizzle = kSwizzleNone; | 1347 ReadbackSwizzle swizzle = kSwizzleNone; |
| 1350 if (supported == GLHelperReadbackSupport::SWIZZLE) | 1348 if (supported == GLHelperReadbackSupport::SWIZZLE) |
| 1351 swizzle = kSwizzleBGRA; | 1349 swizzle = kSwizzleBGRA; |
| 1352 | 1350 |
| 1351 GLHelper::ScalerQuality quality = ((src_size.width() < dst_size.width()) && |
| 1352 (src_size.height() < dst_size.height())) |
| 1353 ? GLHelper::SCALER_QUALITY_BEST |
| 1354 : GLHelper::SCALER_QUALITY_FAST; |
| 1353 if (max_draw_buffers_ >= 2 && use_mrt) { | 1355 if (max_draw_buffers_ >= 2 && use_mrt) { |
| 1354 return new ReadbackYUV_MRT(gl_, | 1356 return new ReadbackYUV_MRT(gl_, |
| 1355 this, | 1357 this, |
| 1356 helper_->scaler_impl_.get(), | 1358 helper_->scaler_impl_.get(), |
| 1357 quality, | 1359 quality, |
| 1358 src_size, | 1360 src_size, |
| 1359 src_subrect, | 1361 src_subrect, |
| 1360 dst_size, | 1362 dst_size, |
| 1361 flip_vertically, | 1363 flip_vertically, |
| 1362 swizzle); | 1364 swizzle); |
| 1363 } | 1365 } |
| 1364 return new ReadbackYUVImpl(gl_, | 1366 return new ReadbackYUVImpl(gl_, |
| 1365 this, | 1367 this, |
| 1366 helper_->scaler_impl_.get(), | 1368 helper_->scaler_impl_.get(), |
| 1367 quality, | 1369 quality, |
| 1368 src_size, | 1370 src_size, |
| 1369 src_subrect, | 1371 src_subrect, |
| 1370 dst_size, | 1372 dst_size, |
| 1371 flip_vertically, | 1373 flip_vertically, |
| 1372 swizzle); | 1374 swizzle); |
| 1373 } | 1375 } |
| 1374 | 1376 |
| 1375 ReadbackYUVInterface* GLHelper::CreateReadbackPipelineYUV( | 1377 ReadbackYUVInterface* GLHelper::CreateReadbackPipelineYUV( |
| 1376 ScalerQuality quality, | |
| 1377 const gfx::Size& src_size, | 1378 const gfx::Size& src_size, |
| 1378 const gfx::Rect& src_subrect, | 1379 const gfx::Rect& src_subrect, |
| 1379 const gfx::Size& dst_size, | 1380 const gfx::Size& dst_size, |
| 1380 bool flip_vertically, | 1381 bool flip_vertically, |
| 1381 bool use_mrt) { | 1382 bool use_mrt) { |
| 1382 InitCopyTextToImpl(); | 1383 InitCopyTextToImpl(); |
| 1383 return copy_texture_to_impl_->CreateReadbackPipelineYUV(quality, | 1384 return copy_texture_to_impl_->CreateReadbackPipelineYUV( |
| 1384 src_size, | 1385 src_size, src_subrect, dst_size, flip_vertically, use_mrt); |
| 1385 src_subrect, | |
| 1386 dst_size, | |
| 1387 flip_vertically, | |
| 1388 use_mrt); | |
| 1389 } | 1386 } |
| 1390 | 1387 |
| 1391 } // namespace content | 1388 } // namespace content |
| OLD | NEW |