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

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

Issue 143683003: Support format using enum argument for Async readback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code changed as per review comments. Created 6 years, 11 months 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
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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 uint32 sync_point) { 120 uint32 sync_point) {
121 return helper_->ConsumeMailboxToTexture(mailbox, sync_point); 121 return helper_->ConsumeMailboxToTexture(mailbox, sync_point);
122 } 122 }
123 123
124 void CropScaleReadbackAndCleanTexture( 124 void CropScaleReadbackAndCleanTexture(
125 GLuint src_texture, 125 GLuint src_texture,
126 const gfx::Size& src_size, 126 const gfx::Size& src_size,
127 const gfx::Rect& src_subrect, 127 const gfx::Rect& src_subrect,
128 const gfx::Size& dst_size, 128 const gfx::Size& dst_size,
129 unsigned char* out, 129 unsigned char* out,
130 bool readback_config_rgb565, 130 const SkBitmap::Config config,
131 const base::Callback<void(bool)>& callback, 131 const base::Callback<void(bool)>& callback,
132 GLHelper::ScalerQuality quality); 132 GLHelper::ScalerQuality quality);
133 133
134 void ReadbackTextureSync(GLuint texture, 134 void ReadbackTextureSync(GLuint texture,
135 const gfx::Rect& src_rect, 135 const gfx::Rect& src_rect,
136 unsigned char* out, 136 unsigned char* out,
137 SkBitmap::Config format); 137 SkBitmap::Config format);
138 138
139 // Reads back bytes from the currently bound frame buffer. 139 // Reads back bytes from the currently bound frame buffer.
140 // Note that dst_size is specified in bytes, not pixels. 140 // Note that dst_size is specified in bytes, not pixels.
141 void ReadbackAsync(const gfx::Size& dst_size, 141 void ReadbackAsync(const gfx::Size& dst_size,
142 int32 bytes_per_row, // generally dst_size.width() * 4 142 int32 bytes_per_row, // generally dst_size.width() * 4
143 int32 row_stride_bytes, // generally dst_size.width() * 4 143 int32 row_stride_bytes, // generally dst_size.width() * 4
144 unsigned char* out, 144 unsigned char* out,
145 bool readback_config_rgb565, 145 const SkBitmap::Config config,
146 const base::Callback<void(bool)>& callback); 146 const base::Callback<void(bool)>& callback);
147 147
148 void ReadbackPlane(TextureFrameBufferPair* source, 148 void ReadbackPlane(TextureFrameBufferPair* source,
149 const scoped_refptr<media::VideoFrame>& target, 149 const scoped_refptr<media::VideoFrame>& target,
150 int plane, 150 int plane,
151 int size_shift, 151 int size_shift,
152 const gfx::Rect& dst_subrect, 152 const gfx::Rect& dst_subrect,
153 const base::Callback<void(bool)>& callback); 153 const base::Callback<void(bool)>& callback);
154 154
155 GLuint CopyAndScaleTexture(GLuint texture, 155 GLuint CopyAndScaleTexture(GLuint texture,
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 281
282 // Copies the block of pixels specified with |src_subrect| from |src_texture|, 282 // Copies the block of pixels specified with |src_subrect| from |src_texture|,
283 // scales it to |dst_size|, writes it into a texture, and returns its ID. 283 // scales it to |dst_size|, writes it into a texture, and returns its ID.
284 // |src_size| is the size of |src_texture|. 284 // |src_size| is the size of |src_texture|.
285 GLuint ScaleTexture(GLuint src_texture, 285 GLuint ScaleTexture(GLuint src_texture,
286 const gfx::Size& src_size, 286 const gfx::Size& src_size,
287 const gfx::Rect& src_subrect, 287 const gfx::Rect& src_subrect,
288 const gfx::Size& dst_size, 288 const gfx::Size& dst_size,
289 bool vertically_flip_texture, 289 bool vertically_flip_texture,
290 bool swizzle, 290 bool swizzle,
291 bool readback_config_rgb565, 291 SkBitmap::Config config,
292 GLHelper::ScalerQuality quality); 292 GLHelper::ScalerQuality quality);
293 293
294 static void nullcallback(bool success) {} 294 static void nullcallback(bool success) {}
295 void ReadbackDone(Request *request, int bytes_per_pixel); 295 void ReadbackDone(Request *request, int bytes_per_pixel);
296 void FinishRequest(Request* request, bool result); 296 void FinishRequest(Request* request, bool result);
297 void CancelRequests(); 297 void CancelRequests();
298 298
299 static const float kRGBtoYColorWeights[]; 299 static const float kRGBtoYColorWeights[];
300 static const float kRGBtoUColorWeights[]; 300 static const float kRGBtoUColorWeights[];
301 static const float kRGBtoVColorWeights[]; 301 static const float kRGBtoVColorWeights[];
(...skipping 25 matching lines...) Expand all
327 swizzle); 327 swizzle);
328 } 328 }
329 329
330 GLuint GLHelper::CopyTextureToImpl::ScaleTexture( 330 GLuint GLHelper::CopyTextureToImpl::ScaleTexture(
331 GLuint src_texture, 331 GLuint src_texture,
332 const gfx::Size& src_size, 332 const gfx::Size& src_size,
333 const gfx::Rect& src_subrect, 333 const gfx::Rect& src_subrect,
334 const gfx::Size& dst_size, 334 const gfx::Size& dst_size,
335 bool vertically_flip_texture, 335 bool vertically_flip_texture,
336 bool swizzle, 336 bool swizzle,
337 bool readback_config_rgb565, 337 SkBitmap::Config config,
338 GLHelper::ScalerQuality quality) { 338 GLHelper::ScalerQuality quality) {
339
340 bool format_support = ((config == SkBitmap::kRGB_565_Config) ||
341 (config == SkBitmap::kARGB_8888_Config));
342 if (!format_support) {
343 DCHECK(format_support);
344 LOG(ERROR) << "Format not supported.";
piman 2014/01/22 22:10:21 no need for this LOG. DCHECK is enough.
sivag 2014/01/23 12:29:20 Done.
345 return GL_INVALID_ENUM;
piman 2014/01/22 22:10:21 Maybe return 0 rather than GL_INVALID_ENUM. GL_INV
sivag 2014/01/23 12:29:20 Done.
346 }
339 scoped_ptr<ScalerInterface> scaler( 347 scoped_ptr<ScalerInterface> scaler(
340 helper_->CreateScaler(quality, 348 helper_->CreateScaler(quality,
341 src_size, 349 src_size,
342 src_subrect, 350 src_subrect,
343 dst_size, 351 dst_size,
344 vertically_flip_texture, 352 vertically_flip_texture,
345 swizzle)); 353 swizzle));
346
347 GLuint dst_texture = 0u; 354 GLuint dst_texture = 0u;
348 gl_->GenTextures(1, &dst_texture); 355 gl_->GenTextures(1, &dst_texture);
349 { 356 {
350 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, dst_texture); 357 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, dst_texture);
351 GLenum format = readback_config_rgb565 ? GL_RGB : GL_RGBA; 358 // Start with ARGB8888 params as any other format which is not
352 GLenum type = readback_config_rgb565 ? 359 // supported is already asserted above.
353 GL_UNSIGNED_SHORT_5_6_5 : 360 GLenum format = GL_RGBA , type = GL_UNSIGNED_BYTE;
354 GL_UNSIGNED_BYTE; 361 switch (config) {
362 case SkBitmap::kARGB_8888_Config:
363 // Do nothing params already set.
364 break;
365 case SkBitmap::kRGB_565_Config:
366 format = GL_RGB;
367 type = GL_UNSIGNED_SHORT_5_6_5;
368 break;
369 default:
370 NOTIMPLEMENTED();
piman 2014/01/22 22:10:21 nit: NOTREACHED() since it's tested above.
sivag 2014/01/23 12:29:20 Done.
371 break;
372 }
355 gl_->TexImage2D(GL_TEXTURE_2D, 373 gl_->TexImage2D(GL_TEXTURE_2D,
356 0, 374 0,
357 format, 375 format,
358 dst_size.width(), 376 dst_size.width(),
359 dst_size.height(), 377 dst_size.height(),
360 0, 378 0,
361 format, 379 format,
362 type, 380 type,
363 NULL); 381 NULL);
364 } 382 }
365 scaler->Scale(src_texture, dst_texture); 383 scaler->Scale(src_texture, dst_texture);
366 return dst_texture; 384 return dst_texture;
367 } 385 }
368 386
369 void GLHelper::CopyTextureToImpl::ReadbackAsync( 387 void GLHelper::CopyTextureToImpl::ReadbackAsync(
370 const gfx::Size& dst_size, 388 const gfx::Size& dst_size,
371 int32 bytes_per_row, 389 int32 bytes_per_row,
372 int32 row_stride_bytes, 390 int32 row_stride_bytes,
373 unsigned char* out, 391 unsigned char* out,
374 bool readback_config_rgb565, 392 const SkBitmap::Config config,
375 const base::Callback<void(bool)>& callback) { 393 const base::Callback<void(bool)>& callback) {
394 bool format_support = ((config == SkBitmap::kRGB_565_Config) ||
395 (config == SkBitmap::kARGB_8888_Config));
396 if (!format_support) {
397 DCHECK(format_support);
398 LOG(ERROR) << "Format not supported.";
piman 2014/01/22 22:10:21 no need for the LOG.
sivag 2014/01/23 12:29:20 Done.
399 callback.Run(false);
400 return;
401 }
376 Request* request = 402 Request* request =
377 new Request(dst_size, bytes_per_row, row_stride_bytes, out, callback); 403 new Request(dst_size, bytes_per_row, row_stride_bytes, out, callback);
378 request_queue_.push(request); 404 request_queue_.push(request);
379 request->buffer = 0u; 405 request->buffer = 0u;
380 int bytes_per_pixel = readback_config_rgb565 ? 2 : 4; 406 // Start with ARGB8888 params as any other format which is not
407 // supported is already asserted above.
408 GLenum format = GL_RGBA , type = GL_UNSIGNED_BYTE;
piman 2014/01/22 22:10:21 nit: no space before ,
sivag 2014/01/23 12:29:20 Done.
sivag 2014/01/23 12:29:20 Done.
409 int bytes_per_pixel = 4;
410
411 switch (config) {
412 case SkBitmap::kARGB_8888_Config:
413 // Do nothing params already set.
414 break;
415 case SkBitmap::kRGB_565_Config:
416 format = GL_RGB;
417 type = GL_UNSIGNED_SHORT_5_6_5;
418 bytes_per_pixel = 2;
419 break;
420 default:
421 NOTIMPLEMENTED();
piman 2014/01/22 22:10:21 nit: NOTREACHED()
sivag 2014/01/23 12:29:20 Done.
422 break;
423 }
381 gl_->GenBuffers(1, &request->buffer); 424 gl_->GenBuffers(1, &request->buffer);
382 gl_->BindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, request->buffer); 425 gl_->BindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, request->buffer);
383 gl_->BufferData(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, 426 gl_->BufferData(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM,
384 bytes_per_pixel * dst_size.GetArea(), 427 bytes_per_pixel * dst_size.GetArea(),
385 NULL, 428 NULL,
386 GL_STREAM_READ); 429 GL_STREAM_READ);
387 430
388 request->query = 0u; 431 request->query = 0u;
389 gl_->GenQueriesEXT(1, &request->query); 432 gl_->GenQueriesEXT(1, &request->query);
390 gl_->BeginQueryEXT(GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM, request->query); 433 gl_->BeginQueryEXT(GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM, request->query);
391 GLenum format = readback_config_rgb565 ? GL_RGB : GL_RGBA;
392 GLenum type = readback_config_rgb565 ?
393 GL_UNSIGNED_SHORT_5_6_5 :
394 GL_UNSIGNED_BYTE;
395 gl_->ReadPixels(0, 434 gl_->ReadPixels(0,
396 0, 435 0,
397 dst_size.width(), 436 dst_size.width(),
398 dst_size.height(), 437 dst_size.height(),
399 format, 438 format,
400 type, 439 type,
401 NULL); 440 NULL);
402 gl_->EndQueryEXT(GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM); 441 gl_->EndQueryEXT(GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM);
403 gl_->BindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, 0); 442 gl_->BindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, 0);
404 context_support_->SignalQuery( 443 context_support_->SignalQuery(
405 request->query, 444 request->query,
406 base::Bind(&CopyTextureToImpl::ReadbackDone, AsWeakPtr(), 445 base::Bind(&CopyTextureToImpl::ReadbackDone, AsWeakPtr(),
407 request, bytes_per_pixel)); 446 request, bytes_per_pixel));
408 } 447 }
409 void GLHelper::CopyTextureToImpl::CropScaleReadbackAndCleanTexture( 448 void GLHelper::CopyTextureToImpl::CropScaleReadbackAndCleanTexture(
410 GLuint src_texture, 449 GLuint src_texture,
411 const gfx::Size& src_size, 450 const gfx::Size& src_size,
412 const gfx::Rect& src_subrect, 451 const gfx::Rect& src_subrect,
413 const gfx::Size& dst_size, 452 const gfx::Size& dst_size,
414 unsigned char* out, 453 unsigned char* out,
415 bool readback_config_rgb565, 454 const SkBitmap::Config bitmap_config,
416 const base::Callback<void(bool)>& callback, 455 const base::Callback<void(bool)>& callback,
417 GLHelper::ScalerQuality quality) { 456 GLHelper::ScalerQuality quality) {
457 bool format_support = ((bitmap_config == SkBitmap::kRGB_565_Config) ||
458 (bitmap_config == SkBitmap::kARGB_8888_Config));
459 if (!format_support) {
460 DCHECK(format_support);
461 LOG(ERROR) << "Format not supported.";
piman 2014/01/22 22:10:21 nit: remove.
sivag 2014/01/23 12:29:20 Done.
462 callback.Run(false);
463 return;
464 }
418 GLuint texture = ScaleTexture(src_texture, 465 GLuint texture = ScaleTexture(src_texture,
419 src_size, 466 src_size,
420 src_subrect, 467 src_subrect,
421 dst_size, 468 dst_size,
422 true, 469 true,
423 #if (SK_R32_SHIFT == 16) && !SK_B32_SHIFT 470 #if (SK_R32_SHIFT == 16) && !SK_B32_SHIFT
424 true, 471 true,
425 #else 472 #else
426 false, 473 false,
427 #endif 474 #endif
428 readback_config_rgb565, 475 bitmap_config,
429 quality); 476 quality);
477 if(texture == GL_INVALID_ENUM) {
piman 2014/01/22 22:10:21 nit: you can just DCHECK(texture), since you teste
sivag 2014/01/23 12:29:20 Done.
478 callback.Run(false);
479 return;
480 }
430 ScopedFramebuffer dst_framebuffer(gl_); 481 ScopedFramebuffer dst_framebuffer(gl_);
431 ScopedFramebufferBinder<GL_FRAMEBUFFER> framebuffer_binder(gl_, 482 ScopedFramebufferBinder<GL_FRAMEBUFFER> framebuffer_binder(gl_,
432 dst_framebuffer); 483 dst_framebuffer);
433 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, texture); 484 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, texture);
434 gl_->FramebufferTexture2D(GL_FRAMEBUFFER, 485 gl_->FramebufferTexture2D(GL_FRAMEBUFFER,
435 GL_COLOR_ATTACHMENT0, 486 GL_COLOR_ATTACHMENT0,
436 GL_TEXTURE_2D, 487 GL_TEXTURE_2D,
437 texture, 488 texture,
438 0); 489 0);
439 int bytes_per_pixel = readback_config_rgb565 ? 2 : 4; 490 int bytes_per_pixel = 4;
491 switch (bitmap_config) {
492 case SkBitmap::kARGB_8888_Config:
493 // Do nothing params already set.
494 break;
495 case SkBitmap::kRGB_565_Config:
496 bytes_per_pixel = 2;
497 break;
498 default:
499 NOTIMPLEMENTED();
piman 2014/01/22 22:10:21 NOTREACHED()
sivag 2014/01/23 12:29:20 Done.
500 break;
501 }
440 ReadbackAsync(dst_size, 502 ReadbackAsync(dst_size,
441 dst_size.width() * bytes_per_pixel, 503 dst_size.width() * bytes_per_pixel,
442 dst_size.width() * bytes_per_pixel, 504 dst_size.width() * bytes_per_pixel,
443 out, 505 out,
444 readback_config_rgb565, 506 bitmap_config,
445 callback); 507 callback);
446 gl_->DeleteTextures(1, &texture); 508 gl_->DeleteTextures(1, &texture);
447 } 509 }
448 510
449 void GLHelper::CopyTextureToImpl::ReadbackTextureSync(GLuint texture, 511 void GLHelper::CopyTextureToImpl::ReadbackTextureSync(GLuint texture,
450 const gfx::Rect& src_rect, 512 const gfx::Rect& src_rect,
451 unsigned char* out, 513 unsigned char* out,
452 SkBitmap::Config config) { 514 SkBitmap::Config config) {
515 DCHECK((config == SkBitmap::kRGB_565_Config) ||
516 (config == SkBitmap::kARGB_8888_Config));
453 ScopedFramebuffer dst_framebuffer(gl_); 517 ScopedFramebuffer dst_framebuffer(gl_);
454 ScopedFramebufferBinder<GL_FRAMEBUFFER> framebuffer_binder(gl_, 518 ScopedFramebufferBinder<GL_FRAMEBUFFER> framebuffer_binder(gl_,
455 dst_framebuffer); 519 dst_framebuffer);
456 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, texture); 520 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, texture);
457 gl_->FramebufferTexture2D( 521 gl_->FramebufferTexture2D(
458 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0); 522 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
459 DCHECK((config == SkBitmap::kRGB_565_Config) ||
460 (config == SkBitmap::kARGB_8888_Config));
461 GLenum format = (config == SkBitmap::kRGB_565_Config) ? 523 GLenum format = (config == SkBitmap::kRGB_565_Config) ?
462 GL_RGB : 524 GL_RGB :
463 GL_RGBA; 525 GL_RGBA;
464 GLenum type = (config == SkBitmap::kRGB_565_Config) ? 526 GLenum type = (config == SkBitmap::kRGB_565_Config) ?
465 GL_UNSIGNED_SHORT_5_6_5 : 527 GL_UNSIGNED_SHORT_5_6_5 :
466 GL_UNSIGNED_BYTE; 528 GL_UNSIGNED_BYTE;
467 gl_->ReadPixels(src_rect.x(), 529 gl_->ReadPixels(src_rect.x(),
468 src_rect.y(), 530 src_rect.y(),
469 src_rect.width(), 531 src_rect.width(),
470 src_rect.height(), 532 src_rect.height(),
471 format, 533 format,
472 type, 534 type,
473 out); 535 out);
474 } 536 }
475 537
476 GLuint GLHelper::CopyTextureToImpl::CopyAndScaleTexture( 538 GLuint GLHelper::CopyTextureToImpl::CopyAndScaleTexture(
477 GLuint src_texture, 539 GLuint src_texture,
478 const gfx::Size& src_size, 540 const gfx::Size& src_size,
479 const gfx::Size& dst_size, 541 const gfx::Size& dst_size,
480 bool vertically_flip_texture, 542 bool vertically_flip_texture,
481 GLHelper::ScalerQuality quality) { 543 GLHelper::ScalerQuality quality) {
482 return ScaleTexture(src_texture, 544 return ScaleTexture(src_texture,
483 src_size, 545 src_size,
484 gfx::Rect(src_size), 546 gfx::Rect(src_size),
485 dst_size, 547 dst_size,
486 vertically_flip_texture, 548 vertically_flip_texture,
487 false, 549 false,
488 false, 550 SkBitmap::kARGB_8888_Config,
489 quality); 551 quality);
490 } 552 }
491 553
492 void GLHelper::CopyTextureToImpl::ReadbackDone(Request* finished_request, 554 void GLHelper::CopyTextureToImpl::ReadbackDone(Request* finished_request,
493 int bytes_per_pixel) { 555 int bytes_per_pixel) {
494 TRACE_EVENT0("mirror", 556 TRACE_EVENT0("mirror",
495 "GLHelper::CopyTextureToImpl::CheckReadbackFramebufferComplete"); 557 "GLHelper::CopyTextureToImpl::CheckReadbackFramebufferComplete");
496 finished_request->done = true; 558 finished_request->done = true;
497 559
498 // We process transfer requests in the order they were received, regardless 560 // We process transfer requests in the order they were received, regardless
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 support_565_format_(false) {} 623 support_565_format_(false) {}
562 624
563 GLHelper::~GLHelper() {} 625 GLHelper::~GLHelper() {}
564 626
565 void GLHelper::CropScaleReadbackAndCleanTexture( 627 void GLHelper::CropScaleReadbackAndCleanTexture(
566 GLuint src_texture, 628 GLuint src_texture,
567 const gfx::Size& src_size, 629 const gfx::Size& src_size,
568 const gfx::Rect& src_subrect, 630 const gfx::Rect& src_subrect,
569 const gfx::Size& dst_size, 631 const gfx::Size& dst_size,
570 unsigned char* out, 632 unsigned char* out,
571 bool readback_config_rgb565, 633 const SkBitmap::Config config,
572 const base::Callback<void(bool)>& callback) { 634 const base::Callback<void(bool)>& callback) {
573 InitCopyTextToImpl(); 635 InitCopyTextToImpl();
574 copy_texture_to_impl_->CropScaleReadbackAndCleanTexture( 636 copy_texture_to_impl_->CropScaleReadbackAndCleanTexture(
575 src_texture, 637 src_texture,
576 src_size, 638 src_size,
577 src_subrect, 639 src_subrect,
578 dst_size, 640 dst_size,
579 out, 641 out,
580 readback_config_rgb565, 642 config,
581 callback, 643 callback,
582 GLHelper::SCALER_QUALITY_FAST); 644 GLHelper::SCALER_QUALITY_FAST);
583 } 645 }
584 646
585 void GLHelper::CropScaleReadbackAndCleanMailbox( 647 void GLHelper::CropScaleReadbackAndCleanMailbox(
586 const gpu::Mailbox& src_mailbox, 648 const gpu::Mailbox& src_mailbox,
587 uint32 sync_point, 649 uint32 sync_point,
588 const gfx::Size& src_size, 650 const gfx::Size& src_size,
589 const gfx::Rect& src_subrect, 651 const gfx::Rect& src_subrect,
590 const gfx::Size& dst_size, 652 const gfx::Size& dst_size,
591 unsigned char* out, 653 unsigned char* out,
592 bool readback_config_rgb565, 654 const SkBitmap::Config bitmap_config,
593 const base::Callback<void(bool)>& callback) { 655 const base::Callback<void(bool)>& callback) {
594 GLuint mailbox_texture = ConsumeMailboxToTexture(src_mailbox, sync_point); 656 GLuint mailbox_texture = ConsumeMailboxToTexture(src_mailbox, sync_point);
595 CropScaleReadbackAndCleanTexture( 657 CropScaleReadbackAndCleanTexture(
596 mailbox_texture, src_size, src_subrect, dst_size, out, 658 mailbox_texture, src_size, src_subrect, dst_size, out,
597 readback_config_rgb565, 659 bitmap_config,
598 callback); 660 callback);
599 gl_->DeleteTextures(1, &mailbox_texture); 661 gl_->DeleteTextures(1, &mailbox_texture);
600 } 662 }
601 663
602 void GLHelper::ReadbackTextureSync(GLuint texture, 664 void GLHelper::ReadbackTextureSync(GLuint texture,
603 const gfx::Rect& src_rect, 665 const gfx::Rect& src_rect,
604 unsigned char* out, 666 unsigned char* out,
605 SkBitmap::Config format) { 667 SkBitmap::Config format) {
606 InitCopyTextToImpl(); 668 InitCopyTextToImpl();
607 copy_texture_to_impl_->ReadbackTextureSync(texture, src_rect, out, format); 669 copy_texture_to_impl_->ReadbackTextureSync(texture, src_rect, out, format);
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 int size_shift, 881 int size_shift,
820 const gfx::Rect& dst_subrect, 882 const gfx::Rect& dst_subrect,
821 const base::Callback<void(bool)>& callback) { 883 const base::Callback<void(bool)>& callback) {
822 gl_->BindFramebuffer(GL_FRAMEBUFFER, source->framebuffer()); 884 gl_->BindFramebuffer(GL_FRAMEBUFFER, source->framebuffer());
823 size_t offset = target->stride(plane) * (dst_subrect.y() >> size_shift) + 885 size_t offset = target->stride(plane) * (dst_subrect.y() >> size_shift) +
824 (dst_subrect.x() >> size_shift); 886 (dst_subrect.x() >> size_shift);
825 ReadbackAsync(source->size(), 887 ReadbackAsync(source->size(),
826 dst_subrect.width() >> size_shift, 888 dst_subrect.width() >> size_shift,
827 target->stride(plane), 889 target->stride(plane),
828 target->data(plane) + offset, 890 target->data(plane) + offset,
829 false, 891 SkBitmap::kARGB_8888_Config,
830 callback); 892 callback);
831 } 893 }
832 894
833 const float GLHelper::CopyTextureToImpl::kRGBtoYColorWeights[] = { 895 const float GLHelper::CopyTextureToImpl::kRGBtoYColorWeights[] = {
834 0.257f, 0.504f, 0.098f, 0.0625f}; 896 0.257f, 0.504f, 0.098f, 0.0625f};
835 const float GLHelper::CopyTextureToImpl::kRGBtoUColorWeights[] = { 897 const float GLHelper::CopyTextureToImpl::kRGBtoUColorWeights[] = {
836 -0.148f, -0.291f, 0.439f, 0.5f}; 898 -0.148f, -0.291f, 0.439f, 0.5f};
837 const float GLHelper::CopyTextureToImpl::kRGBtoVColorWeights[] = { 899 const float GLHelper::CopyTextureToImpl::kRGBtoVColorWeights[] = {
838 0.439f, -0.368f, -0.071f, 0.5f}; 900 0.439f, -0.368f, -0.071f, 0.5f};
839 901
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
1130 return copy_texture_to_impl_->CreateReadbackPipelineYUV(quality, 1192 return copy_texture_to_impl_->CreateReadbackPipelineYUV(quality,
1131 src_size, 1193 src_size,
1132 src_subrect, 1194 src_subrect,
1133 dst_size, 1195 dst_size,
1134 dst_subrect, 1196 dst_subrect,
1135 flip_vertically, 1197 flip_vertically,
1136 use_mrt); 1198 use_mrt);
1137 } 1199 }
1138 1200
1139 } // namespace content 1201 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698