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 #include "content/browser/compositor/gl_helper.h" | 5 #include "content/browser/compositor/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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 175 ReadbackSwizzle swizzle, | 175 ReadbackSwizzle swizzle, |
| 176 const base::Callback<void(bool)>& callback); | 176 const base::Callback<void(bool)>& callback); |
| 177 | 177 |
| 178 GLuint CopyAndScaleTexture(GLuint texture, | 178 GLuint CopyAndScaleTexture(GLuint texture, |
| 179 const gfx::Size& src_size, | 179 const gfx::Size& src_size, |
| 180 const gfx::Size& dst_size, | 180 const gfx::Size& dst_size, |
| 181 bool vertically_flip_texture, | 181 bool vertically_flip_texture, |
| 182 GLHelper::ScalerQuality quality); | 182 GLHelper::ScalerQuality quality); |
| 183 | 183 |
| 184 ReadbackYUVInterface* CreateReadbackPipelineYUV( | 184 ReadbackYUVInterface* CreateReadbackPipelineYUV( |
| 185 GLHelper::ScalerQuality quality, | |
| 186 const gfx::Size& src_size, | 185 const gfx::Size& src_size, |
| 187 const gfx::Rect& src_subrect, | 186 const gfx::Rect& src_subrect, |
| 188 const gfx::Size& dst_size, | 187 const gfx::Size& dst_size, |
| 189 bool flip_vertically, | 188 bool flip_vertically, |
| 190 bool use_mrt); | 189 bool use_mrt); |
| 191 | 190 |
| 192 // Returns the maximum number of draw buffers available, | 191 // Returns the maximum number of draw buffers available, |
| 193 // 0 if GL_EXT_draw_buffers is not available. | 192 // 0 if GL_EXT_draw_buffers is not available. |
| 194 GLint MaxDrawBuffers() const { return max_draw_buffers_; } | 193 GLint MaxDrawBuffers() const { return max_draw_buffers_; } |
| 195 | 194 |
| (...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1174 DCHECK(readback_support_.get()); | 1173 DCHECK(readback_support_.get()); |
| 1175 GLenum format, type; | 1174 GLenum format, type; |
| 1176 size_t bytes_per_pixel; | 1175 size_t bytes_per_pixel; |
| 1177 FormatSupport support = readback_support_->GetReadbackConfig( | 1176 FormatSupport support = readback_support_->GetReadbackConfig( |
| 1178 color_type, false, &format, &type, &bytes_per_pixel); | 1177 color_type, false, &format, &type, &bytes_per_pixel); |
| 1179 | 1178 |
| 1180 return (support == GLHelperReadbackSupport::SUPPORTED); | 1179 return (support == GLHelperReadbackSupport::SUPPORTED); |
| 1181 } | 1180 } |
| 1182 | 1181 |
| 1183 ReadbackYUVInterface* GLHelper::CopyTextureToImpl::CreateReadbackPipelineYUV( | 1182 ReadbackYUVInterface* GLHelper::CopyTextureToImpl::CreateReadbackPipelineYUV( |
| 1184 GLHelper::ScalerQuality quality, | |
| 1185 const gfx::Size& src_size, | 1183 const gfx::Size& src_size, |
| 1186 const gfx::Rect& src_subrect, | 1184 const gfx::Rect& src_subrect, |
| 1187 const gfx::Size& dst_size, | 1185 const gfx::Size& dst_size, |
| 1188 bool flip_vertically, | 1186 bool flip_vertically, |
| 1189 bool use_mrt) { | 1187 bool use_mrt) { |
| 1190 helper_->InitScalerImpl(); | 1188 helper_->InitScalerImpl(); |
| 1191 // Just query if the best readback configuration needs a swizzle In | 1189 // Just query if the best readback configuration needs a swizzle In |
| 1192 // ReadbackPlane() we will choose GL_RGBA/GL_BGRA_EXT based on swizzle | 1190 // ReadbackPlane() we will choose GL_RGBA/GL_BGRA_EXT based on swizzle |
| 1193 GLenum format, type; | 1191 GLenum format, type; |
| 1194 size_t bytes_per_pixel; | 1192 size_t bytes_per_pixel; |
| 1195 FormatSupport supported = GetReadbackConfig(kRGBA_8888_SkColorType, true, | 1193 FormatSupport supported = GetReadbackConfig(kRGBA_8888_SkColorType, true, |
| 1196 &format, &type, &bytes_per_pixel); | 1194 &format, &type, &bytes_per_pixel); |
| 1197 DCHECK((format == GL_RGBA || format == GL_BGRA_EXT) && | 1195 DCHECK((format == GL_RGBA || format == GL_BGRA_EXT) && |
| 1198 type == GL_UNSIGNED_BYTE); | 1196 type == GL_UNSIGNED_BYTE); |
| 1199 | 1197 |
| 1200 ReadbackSwizzle swizzle = kSwizzleNone; | 1198 ReadbackSwizzle swizzle = kSwizzleNone; |
| 1201 if (supported == GLHelperReadbackSupport::SWIZZLE) | 1199 if (supported == GLHelperReadbackSupport::SWIZZLE) |
| 1202 swizzle = kSwizzleBGRA; | 1200 swizzle = kSwizzleBGRA; |
| 1203 | 1201 |
| 1202 // "The YUV readback pipeline is used by real-time video capture of | |
| 1203 // tabs/windows/desktops. Therefore, the scaler chosen here is based on | |
| 1204 // performance measurements of full end-to-end systems. When down-scaling, | |
| 1205 // always use the "fast" scaler because it performs well on both low- and | |
| 1206 // high- end machines, provides decent image quality, and doesn't overwhelm | |
| 1207 // downstream video encoders with too much entropy (which can drastically | |
| 1208 // increase CPU utilization). When up-scaling, always use "best" because the | |
| 1209 // quality improvement is huge with insignificant performance penalty. Note | |
| 1210 // that this strategy differs from single-frame snapshot capture (i.e., using | |
| 1211 // the Skia/RGB code path). | |
| 1212 GLHelper::ScalerQuality quality = ((src_size.width() < dst_size.width()) && | |
| 1213 (src_size.height() < dst_size.height())) | |
| 1214 ? GLHelper::SCALER_QUALITY_BEST | |
| 1215 : GLHelper::SCALER_QUALITY_FAST; | |
|
piman
2016/04/06 18:32:47
If SCALER_QUALITY_GOOD is not used any more, can y
xjz
2016/04/06 18:44:05
SCALER_QUALITY_GOOD is used as the default scaler
piman
2016/04/06 19:20:07
If that the case, then can you leave the policy de
xjz
2016/04/06 23:03:38
Done.
| |
| 1204 if (max_draw_buffers_ >= 2 && use_mrt) { | 1216 if (max_draw_buffers_ >= 2 && use_mrt) { |
| 1205 return new ReadbackYUV_MRT(gl_, this, helper_->scaler_impl_.get(), quality, | 1217 return new ReadbackYUV_MRT(gl_, this, helper_->scaler_impl_.get(), quality, |
| 1206 src_size, src_subrect, dst_size, flip_vertically, | 1218 src_size, src_subrect, dst_size, flip_vertically, |
| 1207 swizzle); | 1219 swizzle); |
| 1208 } | 1220 } |
| 1209 return new ReadbackYUVImpl(gl_, this, helper_->scaler_impl_.get(), quality, | 1221 return new ReadbackYUVImpl(gl_, this, helper_->scaler_impl_.get(), quality, |
| 1210 src_size, src_subrect, dst_size, flip_vertically, | 1222 src_size, src_subrect, dst_size, flip_vertically, |
| 1211 swizzle); | 1223 swizzle); |
| 1212 } | 1224 } |
| 1213 | 1225 |
| 1214 ReadbackYUVInterface* GLHelper::CreateReadbackPipelineYUV( | 1226 ReadbackYUVInterface* GLHelper::CreateReadbackPipelineYUV( |
| 1215 ScalerQuality quality, | |
| 1216 const gfx::Size& src_size, | 1227 const gfx::Size& src_size, |
| 1217 const gfx::Rect& src_subrect, | 1228 const gfx::Rect& src_subrect, |
| 1218 const gfx::Size& dst_size, | 1229 const gfx::Size& dst_size, |
| 1219 bool flip_vertically, | 1230 bool flip_vertically, |
| 1220 bool use_mrt) { | 1231 bool use_mrt) { |
| 1221 InitCopyTextToImpl(); | 1232 InitCopyTextToImpl(); |
| 1222 return copy_texture_to_impl_->CreateReadbackPipelineYUV( | 1233 return copy_texture_to_impl_->CreateReadbackPipelineYUV( |
| 1223 quality, src_size, src_subrect, dst_size, flip_vertically, use_mrt); | 1234 src_size, src_subrect, dst_size, flip_vertically, use_mrt); |
| 1224 } | 1235 } |
| 1225 | 1236 |
| 1226 } // namespace content | 1237 } // namespace content |
| OLD | NEW |