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

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

Issue 149123008: Implement GLHelperReadbackSupport for GLHelper usage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created a new class, Handled review comments. Created 6 years, 9 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"
11 #include "base/debug/trace_event.h" 11 #include "base/debug/trace_event.h"
12 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
16 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
17 #include "base/time/time.h" 17 #include "base/time/time.h"
18 #include "content/common/gpu/client/gl_helper_readback_support.h"
18 #include "content/common/gpu/client/gl_helper_scaling.h" 19 #include "content/common/gpu/client/gl_helper_scaling.h"
19 #include "gpu/GLES2/gl2extchromium.h" 20 #include "gpu/GLES2/gl2extchromium.h"
20 #include "gpu/command_buffer/client/context_support.h" 21 #include "gpu/command_buffer/client/context_support.h"
21 #include "gpu/command_buffer/common/mailbox.h" 22 #include "gpu/command_buffer/common/mailbox.h"
22 #include "gpu/command_buffer/common/mailbox_holder.h" 23 #include "gpu/command_buffer/common/mailbox_holder.h"
23 #include "media/base/video_frame.h" 24 #include "media/base/video_frame.h"
24 #include "media/base/video_util.h" 25 #include "media/base/video_util.h"
25 #include "third_party/skia/include/core/SkRegion.h" 26 #include "third_party/skia/include/core/SkRegion.h"
26 #include "ui/gfx/rect.h" 27 #include "ui/gfx/rect.h"
27 #include "ui/gfx/size.h" 28 #include "ui/gfx/size.h"
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 const gfx::Rect& src_subrect, 172 const gfx::Rect& src_subrect,
172 const gfx::Size& dst_size, 173 const gfx::Size& dst_size,
173 const gfx::Rect& dst_subrect, 174 const gfx::Rect& dst_subrect,
174 bool flip_vertically, 175 bool flip_vertically,
175 bool use_mrt); 176 bool use_mrt);
176 177
177 // Returns the maximum number of draw buffers available, 178 // Returns the maximum number of draw buffers available,
178 // 0 if GL_EXT_draw_buffers is not available. 179 // 0 if GL_EXT_draw_buffers is not available.
179 GLint MaxDrawBuffers() const { return max_draw_buffers_; } 180 GLint MaxDrawBuffers() const { return max_draw_buffers_; }
180 181
182 bool IsReadbackConfigSupported(SkBitmap::Config bitmap_config);
183
181 private: 184 private:
182 // A single request to CropScaleReadbackAndCleanTexture. 185 // A single request to CropScaleReadbackAndCleanTexture.
183 // The main thread can cancel the request, before it's handled by the helper 186 // The main thread can cancel the request, before it's handled by the helper
184 // thread, by resetting the texture and pixels fields. Alternatively, the 187 // thread, by resetting the texture and pixels fields. Alternatively, the
185 // thread marks that it handles the request by resetting the pixels field 188 // thread marks that it handles the request by resetting the pixels field
186 // (meaning it guarantees that the callback with be called). 189 // (meaning it guarantees that the callback with be called).
187 // In either case, the callback must be called exactly once, and the texture 190 // In either case, the callback must be called exactly once, and the texture
188 // must be deleted by the main thread gl. 191 // must be deleted by the main thread gl.
189 struct Request { 192 struct Request {
190 Request(const gfx::Size& size_, 193 Request(const gfx::Size& size_,
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 swizzle); 337 swizzle);
335 } 338 }
336 339
337 GLuint GLHelper::CopyTextureToImpl::ScaleTexture( 340 GLuint GLHelper::CopyTextureToImpl::ScaleTexture(
338 GLuint src_texture, 341 GLuint src_texture,
339 const gfx::Size& src_size, 342 const gfx::Size& src_size,
340 const gfx::Rect& src_subrect, 343 const gfx::Rect& src_subrect,
341 const gfx::Size& dst_size, 344 const gfx::Size& dst_size,
342 bool vertically_flip_texture, 345 bool vertically_flip_texture,
343 bool swizzle, 346 bool swizzle,
344 SkBitmap::Config config, 347 SkBitmap::Config bitmap_config,
345 GLHelper::ScalerQuality quality) { 348 GLHelper::ScalerQuality quality) {
349 if (!IsReadbackConfigSupported(bitmap_config))
350 return 0;
346 351
347 bool format_support = ((config == SkBitmap::kRGB_565_Config) ||
348 (config == SkBitmap::kARGB_8888_Config));
349 if (!format_support) {
350 DCHECK(format_support);
351 return 0;
352 }
353 scoped_ptr<ScalerInterface> scaler( 352 scoped_ptr<ScalerInterface> scaler(
354 helper_->CreateScaler(quality, 353 helper_->CreateScaler(quality,
355 src_size, 354 src_size,
356 src_subrect, 355 src_subrect,
357 dst_size, 356 dst_size,
358 vertically_flip_texture, 357 vertically_flip_texture,
359 swizzle)); 358 swizzle));
360 GLuint dst_texture = 0u; 359 GLuint dst_texture = 0u;
361 // Start with ARGB8888 params as any other format which is not 360 // Start with ARGB8888 params as any other format which is not
362 // supported is already asserted above. 361 // supported is already asserted above.
363 GLenum format = GL_RGBA , type = GL_UNSIGNED_BYTE; 362 GLenum format = GL_RGBA , type = GL_UNSIGNED_BYTE;
364 gl_->GenTextures(1, &dst_texture); 363 gl_->GenTextures(1, &dst_texture);
365 { 364 {
366 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, dst_texture); 365 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, dst_texture);
367 switch (config) { 366 switch (bitmap_config) {
368 case SkBitmap::kARGB_8888_Config: 367 case SkBitmap::kARGB_8888_Config:
369 // Do nothing params already set. 368 // Do nothing params already set.
370 break; 369 break;
371 case SkBitmap::kRGB_565_Config: 370 case SkBitmap::kRGB_565_Config:
372 format = GL_RGB; 371 format = GL_RGB;
373 type = GL_UNSIGNED_SHORT_5_6_5; 372 type = GL_UNSIGNED_SHORT_5_6_5;
374 break; 373 break;
375 default: 374 default:
376 NOTREACHED(); 375 NOTREACHED();
377 break; 376 break;
(...skipping 10 matching lines...) Expand all
388 } 387 }
389 scaler->Scale(src_texture, dst_texture); 388 scaler->Scale(src_texture, dst_texture);
390 return dst_texture; 389 return dst_texture;
391 } 390 }
392 391
393 void GLHelper::CopyTextureToImpl::ReadbackAsync( 392 void GLHelper::CopyTextureToImpl::ReadbackAsync(
394 const gfx::Size& dst_size, 393 const gfx::Size& dst_size,
395 int32 bytes_per_row, 394 int32 bytes_per_row,
396 int32 row_stride_bytes, 395 int32 row_stride_bytes,
397 unsigned char* out, 396 unsigned char* out,
398 const SkBitmap::Config config, 397 const SkBitmap::Config bitmap_config,
399 const base::Callback<void(bool)>& callback) { 398 const base::Callback<void(bool)>& callback) {
400 bool format_support = ((config == SkBitmap::kRGB_565_Config) || 399 if (!IsReadbackConfigSupported(bitmap_config)) {
401 (config == SkBitmap::kARGB_8888_Config));
402 if (!format_support) {
403 DCHECK(format_support);
404 callback.Run(false); 400 callback.Run(false);
405 return; 401 return;
406 } 402 }
407 Request* request = 403 Request* request =
408 new Request(dst_size, bytes_per_row, row_stride_bytes, out, callback); 404 new Request(dst_size, bytes_per_row, row_stride_bytes, out, callback);
409 request_queue_.push(request); 405 request_queue_.push(request);
410 request->buffer = 0u; 406 request->buffer = 0u;
411 // Start with ARGB8888 params as any other format which is not 407 // Start with ARGB8888 params as any other format which is not
412 // supported is already asserted above. 408 // supported is already asserted above.
413 GLenum format = GL_RGBA, type = GL_UNSIGNED_BYTE; 409 GLenum format = GL_RGBA, type = GL_UNSIGNED_BYTE;
414 int bytes_per_pixel = 4; 410 int bytes_per_pixel = 4;
415 411
416 switch (config) { 412 switch (bitmap_config) {
417 case SkBitmap::kARGB_8888_Config: 413 case SkBitmap::kARGB_8888_Config:
418 // Do nothing params already set. 414 // Do nothing params already set.
419 break; 415 break;
420 case SkBitmap::kRGB_565_Config: 416 case SkBitmap::kRGB_565_Config:
421 format = GL_RGB; 417 format = GL_RGB;
422 type = GL_UNSIGNED_SHORT_5_6_5; 418 type = GL_UNSIGNED_SHORT_5_6_5;
423 bytes_per_pixel = 2; 419 bytes_per_pixel = 2;
424 break; 420 break;
425 default: 421 default:
426 NOTREACHED(); 422 NOTREACHED();
(...skipping 25 matching lines...) Expand all
452 } 448 }
453 void GLHelper::CopyTextureToImpl::CropScaleReadbackAndCleanTexture( 449 void GLHelper::CopyTextureToImpl::CropScaleReadbackAndCleanTexture(
454 GLuint src_texture, 450 GLuint src_texture,
455 const gfx::Size& src_size, 451 const gfx::Size& src_size,
456 const gfx::Rect& src_subrect, 452 const gfx::Rect& src_subrect,
457 const gfx::Size& dst_size, 453 const gfx::Size& dst_size,
458 unsigned char* out, 454 unsigned char* out,
459 const SkBitmap::Config bitmap_config, 455 const SkBitmap::Config bitmap_config,
460 const base::Callback<void(bool)>& callback, 456 const base::Callback<void(bool)>& callback,
461 GLHelper::ScalerQuality quality) { 457 GLHelper::ScalerQuality quality) {
462 bool format_support = ((bitmap_config == SkBitmap::kRGB_565_Config) || 458 if (!IsReadbackConfigSupported(bitmap_config)) {
463 (bitmap_config == SkBitmap::kARGB_8888_Config));
464 if (!format_support) {
465 DCHECK(format_support);
466 callback.Run(false); 459 callback.Run(false);
467 return; 460 return;
468 } 461 }
469 GLuint texture = ScaleTexture(src_texture, 462 GLuint texture = ScaleTexture(src_texture,
470 src_size, 463 src_size,
471 src_subrect, 464 src_subrect,
472 dst_size, 465 dst_size,
473 true, 466 true,
474 #if (SK_R32_SHIFT == 16) && !SK_B32_SHIFT 467 #if (SK_R32_SHIFT == 16) && !SK_B32_SHIFT
475 true, 468 true,
(...skipping 26 matching lines...) Expand all
502 } 495 }
503 ReadbackAsync(dst_size, 496 ReadbackAsync(dst_size,
504 dst_size.width() * bytes_per_pixel, 497 dst_size.width() * bytes_per_pixel,
505 dst_size.width() * bytes_per_pixel, 498 dst_size.width() * bytes_per_pixel,
506 out, 499 out,
507 bitmap_config, 500 bitmap_config,
508 callback); 501 callback);
509 gl_->DeleteTextures(1, &texture); 502 gl_->DeleteTextures(1, &texture);
510 } 503 }
511 504
512 void GLHelper::CopyTextureToImpl::ReadbackTextureSync(GLuint texture, 505 void GLHelper::CopyTextureToImpl::ReadbackTextureSync(
513 const gfx::Rect& src_rect, 506 GLuint texture,
514 unsigned char* out, 507 const gfx::Rect& src_rect,
515 SkBitmap::Config config) { 508 unsigned char* out,
516 DCHECK((config == SkBitmap::kRGB_565_Config) || 509 SkBitmap::Config bitmap_config) {
517 (config == SkBitmap::kARGB_8888_Config)); 510 if (!IsReadbackConfigSupported(bitmap_config))
511 return;
512
518 ScopedFramebuffer dst_framebuffer(gl_); 513 ScopedFramebuffer dst_framebuffer(gl_);
519 ScopedFramebufferBinder<GL_FRAMEBUFFER> framebuffer_binder(gl_, 514 ScopedFramebufferBinder<GL_FRAMEBUFFER> framebuffer_binder(gl_,
520 dst_framebuffer); 515 dst_framebuffer);
521 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, texture); 516 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, texture);
522 gl_->FramebufferTexture2D( 517 gl_->FramebufferTexture2D(
523 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0); 518 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
524 GLenum format = (config == SkBitmap::kRGB_565_Config) ? 519 GLenum format =
525 GL_RGB : 520 (bitmap_config == SkBitmap::kRGB_565_Config) ? GL_RGB : GL_RGBA;
526 GL_RGBA; 521 GLenum type = (bitmap_config == SkBitmap::kRGB_565_Config)
527 GLenum type = (config == SkBitmap::kRGB_565_Config) ? 522 ? GL_UNSIGNED_SHORT_5_6_5
528 GL_UNSIGNED_SHORT_5_6_5 : 523 : GL_UNSIGNED_BYTE;
529 GL_UNSIGNED_BYTE;
530 gl_->ReadPixels(src_rect.x(), 524 gl_->ReadPixels(src_rect.x(),
531 src_rect.y(), 525 src_rect.y(),
532 src_rect.width(), 526 src_rect.width(),
533 src_rect.height(), 527 src_rect.height(),
534 format, 528 format,
535 type, 529 type,
536 out); 530 out);
537 } 531 }
538 532
539 void GLHelper::CopyTextureToImpl::ReadbackTextureAsync( 533 void GLHelper::CopyTextureToImpl::ReadbackTextureAsync(
540 GLuint texture, 534 GLuint texture,
541 const gfx::Size& dst_size, 535 const gfx::Size& dst_size,
542 unsigned char* out, 536 unsigned char* out,
543 SkBitmap::Config config, 537 SkBitmap::Config bitmap_config,
544 const base::Callback<void(bool)>& callback) { 538 const base::Callback<void(bool)>& callback) {
545 // Only ARGB888 and RGB565 supported as of now. 539 if (!IsReadbackConfigSupported(bitmap_config))
546 bool format_support = ((config == SkBitmap::kRGB_565_Config) ||
547 (config == SkBitmap::kARGB_8888_Config));
548 if (!format_support) {
549 DCHECK(format_support);
550 return; 540 return;
551 } 541
552 ScopedFramebuffer dst_framebuffer(gl_); 542 ScopedFramebuffer dst_framebuffer(gl_);
553 ScopedFramebufferBinder<GL_FRAMEBUFFER> framebuffer_binder(gl_, 543 ScopedFramebufferBinder<GL_FRAMEBUFFER> framebuffer_binder(gl_,
554 dst_framebuffer); 544 dst_framebuffer);
555 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, texture); 545 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, texture);
556 gl_->FramebufferTexture2D(GL_FRAMEBUFFER, 546 gl_->FramebufferTexture2D(GL_FRAMEBUFFER,
557 GL_COLOR_ATTACHMENT0, 547 GL_COLOR_ATTACHMENT0,
558 GL_TEXTURE_2D, 548 GL_TEXTURE_2D,
559 texture, 549 texture,
560 0); 550 0);
561 int bytes_per_pixel = (config == SkBitmap::kRGB_565_Config) ? 2 : 4; 551 int bytes_per_pixel = (bitmap_config == SkBitmap::kRGB_565_Config) ? 2 : 4;
562 ReadbackAsync(dst_size, 552 ReadbackAsync(dst_size,
563 dst_size.width() * bytes_per_pixel, 553 dst_size.width() * bytes_per_pixel,
564 dst_size.width() * bytes_per_pixel, 554 dst_size.width() * bytes_per_pixel,
565 out, 555 out,
566 config, 556 bitmap_config,
567 callback); 557 callback);
568 } 558 }
569 559
570 GLuint GLHelper::CopyTextureToImpl::CopyAndScaleTexture( 560 GLuint GLHelper::CopyTextureToImpl::CopyAndScaleTexture(
571 GLuint src_texture, 561 GLuint src_texture,
572 const gfx::Size& src_size, 562 const gfx::Size& src_size,
573 const gfx::Size& dst_size, 563 const gfx::Size& dst_size,
574 bool vertically_flip_texture, 564 bool vertically_flip_texture,
575 GLHelper::ScalerQuality quality) { 565 GLHelper::ScalerQuality quality) {
576 return ScaleTexture(src_texture, 566 return ScaleTexture(src_texture,
577 src_size, 567 src_size,
578 gfx::Rect(src_size), 568 gfx::Rect(src_size),
579 dst_size, 569 dst_size,
580 vertically_flip_texture, 570 vertically_flip_texture,
581 false, 571 false,
582 SkBitmap::kARGB_8888_Config, 572 SkBitmap::kARGB_8888_Config,
583 quality); 573 quality);
584 } 574 }
585 575
576 bool GLHelper::CopyTextureToImpl::IsReadbackConfigSupported(
577 SkBitmap::Config bitmap_config) {
578 if (!helper_) {
579 DCHECK(helper_);
580 return false;
581 }
582 return helper_->IsReadbackConfigSupported(bitmap_config);
583 }
584
586 void GLHelper::CopyTextureToImpl::ReadbackDone(Request* finished_request, 585 void GLHelper::CopyTextureToImpl::ReadbackDone(Request* finished_request,
587 int bytes_per_pixel) { 586 int bytes_per_pixel) {
588 TRACE_EVENT0("mirror", 587 TRACE_EVENT0("mirror",
589 "GLHelper::CopyTextureToImpl::CheckReadbackFramebufferComplete"); 588 "GLHelper::CopyTextureToImpl::CheckReadbackFramebufferComplete");
590 finished_request->done = true; 589 finished_request->done = true;
591 590
592 // We process transfer requests in the order they were received, regardless 591 // We process transfer requests in the order they were received, regardless
593 // of the order we get the callbacks in. 592 // of the order we get the callbacks in.
594 while (!request_queue_.empty()) { 593 while (!request_queue_.empty()) {
595 Request* request = request_queue_.front(); 594 Request* request = request_queue_.front();
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 void GLHelper::CopyTextureToImpl::CancelRequests() { 643 void GLHelper::CopyTextureToImpl::CancelRequests() {
645 while (!request_queue_.empty()) { 644 while (!request_queue_.empty()) {
646 Request* request = request_queue_.front(); 645 Request* request = request_queue_.front();
647 FinishRequest(request, false); 646 FinishRequest(request, false);
648 } 647 }
649 } 648 }
650 649
651 GLHelper::GLHelper(GLES2Interface* gl, gpu::ContextSupport* context_support) 650 GLHelper::GLHelper(GLES2Interface* gl, gpu::ContextSupport* context_support)
652 : gl_(gl), 651 : gl_(gl),
653 context_support_(context_support), 652 context_support_(context_support),
654 initialized_565_format_check_(false), 653 readback_support_(new GLHelperReadbackSupport(gl, this)) {}
655 support_565_format_(false) {}
656 654
657 GLHelper::~GLHelper() {} 655 GLHelper::~GLHelper() {}
658 656
659 void GLHelper::CropScaleReadbackAndCleanTexture( 657 void GLHelper::CropScaleReadbackAndCleanTexture(
660 GLuint src_texture, 658 GLuint src_texture,
661 const gfx::Size& src_size, 659 const gfx::Size& src_size,
662 const gfx::Rect& src_subrect, 660 const gfx::Rect& src_subrect,
663 const gfx::Size& dst_size, 661 const gfx::Size& dst_size,
664 unsigned char* out, 662 unsigned char* out,
665 const SkBitmap::Config config, 663 const SkBitmap::Config config,
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 rect.width(), 866 rect.width(),
869 rect.height()); 867 rect.height());
870 } 868 }
871 869
872 void GLHelper::CopyTextureFullImage(GLuint texture, const gfx::Size& size) { 870 void GLHelper::CopyTextureFullImage(GLuint texture, const gfx::Size& size) {
873 content::ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, texture); 871 content::ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, texture);
874 gl_->CopyTexImage2D( 872 gl_->CopyTexImage2D(
875 GL_TEXTURE_2D, 0, GL_RGB, 0, 0, size.width(), size.height(), 0); 873 GL_TEXTURE_2D, 0, GL_RGB, 0, 0, size.width(), size.height(), 0);
876 } 874 }
877 875
878 bool GLHelper::CanUseRgb565Readback() {
879 if(initialized_565_format_check_){
880 return support_565_format_;
881 }
882 const int kTestSize = 64;
883 GLuint dst_texture = 0u;
884 gl_->GenTextures(1, &dst_texture);
885 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, dst_texture);
886 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
887 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
888 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
889 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
890 gl_->TexImage2D(GL_TEXTURE_2D,
891 0,
892 GL_RGB,
893 kTestSize,
894 kTestSize,
895 0,
896 GL_RGB,
897 GL_UNSIGNED_SHORT_5_6_5,
898 NULL);
899 ScopedFramebuffer dst_framebuffer(gl_);
900 ScopedFramebufferBinder<GL_FRAMEBUFFER> framebuffer_binder(gl_,
901 dst_framebuffer);
902 gl_->FramebufferTexture2D(GL_FRAMEBUFFER,
903 GL_COLOR_ATTACHMENT0,
904 GL_TEXTURE_2D,
905 dst_texture,
906 0);
907 GLint ext_format = 0, ext_type = 0;
908 gl_->GetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &ext_format);
909 gl_->GetIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE, &ext_type);
910 gl_->DeleteTextures(1, &dst_texture);
911 if ((ext_format == GL_RGB) && (ext_type == GL_UNSIGNED_SHORT_5_6_5)) {
912 support_565_format_ = true;
913 }
914 initialized_565_format_check_ = true;
915 return support_565_format_;
916 }
917
918 void GLHelper::CopyTextureToImpl::ReadbackPlane( 876 void GLHelper::CopyTextureToImpl::ReadbackPlane(
919 TextureFrameBufferPair* source, 877 TextureFrameBufferPair* source,
920 const scoped_refptr<media::VideoFrame>& target, 878 const scoped_refptr<media::VideoFrame>& target,
921 int plane, 879 int plane,
922 int size_shift, 880 int size_shift,
923 const gfx::Rect& dst_subrect, 881 const gfx::Rect& dst_subrect,
924 const base::Callback<void(bool)>& callback) { 882 const base::Callback<void(bool)>& callback) {
925 gl_->BindFramebuffer(GL_FRAMEBUFFER, source->framebuffer()); 883 gl_->BindFramebuffer(GL_FRAMEBUFFER, source->framebuffer());
926 size_t offset = target->stride(plane) * (dst_subrect.y() >> size_shift) + 884 size_t offset = target->stride(plane) * (dst_subrect.y() >> size_shift) +
927 (dst_subrect.x() >> size_shift); 885 (dst_subrect.x() >> size_shift);
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
1183 &v_, 1141 &v_,
1184 target, 1142 target,
1185 media::VideoFrame::kVPlane, 1143 media::VideoFrame::kVPlane,
1186 1, 1144 1,
1187 dst_subrect_, 1145 dst_subrect_,
1188 base::Bind(&CallbackKeepingVideoFrameAlive, target, callback)); 1146 base::Bind(&CallbackKeepingVideoFrameAlive, target, callback));
1189 gl_->BindFramebuffer(GL_FRAMEBUFFER, 0); 1147 gl_->BindFramebuffer(GL_FRAMEBUFFER, 0);
1190 media::LetterboxYUV(target, dst_subrect_); 1148 media::LetterboxYUV(target, dst_subrect_);
1191 } 1149 }
1192 1150
1151 bool GLHelper::IsReadbackConfigSupported(SkBitmap::Config texture_format) {
1152 DCHECK(readback_support_.get());
1153 return readback_support_.get()->IsReadbackConfigSupported(texture_format);
1154 }
1155
1193 ReadbackYUVInterface* GLHelper::CopyTextureToImpl::CreateReadbackPipelineYUV( 1156 ReadbackYUVInterface* GLHelper::CopyTextureToImpl::CreateReadbackPipelineYUV(
1194 GLHelper::ScalerQuality quality, 1157 GLHelper::ScalerQuality quality,
1195 const gfx::Size& src_size, 1158 const gfx::Size& src_size,
1196 const gfx::Rect& src_subrect, 1159 const gfx::Rect& src_subrect,
1197 const gfx::Size& dst_size, 1160 const gfx::Size& dst_size,
1198 const gfx::Rect& dst_subrect, 1161 const gfx::Rect& dst_subrect,
1199 bool flip_vertically, 1162 bool flip_vertically,
1200 bool use_mrt) { 1163 bool use_mrt) {
1201 helper_->InitScalerImpl(); 1164 helper_->InitScalerImpl();
1202 if (max_draw_buffers_ >= 2 && use_mrt) { 1165 if (max_draw_buffers_ >= 2 && use_mrt) {
(...skipping 30 matching lines...) Expand all
1233 return copy_texture_to_impl_->CreateReadbackPipelineYUV(quality, 1196 return copy_texture_to_impl_->CreateReadbackPipelineYUV(quality,
1234 src_size, 1197 src_size,
1235 src_subrect, 1198 src_subrect,
1236 dst_size, 1199 dst_size,
1237 dst_subrect, 1200 dst_subrect,
1238 flip_vertically, 1201 flip_vertically,
1239 use_mrt); 1202 use_mrt);
1240 } 1203 }
1241 1204
1242 } // namespace content 1205 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698