Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(292)

Side by Side Diff: content/common/gpu/client/gl_helper.cc

Issue 1427543002: Modified old wait sync point functions to also accept new sync tokens. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: format Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/common/gpu/client/gl_helper.h ('k') | content/common/gpu/client/gl_helper_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <queue> 7 #include <queue>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 return; 126 return;
127 std::string extensions_string = 127 std::string extensions_string =
128 " " + std::string(reinterpret_cast<const char*>(extensions)) + " "; 128 " " + std::string(reinterpret_cast<const char*>(extensions)) + " ";
129 if (extensions_string.find(" GL_EXT_draw_buffers ") != std::string::npos) { 129 if (extensions_string.find(" GL_EXT_draw_buffers ") != std::string::npos) {
130 gl_->GetIntegerv(GL_MAX_DRAW_BUFFERS_EXT, &max_draw_buffers_); 130 gl_->GetIntegerv(GL_MAX_DRAW_BUFFERS_EXT, &max_draw_buffers_);
131 } 131 }
132 } 132 }
133 ~CopyTextureToImpl() { CancelRequests(); } 133 ~CopyTextureToImpl() { CancelRequests(); }
134 134
135 GLuint ConsumeMailboxToTexture(const gpu::Mailbox& mailbox, 135 GLuint ConsumeMailboxToTexture(const gpu::Mailbox& mailbox,
136 uint32 sync_point) { 136 const gpu::SyncToken& sync_token) {
137 return helper_->ConsumeMailboxToTexture(mailbox, sync_point); 137 return helper_->ConsumeMailboxToTexture(mailbox, sync_token);
138 } 138 }
139 139
140 void CropScaleReadbackAndCleanTexture( 140 void CropScaleReadbackAndCleanTexture(
141 GLuint src_texture, 141 GLuint src_texture,
142 const gfx::Size& src_size, 142 const gfx::Size& src_size,
143 const gfx::Rect& src_subrect, 143 const gfx::Rect& src_subrect,
144 const gfx::Size& dst_size, 144 const gfx::Size& dst_size,
145 unsigned char* out, 145 unsigned char* out,
146 const SkColorType out_color_type, 146 const SkColorType out_color_type,
147 const base::Callback<void(bool)>& callback, 147 const base::Callback<void(bool)>& callback,
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 CopyTextureToImpl* copy_impl, 266 CopyTextureToImpl* copy_impl,
267 GLHelperScaling* scaler_impl, 267 GLHelperScaling* scaler_impl,
268 GLHelper::ScalerQuality quality, 268 GLHelper::ScalerQuality quality,
269 const gfx::Size& src_size, 269 const gfx::Size& src_size,
270 const gfx::Rect& src_subrect, 270 const gfx::Rect& src_subrect,
271 const gfx::Size& dst_size, 271 const gfx::Size& dst_size,
272 bool flip_vertically, 272 bool flip_vertically,
273 ReadbackSwizzle swizzle); 273 ReadbackSwizzle swizzle);
274 274
275 void ReadbackYUV(const gpu::Mailbox& mailbox, 275 void ReadbackYUV(const gpu::Mailbox& mailbox,
276 uint32 sync_point, 276 const gpu::SyncToken& sync_token,
277 const scoped_refptr<media::VideoFrame>& target, 277 const scoped_refptr<media::VideoFrame>& target,
278 const gfx::Point& paste_location, 278 const gfx::Point& paste_location,
279 const base::Callback<void(bool)>& callback) override; 279 const base::Callback<void(bool)>& callback) override;
280 280
281 ScalerInterface* scaler() override { return scaler_.scaler(); } 281 ScalerInterface* scaler() override { return scaler_.scaler(); }
282 282
283 private: 283 private:
284 GLES2Interface* gl_; 284 GLES2Interface* gl_;
285 CopyTextureToImpl* copy_impl_; 285 CopyTextureToImpl* copy_impl_;
286 gfx::Size dst_size_; 286 gfx::Size dst_size_;
(...skipping 15 matching lines...) Expand all
302 CopyTextureToImpl* copy_impl, 302 CopyTextureToImpl* copy_impl,
303 GLHelperScaling* scaler_impl, 303 GLHelperScaling* scaler_impl,
304 GLHelper::ScalerQuality quality, 304 GLHelper::ScalerQuality quality,
305 const gfx::Size& src_size, 305 const gfx::Size& src_size,
306 const gfx::Rect& src_subrect, 306 const gfx::Rect& src_subrect,
307 const gfx::Size& dst_size, 307 const gfx::Size& dst_size,
308 bool flip_vertically, 308 bool flip_vertically,
309 ReadbackSwizzle swizzle); 309 ReadbackSwizzle swizzle);
310 310
311 void ReadbackYUV(const gpu::Mailbox& mailbox, 311 void ReadbackYUV(const gpu::Mailbox& mailbox,
312 uint32 sync_point, 312 const gpu::SyncToken& sync_token,
313 const scoped_refptr<media::VideoFrame>& target, 313 const scoped_refptr<media::VideoFrame>& target,
314 const gfx::Point& paste_location, 314 const gfx::Point& paste_location,
315 const base::Callback<void(bool)>& callback) override; 315 const base::Callback<void(bool)>& callback) override;
316 316
317 ScalerInterface* scaler() override { return scaler_.scaler(); } 317 ScalerInterface* scaler() override { return scaler_.scaler(); }
318 318
319 private: 319 private:
320 GLES2Interface* gl_; 320 GLES2Interface* gl_;
321 CopyTextureToImpl* copy_impl_; 321 CopyTextureToImpl* copy_impl_;
322 gfx::Size dst_size_; 322 gfx::Size dst_size_;
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 src_subrect, 808 src_subrect,
809 dst_size, 809 dst_size,
810 out, 810 out,
811 out_color_type, 811 out_color_type,
812 callback, 812 callback,
813 quality); 813 quality);
814 } 814 }
815 815
816 void GLHelper::CropScaleReadbackAndCleanMailbox( 816 void GLHelper::CropScaleReadbackAndCleanMailbox(
817 const gpu::Mailbox& src_mailbox, 817 const gpu::Mailbox& src_mailbox,
818 uint32 sync_point, 818 const gpu::SyncToken& sync_token,
819 const gfx::Size& src_size, 819 const gfx::Size& src_size,
820 const gfx::Rect& src_subrect, 820 const gfx::Rect& src_subrect,
821 const gfx::Size& dst_size, 821 const gfx::Size& dst_size,
822 unsigned char* out, 822 unsigned char* out,
823 const SkColorType out_color_type, 823 const SkColorType out_color_type,
824 const base::Callback<void(bool)>& callback, 824 const base::Callback<void(bool)>& callback,
825 GLHelper::ScalerQuality quality) { 825 GLHelper::ScalerQuality quality) {
826 GLuint mailbox_texture = ConsumeMailboxToTexture(src_mailbox, sync_point); 826 GLuint mailbox_texture = ConsumeMailboxToTexture(src_mailbox, sync_token);
827 CropScaleReadbackAndCleanTexture(mailbox_texture, 827 CropScaleReadbackAndCleanTexture(mailbox_texture,
828 src_size, 828 src_size,
829 src_subrect, 829 src_subrect,
830 dst_size, 830 dst_size,
831 out, 831 out,
832 out_color_type, 832 out_color_type,
833 callback, 833 callback,
834 quality); 834 quality);
835 gl_->DeleteTextures(1, &mailbox_texture); 835 gl_->DeleteTextures(1, &mailbox_texture);
836 } 836 }
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 947 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
948 return texture; 948 return texture;
949 } 949 }
950 950
951 void GLHelper::DeleteTexture(GLuint texture_id) { 951 void GLHelper::DeleteTexture(GLuint texture_id) {
952 gl_->DeleteTextures(1, &texture_id); 952 gl_->DeleteTextures(1, &texture_id);
953 } 953 }
954 954
955 uint32 GLHelper::InsertSyncPoint() { return gl_->InsertSyncPointCHROMIUM(); } 955 uint32 GLHelper::InsertSyncPoint() { return gl_->InsertSyncPointCHROMIUM(); }
956 956
957 void GLHelper::WaitSyncPoint(uint32 sync_point) { 957 void GLHelper::WaitSyncToken(const gpu::SyncToken& sync_token) {
958 gl_->WaitSyncPointCHROMIUM(sync_point); 958 gl_->WaitSyncTokenCHROMIUM(sync_token.GetConstData());
959 } 959 }
960 960
961 gpu::MailboxHolder GLHelper::ProduceMailboxHolderFromTexture( 961 gpu::MailboxHolder GLHelper::ProduceMailboxHolderFromTexture(
962 GLuint texture_id) { 962 GLuint texture_id) {
963 gpu::Mailbox mailbox; 963 gpu::Mailbox mailbox;
964 gl_->GenMailboxCHROMIUM(mailbox.name); 964 gl_->GenMailboxCHROMIUM(mailbox.name);
965 gl_->ProduceTextureDirectCHROMIUM(texture_id, GL_TEXTURE_2D, mailbox.name); 965 gl_->ProduceTextureDirectCHROMIUM(texture_id, GL_TEXTURE_2D, mailbox.name);
966 return gpu::MailboxHolder(mailbox, GL_TEXTURE_2D, InsertSyncPoint()); 966 return gpu::MailboxHolder(mailbox, gpu::SyncToken(InsertSyncPoint()),
967 GL_TEXTURE_2D);
967 } 968 }
968 969
969 GLuint GLHelper::ConsumeMailboxToTexture(const gpu::Mailbox& mailbox, 970 GLuint GLHelper::ConsumeMailboxToTexture(const gpu::Mailbox& mailbox,
970 uint32 sync_point) { 971 const gpu::SyncToken& sync_token) {
971 if (mailbox.IsZero()) 972 if (mailbox.IsZero())
972 return 0; 973 return 0;
973 if (sync_point) 974 if (sync_token.HasData())
974 WaitSyncPoint(sync_point); 975 WaitSyncToken(sync_token);
975 GLuint texture = 976 GLuint texture =
976 gl_->CreateAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); 977 gl_->CreateAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name);
977 return texture; 978 return texture;
978 } 979 }
979 980
980 void GLHelper::ResizeTexture(GLuint texture, const gfx::Size& size) { 981 void GLHelper::ResizeTexture(GLuint texture, const gfx::Size& size) {
981 content::ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, texture); 982 content::ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, texture);
982 gl_->TexImage2D(GL_TEXTURE_2D, 983 gl_->TexImage2D(GL_TEXTURE_2D,
983 0, 984 0,
984 GL_RGB, 985 GL_RGB,
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1110 1111
1111 static void CallbackKeepingVideoFrameAlive( 1112 static void CallbackKeepingVideoFrameAlive(
1112 scoped_refptr<media::VideoFrame> video_frame, 1113 scoped_refptr<media::VideoFrame> video_frame,
1113 const base::Callback<void(bool)>& callback, 1114 const base::Callback<void(bool)>& callback,
1114 bool success) { 1115 bool success) {
1115 callback.Run(success); 1116 callback.Run(success);
1116 } 1117 }
1117 1118
1118 void GLHelper::CopyTextureToImpl::ReadbackYUVImpl::ReadbackYUV( 1119 void GLHelper::CopyTextureToImpl::ReadbackYUVImpl::ReadbackYUV(
1119 const gpu::Mailbox& mailbox, 1120 const gpu::Mailbox& mailbox,
1120 uint32 sync_point, 1121 const gpu::SyncToken& sync_token,
1121 const scoped_refptr<media::VideoFrame>& target, 1122 const scoped_refptr<media::VideoFrame>& target,
1122 const gfx::Point& paste_location, 1123 const gfx::Point& paste_location,
1123 const base::Callback<void(bool)>& callback) { 1124 const base::Callback<void(bool)>& callback) {
1124 DCHECK(!(paste_location.x() & 1)); 1125 DCHECK(!(paste_location.x() & 1));
1125 DCHECK(!(paste_location.y() & 1)); 1126 DCHECK(!(paste_location.y() & 1));
1126 1127
1127 GLuint mailbox_texture = 1128 GLuint mailbox_texture =
1128 copy_impl_->ConsumeMailboxToTexture(mailbox, sync_point); 1129 copy_impl_->ConsumeMailboxToTexture(mailbox, sync_token);
1129 1130
1130 // Scale texture to right size. 1131 // Scale texture to right size.
1131 scaler_.Scale(mailbox_texture); 1132 scaler_.Scale(mailbox_texture);
1132 gl_->DeleteTextures(1, &mailbox_texture); 1133 gl_->DeleteTextures(1, &mailbox_texture);
1133 1134
1134 // Convert the scaled texture in to Y, U and V planes. 1135 // Convert the scaled texture in to Y, U and V planes.
1135 y_.Scale(scaler_.texture()); 1136 y_.Scale(scaler_.texture());
1136 u_.Scale(scaler_.texture()); 1137 u_.Scale(scaler_.texture());
1137 v_.Scale(scaler_.texture()); 1138 v_.Scale(scaler_.texture());
1138 1139
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1231 (dst_size.width() + 3) / 4, 1232 (dst_size.width() + 3) / 4,
1232 dst_size.height(), 1233 dst_size.height(),
1233 0, 1234 0,
1234 GL_RGBA, 1235 GL_RGBA,
1235 GL_UNSIGNED_BYTE, 1236 GL_UNSIGNED_BYTE,
1236 NULL); 1237 NULL);
1237 } 1238 }
1238 1239
1239 void GLHelper::CopyTextureToImpl::ReadbackYUV_MRT::ReadbackYUV( 1240 void GLHelper::CopyTextureToImpl::ReadbackYUV_MRT::ReadbackYUV(
1240 const gpu::Mailbox& mailbox, 1241 const gpu::Mailbox& mailbox,
1241 uint32 sync_point, 1242 const gpu::SyncToken& sync_token,
1242 const scoped_refptr<media::VideoFrame>& target, 1243 const scoped_refptr<media::VideoFrame>& target,
1243 const gfx::Point& paste_location, 1244 const gfx::Point& paste_location,
1244 const base::Callback<void(bool)>& callback) { 1245 const base::Callback<void(bool)>& callback) {
1245 DCHECK(!(paste_location.x() & 1)); 1246 DCHECK(!(paste_location.x() & 1));
1246 DCHECK(!(paste_location.y() & 1)); 1247 DCHECK(!(paste_location.y() & 1));
1247 1248
1248 GLuint mailbox_texture = 1249 GLuint mailbox_texture =
1249 copy_impl_->ConsumeMailboxToTexture(mailbox, sync_point); 1250 copy_impl_->ConsumeMailboxToTexture(mailbox, sync_token);
1250 1251
1251 GLuint texture; 1252 GLuint texture;
1252 if (quality_ == GLHelper::SCALER_QUALITY_FAST) { 1253 if (quality_ == GLHelper::SCALER_QUALITY_FAST) {
1253 // Optimization: SCALER_QUALITY_FAST is just a single bilinear 1254 // Optimization: SCALER_QUALITY_FAST is just a single bilinear
1254 // pass, which pass1_shader_ can do just as well, so let's skip 1255 // pass, which pass1_shader_ can do just as well, so let's skip
1255 // the actual scaling in that case. 1256 // the actual scaling in that case.
1256 texture = mailbox_texture; 1257 texture = mailbox_texture;
1257 } else { 1258 } else {
1258 // Scale texture to right size. 1259 // Scale texture to right size.
1259 scaler_.Scale(mailbox_texture); 1260 scaler_.Scale(mailbox_texture);
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1369 InitCopyTextToImpl(); 1370 InitCopyTextToImpl();
1370 return copy_texture_to_impl_->CreateReadbackPipelineYUV(quality, 1371 return copy_texture_to_impl_->CreateReadbackPipelineYUV(quality,
1371 src_size, 1372 src_size,
1372 src_subrect, 1373 src_subrect,
1373 dst_size, 1374 dst_size,
1374 flip_vertically, 1375 flip_vertically,
1375 use_mrt); 1376 use_mrt);
1376 } 1377 }
1377 1378
1378 } // namespace content 1379 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/client/gl_helper.h ('k') | content/common/gpu/client/gl_helper_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698