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

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: Fix for aura build error 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 return 0;
345 }
339 scoped_ptr<ScalerInterface> scaler( 346 scoped_ptr<ScalerInterface> scaler(
340 helper_->CreateScaler(quality, 347 helper_->CreateScaler(quality,
341 src_size, 348 src_size,
342 src_subrect, 349 src_subrect,
343 dst_size, 350 dst_size,
344 vertically_flip_texture, 351 vertically_flip_texture,
345 swizzle)); 352 swizzle));
346
347 GLuint dst_texture = 0u; 353 GLuint dst_texture = 0u;
348 gl_->GenTextures(1, &dst_texture); 354 gl_->GenTextures(1, &dst_texture);
349 { 355 {
350 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, dst_texture); 356 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, dst_texture);
351 GLenum format = readback_config_rgb565 ? GL_RGB : GL_RGBA; 357 // Start with ARGB8888 params as any other format which is not
352 GLenum type = readback_config_rgb565 ? 358 // supported is already asserted above.
353 GL_UNSIGNED_SHORT_5_6_5 : 359 GLenum format = GL_RGBA , type = GL_UNSIGNED_BYTE;
354 GL_UNSIGNED_BYTE; 360 switch (config) {
361 case SkBitmap::kARGB_8888_Config:
362 // Do nothing params already set.
363 break;
364 case SkBitmap::kRGB_565_Config:
365 format = GL_RGB;
366 type = GL_UNSIGNED_SHORT_5_6_5;
367 break;
368 default:
369 NOTREACHED();
370 break;
371 }
355 gl_->TexImage2D(GL_TEXTURE_2D, 372 gl_->TexImage2D(GL_TEXTURE_2D,
356 0, 373 0,
357 format, 374 format,
358 dst_size.width(), 375 dst_size.width(),
359 dst_size.height(), 376 dst_size.height(),
360 0, 377 0,
361 format, 378 format,
362 type, 379 type,
363 NULL); 380 NULL);
364 } 381 }
365 scaler->Scale(src_texture, dst_texture); 382 scaler->Scale(src_texture, dst_texture);
366 return dst_texture; 383 return dst_texture;
367 } 384 }
368 385
369 void GLHelper::CopyTextureToImpl::ReadbackAsync( 386 void GLHelper::CopyTextureToImpl::ReadbackAsync(
370 const gfx::Size& dst_size, 387 const gfx::Size& dst_size,
371 int32 bytes_per_row, 388 int32 bytes_per_row,
372 int32 row_stride_bytes, 389 int32 row_stride_bytes,
373 unsigned char* out, 390 unsigned char* out,
374 bool readback_config_rgb565, 391 const SkBitmap::Config config,
375 const base::Callback<void(bool)>& callback) { 392 const base::Callback<void(bool)>& callback) {
393 bool format_support = ((config == SkBitmap::kRGB_565_Config) ||
394 (config == SkBitmap::kARGB_8888_Config));
395 if (!format_support) {
396 DCHECK(format_support);
397 callback.Run(false);
398 return;
399 }
376 Request* request = 400 Request* request =
377 new Request(dst_size, bytes_per_row, row_stride_bytes, out, callback); 401 new Request(dst_size, bytes_per_row, row_stride_bytes, out, callback);
378 request_queue_.push(request); 402 request_queue_.push(request);
379 request->buffer = 0u; 403 request->buffer = 0u;
380 int bytes_per_pixel = readback_config_rgb565 ? 2 : 4; 404 // Start with ARGB8888 params as any other format which is not
405 // supported is already asserted above.
406 GLenum format = GL_RGBA, type = GL_UNSIGNED_BYTE;
407 int bytes_per_pixel = 4;
408
409 switch (config) {
410 case SkBitmap::kARGB_8888_Config:
411 // Do nothing params already set.
412 break;
413 case SkBitmap::kRGB_565_Config:
414 format = GL_RGB;
415 type = GL_UNSIGNED_SHORT_5_6_5;
416 bytes_per_pixel = 2;
417 break;
418 default:
419 NOTREACHED();
420 break;
421 }
381 gl_->GenBuffers(1, &request->buffer); 422 gl_->GenBuffers(1, &request->buffer);
382 gl_->BindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, request->buffer); 423 gl_->BindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, request->buffer);
383 gl_->BufferData(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, 424 gl_->BufferData(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM,
384 bytes_per_pixel * dst_size.GetArea(), 425 bytes_per_pixel * dst_size.GetArea(),
385 NULL, 426 NULL,
386 GL_STREAM_READ); 427 GL_STREAM_READ);
387 428
388 request->query = 0u; 429 request->query = 0u;
389 gl_->GenQueriesEXT(1, &request->query); 430 gl_->GenQueriesEXT(1, &request->query);
390 gl_->BeginQueryEXT(GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM, request->query); 431 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, 432 gl_->ReadPixels(0,
396 0, 433 0,
397 dst_size.width(), 434 dst_size.width(),
398 dst_size.height(), 435 dst_size.height(),
399 format, 436 format,
400 type, 437 type,
401 NULL); 438 NULL);
402 gl_->EndQueryEXT(GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM); 439 gl_->EndQueryEXT(GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM);
403 gl_->BindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, 0); 440 gl_->BindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, 0);
404 context_support_->SignalQuery( 441 context_support_->SignalQuery(
405 request->query, 442 request->query,
406 base::Bind(&CopyTextureToImpl::ReadbackDone, AsWeakPtr(), 443 base::Bind(&CopyTextureToImpl::ReadbackDone, AsWeakPtr(),
407 request, bytes_per_pixel)); 444 request, bytes_per_pixel));
408 } 445 }
409 void GLHelper::CopyTextureToImpl::CropScaleReadbackAndCleanTexture( 446 void GLHelper::CopyTextureToImpl::CropScaleReadbackAndCleanTexture(
410 GLuint src_texture, 447 GLuint src_texture,
411 const gfx::Size& src_size, 448 const gfx::Size& src_size,
412 const gfx::Rect& src_subrect, 449 const gfx::Rect& src_subrect,
413 const gfx::Size& dst_size, 450 const gfx::Size& dst_size,
414 unsigned char* out, 451 unsigned char* out,
415 bool readback_config_rgb565, 452 const SkBitmap::Config bitmap_config,
416 const base::Callback<void(bool)>& callback, 453 const base::Callback<void(bool)>& callback,
417 GLHelper::ScalerQuality quality) { 454 GLHelper::ScalerQuality quality) {
455 bool format_support = ((bitmap_config == SkBitmap::kRGB_565_Config) ||
456 (bitmap_config == SkBitmap::kARGB_8888_Config));
457 if (!format_support) {
458 DCHECK(format_support);
459 callback.Run(false);
460 return;
461 }
418 GLuint texture = ScaleTexture(src_texture, 462 GLuint texture = ScaleTexture(src_texture,
419 src_size, 463 src_size,
420 src_subrect, 464 src_subrect,
421 dst_size, 465 dst_size,
422 true, 466 true,
423 #if (SK_R32_SHIFT == 16) && !SK_B32_SHIFT 467 #if (SK_R32_SHIFT == 16) && !SK_B32_SHIFT
424 true, 468 true,
425 #else 469 #else
426 false, 470 false,
427 #endif 471 #endif
428 readback_config_rgb565, 472 bitmap_config,
429 quality); 473 quality);
474 if(texture == 0) {
475 DCHECK(texture);
piman 2014/01/23 18:41:15 What I meant is, you don't need to do the if (text
sivag 2014/01/24 10:19:34 Done.
476 callback.Run(false);
477 return;
478 }
430 ScopedFramebuffer dst_framebuffer(gl_); 479 ScopedFramebuffer dst_framebuffer(gl_);
431 ScopedFramebufferBinder<GL_FRAMEBUFFER> framebuffer_binder(gl_, 480 ScopedFramebufferBinder<GL_FRAMEBUFFER> framebuffer_binder(gl_,
432 dst_framebuffer); 481 dst_framebuffer);
433 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, texture); 482 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, texture);
434 gl_->FramebufferTexture2D(GL_FRAMEBUFFER, 483 gl_->FramebufferTexture2D(GL_FRAMEBUFFER,
435 GL_COLOR_ATTACHMENT0, 484 GL_COLOR_ATTACHMENT0,
436 GL_TEXTURE_2D, 485 GL_TEXTURE_2D,
437 texture, 486 texture,
438 0); 487 0);
439 int bytes_per_pixel = readback_config_rgb565 ? 2 : 4; 488 int bytes_per_pixel = 4;
489 switch (bitmap_config) {
490 case SkBitmap::kARGB_8888_Config:
491 // Do nothing params already set.
492 break;
493 case SkBitmap::kRGB_565_Config:
494 bytes_per_pixel = 2;
495 break;
496 default:
497 NOTREACHED();
498 break;
499 }
440 ReadbackAsync(dst_size, 500 ReadbackAsync(dst_size,
441 dst_size.width() * bytes_per_pixel, 501 dst_size.width() * bytes_per_pixel,
442 dst_size.width() * bytes_per_pixel, 502 dst_size.width() * bytes_per_pixel,
443 out, 503 out,
444 readback_config_rgb565, 504 bitmap_config,
445 callback); 505 callback);
446 gl_->DeleteTextures(1, &texture); 506 gl_->DeleteTextures(1, &texture);
447 } 507 }
448 508
449 void GLHelper::CopyTextureToImpl::ReadbackTextureSync(GLuint texture, 509 void GLHelper::CopyTextureToImpl::ReadbackTextureSync(GLuint texture,
450 const gfx::Rect& src_rect, 510 const gfx::Rect& src_rect,
451 unsigned char* out, 511 unsigned char* out,
452 SkBitmap::Config config) { 512 SkBitmap::Config config) {
513 DCHECK((config == SkBitmap::kRGB_565_Config) ||
514 (config == SkBitmap::kARGB_8888_Config));
453 ScopedFramebuffer dst_framebuffer(gl_); 515 ScopedFramebuffer dst_framebuffer(gl_);
454 ScopedFramebufferBinder<GL_FRAMEBUFFER> framebuffer_binder(gl_, 516 ScopedFramebufferBinder<GL_FRAMEBUFFER> framebuffer_binder(gl_,
455 dst_framebuffer); 517 dst_framebuffer);
456 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, texture); 518 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, texture);
457 gl_->FramebufferTexture2D( 519 gl_->FramebufferTexture2D(
458 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0); 520 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) ? 521 GLenum format = (config == SkBitmap::kRGB_565_Config) ?
462 GL_RGB : 522 GL_RGB :
463 GL_RGBA; 523 GL_RGBA;
464 GLenum type = (config == SkBitmap::kRGB_565_Config) ? 524 GLenum type = (config == SkBitmap::kRGB_565_Config) ?
465 GL_UNSIGNED_SHORT_5_6_5 : 525 GL_UNSIGNED_SHORT_5_6_5 :
466 GL_UNSIGNED_BYTE; 526 GL_UNSIGNED_BYTE;
467 gl_->ReadPixels(src_rect.x(), 527 gl_->ReadPixels(src_rect.x(),
468 src_rect.y(), 528 src_rect.y(),
469 src_rect.width(), 529 src_rect.width(),
470 src_rect.height(), 530 src_rect.height(),
471 format, 531 format,
472 type, 532 type,
473 out); 533 out);
474 } 534 }
475 535
476 GLuint GLHelper::CopyTextureToImpl::CopyAndScaleTexture( 536 GLuint GLHelper::CopyTextureToImpl::CopyAndScaleTexture(
477 GLuint src_texture, 537 GLuint src_texture,
478 const gfx::Size& src_size, 538 const gfx::Size& src_size,
479 const gfx::Size& dst_size, 539 const gfx::Size& dst_size,
480 bool vertically_flip_texture, 540 bool vertically_flip_texture,
481 GLHelper::ScalerQuality quality) { 541 GLHelper::ScalerQuality quality) {
482 return ScaleTexture(src_texture, 542 return ScaleTexture(src_texture,
483 src_size, 543 src_size,
484 gfx::Rect(src_size), 544 gfx::Rect(src_size),
485 dst_size, 545 dst_size,
486 vertically_flip_texture, 546 vertically_flip_texture,
487 false, 547 false,
488 false, 548 SkBitmap::kARGB_8888_Config,
489 quality); 549 quality);
490 } 550 }
491 551
492 void GLHelper::CopyTextureToImpl::ReadbackDone(Request* finished_request, 552 void GLHelper::CopyTextureToImpl::ReadbackDone(Request* finished_request,
493 int bytes_per_pixel) { 553 int bytes_per_pixel) {
494 TRACE_EVENT0("mirror", 554 TRACE_EVENT0("mirror",
495 "GLHelper::CopyTextureToImpl::CheckReadbackFramebufferComplete"); 555 "GLHelper::CopyTextureToImpl::CheckReadbackFramebufferComplete");
496 finished_request->done = true; 556 finished_request->done = true;
497 557
498 // We process transfer requests in the order they were received, regardless 558 // 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) {} 621 support_565_format_(false) {}
562 622
563 GLHelper::~GLHelper() {} 623 GLHelper::~GLHelper() {}
564 624
565 void GLHelper::CropScaleReadbackAndCleanTexture( 625 void GLHelper::CropScaleReadbackAndCleanTexture(
566 GLuint src_texture, 626 GLuint src_texture,
567 const gfx::Size& src_size, 627 const gfx::Size& src_size,
568 const gfx::Rect& src_subrect, 628 const gfx::Rect& src_subrect,
569 const gfx::Size& dst_size, 629 const gfx::Size& dst_size,
570 unsigned char* out, 630 unsigned char* out,
571 bool readback_config_rgb565, 631 const SkBitmap::Config config,
572 const base::Callback<void(bool)>& callback) { 632 const base::Callback<void(bool)>& callback) {
573 InitCopyTextToImpl(); 633 InitCopyTextToImpl();
574 copy_texture_to_impl_->CropScaleReadbackAndCleanTexture( 634 copy_texture_to_impl_->CropScaleReadbackAndCleanTexture(
575 src_texture, 635 src_texture,
576 src_size, 636 src_size,
577 src_subrect, 637 src_subrect,
578 dst_size, 638 dst_size,
579 out, 639 out,
580 readback_config_rgb565, 640 config,
581 callback, 641 callback,
582 GLHelper::SCALER_QUALITY_FAST); 642 GLHelper::SCALER_QUALITY_FAST);
583 } 643 }
584 644
585 void GLHelper::CropScaleReadbackAndCleanMailbox( 645 void GLHelper::CropScaleReadbackAndCleanMailbox(
586 const gpu::Mailbox& src_mailbox, 646 const gpu::Mailbox& src_mailbox,
587 uint32 sync_point, 647 uint32 sync_point,
588 const gfx::Size& src_size, 648 const gfx::Size& src_size,
589 const gfx::Rect& src_subrect, 649 const gfx::Rect& src_subrect,
590 const gfx::Size& dst_size, 650 const gfx::Size& dst_size,
591 unsigned char* out, 651 unsigned char* out,
592 bool readback_config_rgb565, 652 const SkBitmap::Config bitmap_config,
593 const base::Callback<void(bool)>& callback) { 653 const base::Callback<void(bool)>& callback) {
594 GLuint mailbox_texture = ConsumeMailboxToTexture(src_mailbox, sync_point); 654 GLuint mailbox_texture = ConsumeMailboxToTexture(src_mailbox, sync_point);
595 CropScaleReadbackAndCleanTexture( 655 CropScaleReadbackAndCleanTexture(
596 mailbox_texture, src_size, src_subrect, dst_size, out, 656 mailbox_texture, src_size, src_subrect, dst_size, out,
597 readback_config_rgb565, 657 bitmap_config,
598 callback); 658 callback);
599 gl_->DeleteTextures(1, &mailbox_texture); 659 gl_->DeleteTextures(1, &mailbox_texture);
600 } 660 }
601 661
602 void GLHelper::ReadbackTextureSync(GLuint texture, 662 void GLHelper::ReadbackTextureSync(GLuint texture,
603 const gfx::Rect& src_rect, 663 const gfx::Rect& src_rect,
604 unsigned char* out, 664 unsigned char* out,
605 SkBitmap::Config format) { 665 SkBitmap::Config format) {
606 InitCopyTextToImpl(); 666 InitCopyTextToImpl();
607 copy_texture_to_impl_->ReadbackTextureSync(texture, src_rect, out, format); 667 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, 879 int size_shift,
820 const gfx::Rect& dst_subrect, 880 const gfx::Rect& dst_subrect,
821 const base::Callback<void(bool)>& callback) { 881 const base::Callback<void(bool)>& callback) {
822 gl_->BindFramebuffer(GL_FRAMEBUFFER, source->framebuffer()); 882 gl_->BindFramebuffer(GL_FRAMEBUFFER, source->framebuffer());
823 size_t offset = target->stride(plane) * (dst_subrect.y() >> size_shift) + 883 size_t offset = target->stride(plane) * (dst_subrect.y() >> size_shift) +
824 (dst_subrect.x() >> size_shift); 884 (dst_subrect.x() >> size_shift);
825 ReadbackAsync(source->size(), 885 ReadbackAsync(source->size(),
826 dst_subrect.width() >> size_shift, 886 dst_subrect.width() >> size_shift,
827 target->stride(plane), 887 target->stride(plane),
828 target->data(plane) + offset, 888 target->data(plane) + offset,
829 false, 889 SkBitmap::kARGB_8888_Config,
830 callback); 890 callback);
831 } 891 }
832 892
833 const float GLHelper::CopyTextureToImpl::kRGBtoYColorWeights[] = { 893 const float GLHelper::CopyTextureToImpl::kRGBtoYColorWeights[] = {
834 0.257f, 0.504f, 0.098f, 0.0625f}; 894 0.257f, 0.504f, 0.098f, 0.0625f};
835 const float GLHelper::CopyTextureToImpl::kRGBtoUColorWeights[] = { 895 const float GLHelper::CopyTextureToImpl::kRGBtoUColorWeights[] = {
836 -0.148f, -0.291f, 0.439f, 0.5f}; 896 -0.148f, -0.291f, 0.439f, 0.5f};
837 const float GLHelper::CopyTextureToImpl::kRGBtoVColorWeights[] = { 897 const float GLHelper::CopyTextureToImpl::kRGBtoVColorWeights[] = {
838 0.439f, -0.368f, -0.071f, 0.5f}; 898 0.439f, -0.368f, -0.071f, 0.5f};
839 899
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
1130 return copy_texture_to_impl_->CreateReadbackPipelineYUV(quality, 1190 return copy_texture_to_impl_->CreateReadbackPipelineYUV(quality,
1131 src_size, 1191 src_size,
1132 src_subrect, 1192 src_subrect,
1133 dst_size, 1193 dst_size,
1134 dst_subrect, 1194 dst_subrect,
1135 flip_vertically, 1195 flip_vertically,
1136 use_mrt); 1196 use_mrt);
1137 } 1197 }
1138 1198
1139 } // namespace content 1199 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/client/gl_helper.h ('k') | content/port/browser/render_widget_host_view_port.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698