| 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> |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/lazy_instance.h" | 14 #include "base/lazy_instance.h" |
| 15 #include "base/logging.h" | 15 #include "base/logging.h" |
| 16 #include "base/macros.h" | 16 #include "base/macros.h" |
| 17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| 18 #include "base/message_loop/message_loop.h" | 18 #include "base/message_loop/message_loop.h" |
| 19 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
| 20 #include "base/time/time.h" | 20 #include "base/time/time.h" |
| 21 #include "base/trace_event/trace_event.h" | 21 #include "base/trace_event/trace_event.h" |
| 22 #include "content/browser/compositor/gl_helper_readback_support.h" | 22 #include "content/browser/compositor/gl_helper_readback_support.h" |
| 23 #include "content/browser/compositor/gl_helper_scaling.h" | 23 #include "content/browser/compositor/gl_helper_scaling.h" |
| 24 #include "gpu/GLES2/gl2extchromium.h" | 24 #include "gpu/GLES2/gl2extchromium.h" |
| 25 #include "gpu/command_buffer/client/context_support.h" | 25 #include "gpu/command_buffer/client/context_support.h" |
| 26 #include "gpu/command_buffer/common/mailbox.h" | 26 #include "gpu/command_buffer/common/mailbox.h" |
| 27 #include "gpu/command_buffer/common/mailbox_holder.h" | 27 #include "gpu/command_buffer/common/mailbox_holder.h" |
| 28 #include "media/base/video_frame.h" | |
| 29 #include "media/base/video_util.h" | |
| 30 #include "third_party/skia/include/core/SkRegion.h" | 28 #include "third_party/skia/include/core/SkRegion.h" |
| 31 #include "ui/gfx/geometry/point.h" | 29 #include "ui/gfx/geometry/point.h" |
| 32 #include "ui/gfx/geometry/rect.h" | 30 #include "ui/gfx/geometry/rect.h" |
| 33 #include "ui/gfx/geometry/size.h" | 31 #include "ui/gfx/geometry/size.h" |
| 34 | 32 |
| 35 using gpu::gles2::GLES2Interface; | 33 using gpu::gles2::GLES2Interface; |
| 36 | 34 |
| 37 namespace { | 35 namespace { |
| 38 | 36 |
| 39 class ScopedFlush { | 37 class ScopedFlush { |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 const gfx::Size& dst_size, | 159 const gfx::Size& dst_size, |
| 162 int32_t bytes_per_row, // generally dst_size.width() * 4 | 160 int32_t bytes_per_row, // generally dst_size.width() * 4 |
| 163 int32_t row_stride_bytes, // generally dst_size.width() * 4 | 161 int32_t row_stride_bytes, // generally dst_size.width() * 4 |
| 164 unsigned char* out, | 162 unsigned char* out, |
| 165 GLenum format, | 163 GLenum format, |
| 166 GLenum type, | 164 GLenum type, |
| 167 size_t bytes_per_pixel, | 165 size_t bytes_per_pixel, |
| 168 const base::Callback<void(bool)>& callback); | 166 const base::Callback<void(bool)>& callback); |
| 169 | 167 |
| 170 void ReadbackPlane(TextureFrameBufferPair* source, | 168 void ReadbackPlane(TextureFrameBufferPair* source, |
| 171 const scoped_refptr<media::VideoFrame>& target, | 169 int row_stride_bytes, |
| 172 int plane, | 170 unsigned char* data, |
| 173 int size_shift, | 171 int size_shift, |
| 174 const gfx::Rect& paste_rect, | 172 const gfx::Rect& paste_rect, |
| 175 ReadbackSwizzle swizzle, | 173 ReadbackSwizzle swizzle, |
| 176 const base::Callback<void(bool)>& callback); | 174 const base::Callback<void(bool)>& callback); |
| 177 | 175 |
| 178 GLuint CopyAndScaleTexture(GLuint texture, | 176 GLuint CopyAndScaleTexture(GLuint texture, |
| 179 const gfx::Size& src_size, | 177 const gfx::Size& src_size, |
| 180 const gfx::Size& dst_size, | 178 const gfx::Size& dst_size, |
| 181 bool vertically_flip_texture, | 179 bool vertically_flip_texture, |
| 182 GLHelper::ScalerQuality quality); | 180 GLHelper::ScalerQuality quality); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 GLHelperScaling* scaler_impl, | 262 GLHelperScaling* scaler_impl, |
| 265 GLHelper::ScalerQuality quality, | 263 GLHelper::ScalerQuality quality, |
| 266 const gfx::Size& src_size, | 264 const gfx::Size& src_size, |
| 267 const gfx::Rect& src_subrect, | 265 const gfx::Rect& src_subrect, |
| 268 const gfx::Size& dst_size, | 266 const gfx::Size& dst_size, |
| 269 bool flip_vertically, | 267 bool flip_vertically, |
| 270 ReadbackSwizzle swizzle); | 268 ReadbackSwizzle swizzle); |
| 271 | 269 |
| 272 void ReadbackYUV(const gpu::Mailbox& mailbox, | 270 void ReadbackYUV(const gpu::Mailbox& mailbox, |
| 273 const gpu::SyncToken& sync_token, | 271 const gpu::SyncToken& sync_token, |
| 274 const scoped_refptr<media::VideoFrame>& target, | 272 const gfx::Rect& target_visible_rect, |
| 273 int y_plane_row_stride_bytes, |
| 274 unsigned char* y_plane_data, |
| 275 int u_plane_row_stride_bytes, |
| 276 unsigned char* u_plane_data, |
| 277 int v_plane_row_stride_bytes, |
| 278 unsigned char* v_plane_data, |
| 275 const gfx::Point& paste_location, | 279 const gfx::Point& paste_location, |
| 276 const base::Callback<void(bool)>& callback) override; | 280 const base::Callback<void(bool)>& callback) override; |
| 277 | 281 |
| 278 ScalerInterface* scaler() override { return scaler_.scaler(); } | 282 ScalerInterface* scaler() override { return scaler_.scaler(); } |
| 279 | 283 |
| 280 private: | 284 private: |
| 281 GLES2Interface* gl_; | 285 GLES2Interface* gl_; |
| 282 CopyTextureToImpl* copy_impl_; | 286 CopyTextureToImpl* copy_impl_; |
| 283 gfx::Size dst_size_; | 287 gfx::Size dst_size_; |
| 284 ReadbackSwizzle swizzle_; | 288 ReadbackSwizzle swizzle_; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 300 GLHelperScaling* scaler_impl, | 304 GLHelperScaling* scaler_impl, |
| 301 GLHelper::ScalerQuality quality, | 305 GLHelper::ScalerQuality quality, |
| 302 const gfx::Size& src_size, | 306 const gfx::Size& src_size, |
| 303 const gfx::Rect& src_subrect, | 307 const gfx::Rect& src_subrect, |
| 304 const gfx::Size& dst_size, | 308 const gfx::Size& dst_size, |
| 305 bool flip_vertically, | 309 bool flip_vertically, |
| 306 ReadbackSwizzle swizzle); | 310 ReadbackSwizzle swizzle); |
| 307 | 311 |
| 308 void ReadbackYUV(const gpu::Mailbox& mailbox, | 312 void ReadbackYUV(const gpu::Mailbox& mailbox, |
| 309 const gpu::SyncToken& sync_token, | 313 const gpu::SyncToken& sync_token, |
| 310 const scoped_refptr<media::VideoFrame>& target, | 314 const gfx::Rect& target_visible_rect, |
| 315 int y_plane_row_stride_bytes, |
| 316 unsigned char* y_plane_data, |
| 317 int u_plane_row_stride_bytes, |
| 318 unsigned char* u_plane_data, |
| 319 int v_plane_row_stride_bytes, |
| 320 unsigned char* v_plane_data, |
| 311 const gfx::Point& paste_location, | 321 const gfx::Point& paste_location, |
| 312 const base::Callback<void(bool)>& callback) override; | 322 const base::Callback<void(bool)>& callback) override; |
| 313 | 323 |
| 314 ScalerInterface* scaler() override { return scaler_.scaler(); } | 324 ScalerInterface* scaler() override { return scaler_.scaler(); } |
| 315 | 325 |
| 316 private: | 326 private: |
| 317 GLES2Interface* gl_; | 327 GLES2Interface* gl_; |
| 318 CopyTextureToImpl* copy_impl_; | 328 CopyTextureToImpl* copy_impl_; |
| 319 gfx::Size dst_size_; | 329 gfx::Size dst_size_; |
| 320 GLHelper::ScalerQuality quality_; | 330 GLHelper::ScalerQuality quality_; |
| (...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 924 void GLHelper::Flush() { | 934 void GLHelper::Flush() { |
| 925 gl_->Flush(); | 935 gl_->Flush(); |
| 926 } | 936 } |
| 927 | 937 |
| 928 void GLHelper::InsertOrderingBarrier() { | 938 void GLHelper::InsertOrderingBarrier() { |
| 929 gl_->OrderingBarrierCHROMIUM(); | 939 gl_->OrderingBarrierCHROMIUM(); |
| 930 } | 940 } |
| 931 | 941 |
| 932 void GLHelper::CopyTextureToImpl::ReadbackPlane( | 942 void GLHelper::CopyTextureToImpl::ReadbackPlane( |
| 933 TextureFrameBufferPair* source, | 943 TextureFrameBufferPair* source, |
| 934 const scoped_refptr<media::VideoFrame>& target, | 944 int row_stride_bytes, |
| 935 int plane, | 945 unsigned char* data, |
| 936 int size_shift, | 946 int size_shift, |
| 937 const gfx::Rect& paste_rect, | 947 const gfx::Rect& paste_rect, |
| 938 ReadbackSwizzle swizzle, | 948 ReadbackSwizzle swizzle, |
| 939 const base::Callback<void(bool)>& callback) { | 949 const base::Callback<void(bool)>& callback) { |
| 940 gl_->BindFramebuffer(GL_FRAMEBUFFER, source->framebuffer()); | 950 gl_->BindFramebuffer(GL_FRAMEBUFFER, source->framebuffer()); |
| 941 const size_t offset = target->stride(plane) * (paste_rect.y() >> size_shift) + | 951 const size_t offset = row_stride_bytes * (paste_rect.y() >> size_shift) + |
| 942 (paste_rect.x() >> size_shift); | 952 (paste_rect.x() >> size_shift); |
| 943 ReadbackAsync(source->size(), paste_rect.width() >> size_shift, | 953 ReadbackAsync(source->size(), paste_rect.width() >> size_shift, |
| 944 target->stride(plane), target->data(plane) + offset, | 954 row_stride_bytes, data + offset, |
| 945 (swizzle == kSwizzleBGRA) ? GL_BGRA_EXT : GL_RGBA, | 955 (swizzle == kSwizzleBGRA) ? GL_BGRA_EXT : GL_RGBA, |
| 946 GL_UNSIGNED_BYTE, 4, callback); | 956 GL_UNSIGNED_BYTE, 4, callback); |
| 947 } | 957 } |
| 948 | 958 |
| 949 const float GLHelper::CopyTextureToImpl::kRGBtoYColorWeights[] = { | 959 const float GLHelper::CopyTextureToImpl::kRGBtoYColorWeights[] = { |
| 950 0.257f, 0.504f, 0.098f, 0.0625f}; | 960 0.257f, 0.504f, 0.098f, 0.0625f}; |
| 951 const float GLHelper::CopyTextureToImpl::kRGBtoUColorWeights[] = { | 961 const float GLHelper::CopyTextureToImpl::kRGBtoUColorWeights[] = { |
| 952 -0.148f, -0.291f, 0.439f, 0.5f}; | 962 -0.148f, -0.291f, 0.439f, 0.5f}; |
| 953 const float GLHelper::CopyTextureToImpl::kRGBtoVColorWeights[] = { | 963 const float GLHelper::CopyTextureToImpl::kRGBtoVColorWeights[] = { |
| 954 0.439f, -0.368f, -0.071f, 0.5f}; | 964 0.439f, -0.368f, -0.071f, 0.5f}; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1005 (dst_size.width() + 7) & ~7, | 1015 (dst_size.width() + 7) & ~7, |
| 1006 (dst_size.height() + 1) & ~1), | 1016 (dst_size.height() + 1) & ~1), |
| 1007 gfx::Size((dst_size.width() + 7) / 8, (dst_size.height() + 1) / 2), | 1017 gfx::Size((dst_size.width() + 7) / 8, (dst_size.height() + 1) / 2), |
| 1008 false, | 1018 false, |
| 1009 (swizzle == kSwizzleBGRA), | 1019 (swizzle == kSwizzleBGRA), |
| 1010 kRGBtoVColorWeights)) { | 1020 kRGBtoVColorWeights)) { |
| 1011 DCHECK(!(dst_size.width() & 1)); | 1021 DCHECK(!(dst_size.width() & 1)); |
| 1012 DCHECK(!(dst_size.height() & 1)); | 1022 DCHECK(!(dst_size.height() & 1)); |
| 1013 } | 1023 } |
| 1014 | 1024 |
| 1015 static void CallbackKeepingVideoFrameAlive( | |
| 1016 scoped_refptr<media::VideoFrame> video_frame, | |
| 1017 const base::Callback<void(bool)>& callback, | |
| 1018 bool success) { | |
| 1019 callback.Run(success); | |
| 1020 } | |
| 1021 | |
| 1022 void GLHelper::CopyTextureToImpl::ReadbackYUVImpl::ReadbackYUV( | 1025 void GLHelper::CopyTextureToImpl::ReadbackYUVImpl::ReadbackYUV( |
| 1023 const gpu::Mailbox& mailbox, | 1026 const gpu::Mailbox& mailbox, |
| 1024 const gpu::SyncToken& sync_token, | 1027 const gpu::SyncToken& sync_token, |
| 1025 const scoped_refptr<media::VideoFrame>& target, | 1028 const gfx::Rect& target_visible_rect, |
| 1029 int y_plane_row_stride_bytes, |
| 1030 unsigned char* y_plane_data, |
| 1031 int u_plane_row_stride_bytes, |
| 1032 unsigned char* u_plane_data, |
| 1033 int v_plane_row_stride_bytes, |
| 1034 unsigned char* v_plane_data, |
| 1026 const gfx::Point& paste_location, | 1035 const gfx::Point& paste_location, |
| 1027 const base::Callback<void(bool)>& callback) { | 1036 const base::Callback<void(bool)>& callback) { |
| 1028 DCHECK(!(paste_location.x() & 1)); | 1037 DCHECK(!(paste_location.x() & 1)); |
| 1029 DCHECK(!(paste_location.y() & 1)); | 1038 DCHECK(!(paste_location.y() & 1)); |
| 1030 | 1039 |
| 1031 GLuint mailbox_texture = | 1040 GLuint mailbox_texture = |
| 1032 copy_impl_->ConsumeMailboxToTexture(mailbox, sync_token); | 1041 copy_impl_->ConsumeMailboxToTexture(mailbox, sync_token); |
| 1033 | 1042 |
| 1034 // Scale texture to right size. | 1043 // Scale texture to right size. |
| 1035 scaler_.Scale(mailbox_texture); | 1044 scaler_.Scale(mailbox_texture); |
| 1036 gl_->DeleteTextures(1, &mailbox_texture); | 1045 gl_->DeleteTextures(1, &mailbox_texture); |
| 1037 | 1046 |
| 1038 // Convert the scaled texture in to Y, U and V planes. | 1047 // Convert the scaled texture in to Y, U and V planes. |
| 1039 y_.Scale(scaler_.texture()); | 1048 y_.Scale(scaler_.texture()); |
| 1040 u_.Scale(scaler_.texture()); | 1049 u_.Scale(scaler_.texture()); |
| 1041 v_.Scale(scaler_.texture()); | 1050 v_.Scale(scaler_.texture()); |
| 1042 | 1051 |
| 1043 const gfx::Rect paste_rect(paste_location, dst_size_); | 1052 const gfx::Rect paste_rect(paste_location, dst_size_); |
| 1044 if (!target->visible_rect().Contains(paste_rect)) { | 1053 if (!target_visible_rect.Contains(paste_rect)) { |
| 1045 LOG(DFATAL) << "Paste rect not inside VideoFrame's visible rect!"; | 1054 LOG(DFATAL) << "Paste rect not inside VideoFrame's visible rect!"; |
| 1046 callback.Run(false); | 1055 callback.Run(false); |
| 1047 return; | 1056 return; |
| 1048 } | 1057 } |
| 1049 | 1058 |
| 1050 // Read back planes, one at a time. Keep the video frame alive while doing the | 1059 // Read back planes, one at a time. Keep the video frame alive while doing the |
| 1051 // readback. | 1060 // readback. |
| 1052 copy_impl_->ReadbackPlane(y_.texture_and_framebuffer(), target, | 1061 copy_impl_->ReadbackPlane(y_.texture_and_framebuffer(), |
| 1053 media::VideoFrame::kYPlane, 0, paste_rect, swizzle_, | 1062 y_plane_row_stride_bytes, y_plane_data, 0, |
| 1054 base::Bind(&nullcallback)); | 1063 paste_rect, swizzle_, base::Bind(&nullcallback)); |
| 1055 copy_impl_->ReadbackPlane(u_.texture_and_framebuffer(), target, | 1064 copy_impl_->ReadbackPlane(u_.texture_and_framebuffer(), |
| 1056 media::VideoFrame::kUPlane, 1, paste_rect, swizzle_, | 1065 u_plane_row_stride_bytes, u_plane_data, 1, |
| 1057 base::Bind(&nullcallback)); | 1066 paste_rect, swizzle_, base::Bind(&nullcallback)); |
| 1058 copy_impl_->ReadbackPlane( | 1067 copy_impl_->ReadbackPlane(v_.texture_and_framebuffer(), |
| 1059 v_.texture_and_framebuffer(), target, media::VideoFrame::kVPlane, 1, | 1068 v_plane_row_stride_bytes, v_plane_data, 1, |
| 1060 paste_rect, swizzle_, | 1069 paste_rect, swizzle_, callback); |
| 1061 base::Bind(&CallbackKeepingVideoFrameAlive, target, callback)); | |
| 1062 gl_->BindFramebuffer(GL_FRAMEBUFFER, 0); | 1070 gl_->BindFramebuffer(GL_FRAMEBUFFER, 0); |
| 1063 media::LetterboxYUV(target.get(), paste_rect); | |
| 1064 } | 1071 } |
| 1065 | 1072 |
| 1066 // YUV readback constructors. Initiates the main scaler pipeline and | 1073 // YUV readback constructors. Initiates the main scaler pipeline and |
| 1067 // one planar scaler for each of the Y, U and V planes. | 1074 // one planar scaler for each of the Y, U and V planes. |
| 1068 GLHelper::CopyTextureToImpl::ReadbackYUV_MRT::ReadbackYUV_MRT( | 1075 GLHelper::CopyTextureToImpl::ReadbackYUV_MRT::ReadbackYUV_MRT( |
| 1069 GLES2Interface* gl, | 1076 GLES2Interface* gl, |
| 1070 CopyTextureToImpl* copy_impl, | 1077 CopyTextureToImpl* copy_impl, |
| 1071 GLHelperScaling* scaler_impl, | 1078 GLHelperScaling* scaler_impl, |
| 1072 GLHelper::ScalerQuality quality, | 1079 GLHelper::ScalerQuality quality, |
| 1073 const gfx::Size& src_size, | 1080 const gfx::Size& src_size, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1111 DCHECK(!(dst_size.height() & 1)); | 1118 DCHECK(!(dst_size.height() & 1)); |
| 1112 | 1119 |
| 1113 content::ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl, uv_); | 1120 content::ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl, uv_); |
| 1114 gl->TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (dst_size.width() + 3) / 4, | 1121 gl->TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (dst_size.width() + 3) / 4, |
| 1115 dst_size.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); | 1122 dst_size.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); |
| 1116 } | 1123 } |
| 1117 | 1124 |
| 1118 void GLHelper::CopyTextureToImpl::ReadbackYUV_MRT::ReadbackYUV( | 1125 void GLHelper::CopyTextureToImpl::ReadbackYUV_MRT::ReadbackYUV( |
| 1119 const gpu::Mailbox& mailbox, | 1126 const gpu::Mailbox& mailbox, |
| 1120 const gpu::SyncToken& sync_token, | 1127 const gpu::SyncToken& sync_token, |
| 1121 const scoped_refptr<media::VideoFrame>& target, | 1128 const gfx::Rect& target_visible_rect, |
| 1129 int y_plane_row_stride_bytes, |
| 1130 unsigned char* y_plane_data, |
| 1131 int u_plane_row_stride_bytes, |
| 1132 unsigned char* u_plane_data, |
| 1133 int v_plane_row_stride_bytes, |
| 1134 unsigned char* v_plane_data, |
| 1122 const gfx::Point& paste_location, | 1135 const gfx::Point& paste_location, |
| 1123 const base::Callback<void(bool)>& callback) { | 1136 const base::Callback<void(bool)>& callback) { |
| 1124 DCHECK(!(paste_location.x() & 1)); | 1137 DCHECK(!(paste_location.x() & 1)); |
| 1125 DCHECK(!(paste_location.y() & 1)); | 1138 DCHECK(!(paste_location.y() & 1)); |
| 1126 | 1139 |
| 1127 GLuint mailbox_texture = | 1140 GLuint mailbox_texture = |
| 1128 copy_impl_->ConsumeMailboxToTexture(mailbox, sync_token); | 1141 copy_impl_->ConsumeMailboxToTexture(mailbox, sync_token); |
| 1129 | 1142 |
| 1130 GLuint texture; | 1143 GLuint texture; |
| 1131 if (quality_ == GLHelper::SCALER_QUALITY_FAST) { | 1144 if (quality_ == GLHelper::SCALER_QUALITY_FAST) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1145 outputs[1] = uv_; | 1158 outputs[1] = uv_; |
| 1146 pass1_shader_->Execute(texture, outputs); | 1159 pass1_shader_->Execute(texture, outputs); |
| 1147 | 1160 |
| 1148 gl_->DeleteTextures(1, &mailbox_texture); | 1161 gl_->DeleteTextures(1, &mailbox_texture); |
| 1149 | 1162 |
| 1150 outputs[0] = u_.texture(); | 1163 outputs[0] = u_.texture(); |
| 1151 outputs[1] = v_.texture(); | 1164 outputs[1] = v_.texture(); |
| 1152 pass2_shader_->Execute(uv_, outputs); | 1165 pass2_shader_->Execute(uv_, outputs); |
| 1153 | 1166 |
| 1154 const gfx::Rect paste_rect(paste_location, dst_size_); | 1167 const gfx::Rect paste_rect(paste_location, dst_size_); |
| 1155 if (!target->visible_rect().Contains(paste_rect)) { | 1168 if (!target_visible_rect.Contains(paste_rect)) { |
| 1156 LOG(DFATAL) << "Paste rect not inside VideoFrame's visible rect!"; | 1169 LOG(DFATAL) << "Paste rect not inside VideoFrame's visible rect!"; |
| 1157 callback.Run(false); | 1170 callback.Run(false); |
| 1158 return; | 1171 return; |
| 1159 } | 1172 } |
| 1160 | 1173 |
| 1161 // Read back planes, one at a time. | 1174 // Read back planes, one at a time. |
| 1162 copy_impl_->ReadbackPlane(&y_, target, media::VideoFrame::kYPlane, 0, | 1175 copy_impl_->ReadbackPlane(&y_, y_plane_row_stride_bytes, y_plane_data, 0, |
| 1163 paste_rect, swizzle_, base::Bind(&nullcallback)); | 1176 paste_rect, swizzle_, base::Bind(&nullcallback)); |
| 1164 copy_impl_->ReadbackPlane(&u_, target, media::VideoFrame::kUPlane, 1, | 1177 copy_impl_->ReadbackPlane(&u_, u_plane_row_stride_bytes, u_plane_data, 1, |
| 1165 paste_rect, swizzle_, base::Bind(&nullcallback)); | 1178 paste_rect, swizzle_, base::Bind(&nullcallback)); |
| 1166 copy_impl_->ReadbackPlane( | 1179 copy_impl_->ReadbackPlane(&v_, v_plane_row_stride_bytes, v_plane_data, 1, |
| 1167 &v_, target, media::VideoFrame::kVPlane, 1, paste_rect, swizzle_, | 1180 paste_rect, swizzle_, callback); |
| 1168 base::Bind(&CallbackKeepingVideoFrameAlive, target, callback)); | |
| 1169 gl_->BindFramebuffer(GL_FRAMEBUFFER, 0); | 1181 gl_->BindFramebuffer(GL_FRAMEBUFFER, 0); |
| 1170 media::LetterboxYUV(target.get(), paste_rect); | |
| 1171 } | 1182 } |
| 1172 | 1183 |
| 1173 bool GLHelper::IsReadbackConfigSupported(SkColorType color_type) { | 1184 bool GLHelper::IsReadbackConfigSupported(SkColorType color_type) { |
| 1174 DCHECK(readback_support_.get()); | 1185 DCHECK(readback_support_.get()); |
| 1175 GLenum format, type; | 1186 GLenum format, type; |
| 1176 size_t bytes_per_pixel; | 1187 size_t bytes_per_pixel; |
| 1177 FormatSupport support = readback_support_->GetReadbackConfig( | 1188 FormatSupport support = readback_support_->GetReadbackConfig( |
| 1178 color_type, false, &format, &type, &bytes_per_pixel); | 1189 color_type, false, &format, &type, &bytes_per_pixel); |
| 1179 | 1190 |
| 1180 return (support == GLHelperReadbackSupport::SUPPORTED); | 1191 return (support == GLHelperReadbackSupport::SUPPORTED); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 quality, src_size, src_subrect, dst_size, flip_vertically, use_mrt); |
| 1224 } | 1235 } |
| 1225 | 1236 |
| 1226 } // namespace content | 1237 } // namespace content |
| OLD | NEW |