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 <queue> | 7 #include <queue> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
186 Request(const gfx::Size& size_, | 186 Request(const gfx::Size& size_, |
187 int32 bytes_per_row_, | 187 int32 bytes_per_row_, |
188 int32 row_stride_bytes_, | 188 int32 row_stride_bytes_, |
189 unsigned char* pixels_, | 189 unsigned char* pixels_, |
190 const base::Callback<void(bool)>& callback_) | 190 const base::Callback<void(bool)>& callback_) |
191 : size(size_), | 191 : size(size_), |
192 bytes_per_row(bytes_per_row_), | 192 bytes_per_row(bytes_per_row_), |
193 row_stride_bytes(row_stride_bytes_), | 193 row_stride_bytes(row_stride_bytes_), |
194 pixels(pixels_), | 194 pixels(pixels_), |
195 callback(callback_), | 195 callback(callback_), |
196 buffer(0) { | 196 buffer(0), |
197 query(0) { | |
197 } | 198 } |
198 | 199 |
199 gfx::Size size; | 200 gfx::Size size; |
200 int bytes_per_row; | 201 int bytes_per_row; |
201 int row_stride_bytes; | 202 int row_stride_bytes; |
202 unsigned char* pixels; | 203 unsigned char* pixels; |
203 base::Callback<void(bool)> callback; | 204 base::Callback<void(bool)> callback; |
204 GLuint buffer; | 205 GLuint buffer; |
206 WebKit::WebGLId query; | |
205 }; | 207 }; |
206 | 208 |
207 // A readback pipeline that also converts the data to YUV before | 209 // A readback pipeline that also converts the data to YUV before |
208 // reading it back. | 210 // reading it back. |
209 class ReadbackYUVImpl : public ReadbackYUVInterface { | 211 class ReadbackYUVImpl : public ReadbackYUVInterface { |
210 public: | 212 public: |
211 ReadbackYUVImpl(WebGraphicsContext3D* context, | 213 ReadbackYUVImpl(WebGraphicsContext3D* context, |
212 CopyTextureToImpl* copy_impl, | 214 CopyTextureToImpl* copy_impl, |
213 GLHelperScaling* scaler_impl, | 215 GLHelperScaling* scaler_impl, |
214 GLHelper::ScalerQuality quality, | 216 GLHelper::ScalerQuality quality, |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
375 request->buffer = context_->createBuffer(); | 377 request->buffer = context_->createBuffer(); |
376 context_->bindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, | 378 context_->bindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, |
377 request->buffer); | 379 request->buffer); |
378 context_->bufferData(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, | 380 context_->bufferData(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, |
379 4 * dst_size.GetArea(), | 381 4 * dst_size.GetArea(), |
380 NULL, | 382 NULL, |
381 GL_STREAM_READ); | 383 GL_STREAM_READ); |
382 | 384 |
383 context_->readPixels(0, 0, dst_size.width(), dst_size.height(), | 385 context_->readPixels(0, 0, dst_size.width(), dst_size.height(), |
384 GL_RGBA, GL_UNSIGNED_BYTE, NULL); | 386 GL_RGBA, GL_UNSIGNED_BYTE, NULL); |
387 request->query = context_->createQueryEXT(); | |
388 context_->beginQueryEXT(GL_ASYNC_PIXEL_TRANSFERS_COMPLETED_CHROMIUM, | |
389 request->query); | |
piman
2013/06/26 22:17:08
Don't you want to beginQuery before readPixels?
hubbe
2013/06/28 22:17:49
Done.
| |
385 context_->bindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, 0); | 390 context_->bindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, 0); |
386 cc::SyncPointHelper::SignalSyncPoint( | 391 context_->endQueryEXT(GL_ASYNC_PIXEL_TRANSFERS_COMPLETED_CHROMIUM); |
392 cc::SyncPointHelper::SignalQuery( | |
387 context_, | 393 context_, |
388 context_->insertSyncPoint(), | 394 request->query, |
389 base::Bind(&CopyTextureToImpl::ReadbackDone, AsWeakPtr(), request)); | 395 base::Bind(&CopyTextureToImpl::ReadbackDone, AsWeakPtr(), request)); |
390 } | 396 } |
391 | 397 |
392 | 398 |
393 void GLHelper::CopyTextureToImpl::CropScaleReadbackAndCleanTexture( | 399 void GLHelper::CopyTextureToImpl::CropScaleReadbackAndCleanTexture( |
394 WebGLId src_texture, | 400 WebGLId src_texture, |
395 const gfx::Size& src_size, | 401 const gfx::Size& src_size, |
396 const gfx::Rect& src_subrect, | 402 const gfx::Rect& src_subrect, |
397 const gfx::Size& dst_size, | 403 const gfx::Size& dst_size, |
398 unsigned char* out, | 404 unsigned char* out, |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
491 context_->unmapBufferCHROMIUM(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM); | 497 context_->unmapBufferCHROMIUM(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM); |
492 } | 498 } |
493 context_->bindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, 0); | 499 context_->bindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, 0); |
494 } | 500 } |
495 | 501 |
496 FinishRequest(request, result); | 502 FinishRequest(request, result); |
497 } | 503 } |
498 | 504 |
499 void GLHelper::CopyTextureToImpl::FinishRequest(Request* request, | 505 void GLHelper::CopyTextureToImpl::FinishRequest(Request* request, |
500 bool result) { | 506 bool result) { |
507 TRACE_EVENT0("mirror", "GLHelper::CopyTextureToImpl::FinishRequest"); | |
501 DCHECK(request_queue_.front() == request); | 508 DCHECK(request_queue_.front() == request); |
502 request_queue_.pop(); | 509 request_queue_.pop(); |
503 request->callback.Run(result); | 510 request->callback.Run(result); |
504 ScopedFlush flush(context_); | 511 ScopedFlush flush(context_); |
512 if (request->query != 0) { | |
513 context_->deleteQueryEXT(request->query); | |
514 request->query = 0; | |
515 } | |
505 if (request->buffer != 0) { | 516 if (request->buffer != 0) { |
506 context_->deleteBuffer(request->buffer); | 517 context_->deleteBuffer(request->buffer); |
507 request->buffer = 0; | 518 request->buffer = 0; |
508 } | 519 } |
509 delete request; | 520 delete request; |
510 } | 521 } |
511 | 522 |
512 void GLHelper::CopyTextureToImpl::CancelRequests() { | 523 void GLHelper::CopyTextureToImpl::CancelRequests() { |
513 while (!request_queue_.empty()) { | 524 while (!request_queue_.empty()) { |
514 Request* request = request_queue_.front(); | 525 Request* request = request_queue_.front(); |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
960 quality, | 971 quality, |
961 src_size, | 972 src_size, |
962 src_subrect, | 973 src_subrect, |
963 dst_size, | 974 dst_size, |
964 dst_subrect, | 975 dst_subrect, |
965 flip_vertically, | 976 flip_vertically, |
966 use_mrt); | 977 use_mrt); |
967 } | 978 } |
968 | 979 |
969 } // namespace content | 980 } // namespace content |
OLD | NEW |