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

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: Formatted cl using git format option. Created 6 years, 10 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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 const gfx::Rect& src_subrect, 171 const gfx::Rect& src_subrect,
172 const gfx::Size& dst_size, 172 const gfx::Size& dst_size,
173 const gfx::Rect& dst_subrect, 173 const gfx::Rect& dst_subrect,
174 bool flip_vertically, 174 bool flip_vertically,
175 bool use_mrt); 175 bool use_mrt);
176 176
177 // Returns the maximum number of draw buffers available, 177 // Returns the maximum number of draw buffers available,
178 // 0 if GL_EXT_draw_buffers is not available. 178 // 0 if GL_EXT_draw_buffers is not available.
179 GLint MaxDrawBuffers() const { return max_draw_buffers_; } 179 GLint MaxDrawBuffers() const { return max_draw_buffers_; }
180 180
181 bool IsReadBackConfigSupported(SkBitmap::Config bitmap_config);
182
181 private: 183 private:
182 // A single request to CropScaleReadbackAndCleanTexture. 184 // A single request to CropScaleReadbackAndCleanTexture.
183 // The main thread can cancel the request, before it's handled by the helper 185 // 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 186 // thread, by resetting the texture and pixels fields. Alternatively, the
185 // thread marks that it handles the request by resetting the pixels field 187 // thread marks that it handles the request by resetting the pixels field
186 // (meaning it guarantees that the callback with be called). 188 // (meaning it guarantees that the callback with be called).
187 // In either case, the callback must be called exactly once, and the texture 189 // In either case, the callback must be called exactly once, and the texture
188 // must be deleted by the main thread gl. 190 // must be deleted by the main thread gl.
189 struct Request { 191 struct Request {
190 Request(const gfx::Size& size_, 192 Request(const gfx::Size& size_,
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 swizzle); 336 swizzle);
335 } 337 }
336 338
337 GLuint GLHelper::CopyTextureToImpl::ScaleTexture( 339 GLuint GLHelper::CopyTextureToImpl::ScaleTexture(
338 GLuint src_texture, 340 GLuint src_texture,
339 const gfx::Size& src_size, 341 const gfx::Size& src_size,
340 const gfx::Rect& src_subrect, 342 const gfx::Rect& src_subrect,
341 const gfx::Size& dst_size, 343 const gfx::Size& dst_size,
342 bool vertically_flip_texture, 344 bool vertically_flip_texture,
343 bool swizzle, 345 bool swizzle,
344 SkBitmap::Config config, 346 SkBitmap::Config bitmap_config,
345 GLHelper::ScalerQuality quality) { 347 GLHelper::ScalerQuality quality) {
346 348
piman 2014/02/20 00:32:18 nit: no blank line
sivag 2014/02/21 11:40:51 Done.
347 bool format_support = ((config == SkBitmap::kRGB_565_Config) || 349 if (!IsReadBackConfigSupported(bitmap_config))
348 (config == SkBitmap::kARGB_8888_Config));
349 if (!format_support) {
350 DCHECK(format_support);
351 return 0; 350 return 0;
352 } 351
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
piman 2014/02/20 00:32:18 nit: no blank line
sivag 2014/02/21 11:40:51 Done.
401 (config == SkBitmap::kARGB_8888_Config)); 400 if (!IsReadBackConfigSupported(bitmap_config)) {
402 if (!format_support) {
403 DCHECK(format_support);
404 callback.Run(false); 401 callback.Run(false);
405 return; 402 return;
406 } 403 }
407 Request* request = 404 Request* request =
408 new Request(dst_size, bytes_per_row, row_stride_bytes, out, callback); 405 new Request(dst_size, bytes_per_row, row_stride_bytes, out, callback);
409 request_queue_.push(request); 406 request_queue_.push(request);
410 request->buffer = 0u; 407 request->buffer = 0u;
411 // Start with ARGB8888 params as any other format which is not 408 // Start with ARGB8888 params as any other format which is not
412 // supported is already asserted above. 409 // supported is already asserted above.
413 GLenum format = GL_RGBA, type = GL_UNSIGNED_BYTE; 410 GLenum format = GL_RGBA, type = GL_UNSIGNED_BYTE;
414 int bytes_per_pixel = 4; 411 int bytes_per_pixel = 4;
415 412
416 switch (config) { 413 switch (bitmap_config) {
417 case SkBitmap::kARGB_8888_Config: 414 case SkBitmap::kARGB_8888_Config:
418 // Do nothing params already set. 415 // Do nothing params already set.
419 break; 416 break;
420 case SkBitmap::kRGB_565_Config: 417 case SkBitmap::kRGB_565_Config:
421 format = GL_RGB; 418 format = GL_RGB;
422 type = GL_UNSIGNED_SHORT_5_6_5; 419 type = GL_UNSIGNED_SHORT_5_6_5;
423 bytes_per_pixel = 2; 420 bytes_per_pixel = 2;
424 break; 421 break;
425 default: 422 default:
426 NOTREACHED(); 423 NOTREACHED();
(...skipping 25 matching lines...) Expand all
452 } 449 }
453 void GLHelper::CopyTextureToImpl::CropScaleReadbackAndCleanTexture( 450 void GLHelper::CopyTextureToImpl::CropScaleReadbackAndCleanTexture(
454 GLuint src_texture, 451 GLuint src_texture,
455 const gfx::Size& src_size, 452 const gfx::Size& src_size,
456 const gfx::Rect& src_subrect, 453 const gfx::Rect& src_subrect,
457 const gfx::Size& dst_size, 454 const gfx::Size& dst_size,
458 unsigned char* out, 455 unsigned char* out,
459 const SkBitmap::Config bitmap_config, 456 const SkBitmap::Config bitmap_config,
460 const base::Callback<void(bool)>& callback, 457 const base::Callback<void(bool)>& callback,
461 GLHelper::ScalerQuality quality) { 458 GLHelper::ScalerQuality quality) {
462 bool format_support = ((bitmap_config == SkBitmap::kRGB_565_Config) || 459
piman 2014/02/20 00:32:18 nit: no blank line
sivag 2014/02/21 11:40:51 Done.
463 (bitmap_config == SkBitmap::kARGB_8888_Config)); 460 if (!IsReadBackConfigSupported(bitmap_config)) {
464 if (!format_support) {
465 DCHECK(format_support);
466 callback.Run(false); 461 callback.Run(false);
467 return; 462 return;
468 } 463 }
469 GLuint texture = ScaleTexture(src_texture, 464 GLuint texture = ScaleTexture(src_texture,
470 src_size, 465 src_size,
471 src_subrect, 466 src_subrect,
472 dst_size, 467 dst_size,
473 true, 468 true,
474 #if (SK_R32_SHIFT == 16) && !SK_B32_SHIFT 469 #if (SK_R32_SHIFT == 16) && !SK_B32_SHIFT
475 true, 470 true,
(...skipping 26 matching lines...) Expand all
502 } 497 }
503 ReadbackAsync(dst_size, 498 ReadbackAsync(dst_size,
504 dst_size.width() * bytes_per_pixel, 499 dst_size.width() * bytes_per_pixel,
505 dst_size.width() * bytes_per_pixel, 500 dst_size.width() * bytes_per_pixel,
506 out, 501 out,
507 bitmap_config, 502 bitmap_config,
508 callback); 503 callback);
509 gl_->DeleteTextures(1, &texture); 504 gl_->DeleteTextures(1, &texture);
510 } 505 }
511 506
512 void GLHelper::CopyTextureToImpl::ReadbackTextureSync(GLuint texture, 507 void GLHelper::CopyTextureToImpl::ReadbackTextureSync(
513 const gfx::Rect& src_rect, 508 GLuint texture,
514 unsigned char* out, 509 const gfx::Rect& src_rect,
515 SkBitmap::Config config) { 510 unsigned char* out,
516 DCHECK((config == SkBitmap::kRGB_565_Config) || 511 SkBitmap::Config bitmap_config) {
517 (config == SkBitmap::kARGB_8888_Config)); 512
piman 2014/02/20 00:32:18 nit: no blank line
sivag 2014/02/21 11:40:51 Done.
513 if (!IsReadBackConfigSupported(bitmap_config))
514 return;
515
518 ScopedFramebuffer dst_framebuffer(gl_); 516 ScopedFramebuffer dst_framebuffer(gl_);
519 ScopedFramebufferBinder<GL_FRAMEBUFFER> framebuffer_binder(gl_, 517 ScopedFramebufferBinder<GL_FRAMEBUFFER> framebuffer_binder(gl_,
520 dst_framebuffer); 518 dst_framebuffer);
521 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, texture); 519 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, texture);
522 gl_->FramebufferTexture2D( 520 gl_->FramebufferTexture2D(
523 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0); 521 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
524 GLenum format = (config == SkBitmap::kRGB_565_Config) ? 522 GLenum format =
525 GL_RGB : 523 (bitmap_config == SkBitmap::kRGB_565_Config) ? GL_RGB : GL_RGBA;
526 GL_RGBA; 524 GLenum type = (bitmap_config == SkBitmap::kRGB_565_Config)
527 GLenum type = (config == SkBitmap::kRGB_565_Config) ? 525 ? GL_UNSIGNED_SHORT_5_6_5
528 GL_UNSIGNED_SHORT_5_6_5 : 526 : GL_UNSIGNED_BYTE;
529 GL_UNSIGNED_BYTE;
530 gl_->ReadPixels(src_rect.x(), 527 gl_->ReadPixels(src_rect.x(),
531 src_rect.y(), 528 src_rect.y(),
532 src_rect.width(), 529 src_rect.width(),
533 src_rect.height(), 530 src_rect.height(),
534 format, 531 format,
535 type, 532 type,
536 out); 533 out);
537 } 534 }
538 535
539 void GLHelper::CopyTextureToImpl::ReadbackTextureAsync( 536 void GLHelper::CopyTextureToImpl::ReadbackTextureAsync(
540 GLuint texture, 537 GLuint texture,
541 const gfx::Size& dst_size, 538 const gfx::Size& dst_size,
542 unsigned char* out, 539 unsigned char* out,
543 SkBitmap::Config config, 540 SkBitmap::Config bitmap_config,
544 const base::Callback<void(bool)>& callback) { 541 const base::Callback<void(bool)>& callback) {
545 // Only ARGB888 and RGB565 supported as of now. 542
piman 2014/02/20 00:32:18 nit: no blank line
sivag 2014/02/21 11:40:51 Done.
546 bool format_support = ((config == SkBitmap::kRGB_565_Config) || 543 if (!IsReadBackConfigSupported(bitmap_config))
547 (config == SkBitmap::kARGB_8888_Config));
548 if (!format_support) {
549 DCHECK(format_support);
550 return; 544 return;
551 } 545
552 ScopedFramebuffer dst_framebuffer(gl_); 546 ScopedFramebuffer dst_framebuffer(gl_);
553 ScopedFramebufferBinder<GL_FRAMEBUFFER> framebuffer_binder(gl_, 547 ScopedFramebufferBinder<GL_FRAMEBUFFER> framebuffer_binder(gl_,
554 dst_framebuffer); 548 dst_framebuffer);
555 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, texture); 549 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, texture);
556 gl_->FramebufferTexture2D(GL_FRAMEBUFFER, 550 gl_->FramebufferTexture2D(GL_FRAMEBUFFER,
557 GL_COLOR_ATTACHMENT0, 551 GL_COLOR_ATTACHMENT0,
558 GL_TEXTURE_2D, 552 GL_TEXTURE_2D,
559 texture, 553 texture,
560 0); 554 0);
561 int bytes_per_pixel = (config == SkBitmap::kRGB_565_Config) ? 2 : 4; 555 int bytes_per_pixel = (bitmap_config == SkBitmap::kRGB_565_Config) ? 2 : 4;
562 ReadbackAsync(dst_size, 556 ReadbackAsync(dst_size,
563 dst_size.width() * bytes_per_pixel, 557 dst_size.width() * bytes_per_pixel,
564 dst_size.width() * bytes_per_pixel, 558 dst_size.width() * bytes_per_pixel,
565 out, 559 out,
566 config, 560 bitmap_config,
567 callback); 561 callback);
568 } 562 }
569 563
570 GLuint GLHelper::CopyTextureToImpl::CopyAndScaleTexture( 564 GLuint GLHelper::CopyTextureToImpl::CopyAndScaleTexture(
571 GLuint src_texture, 565 GLuint src_texture,
572 const gfx::Size& src_size, 566 const gfx::Size& src_size,
573 const gfx::Size& dst_size, 567 const gfx::Size& dst_size,
574 bool vertically_flip_texture, 568 bool vertically_flip_texture,
575 GLHelper::ScalerQuality quality) { 569 GLHelper::ScalerQuality quality) {
576 return ScaleTexture(src_texture, 570 return ScaleTexture(src_texture,
577 src_size, 571 src_size,
578 gfx::Rect(src_size), 572 gfx::Rect(src_size),
579 dst_size, 573 dst_size,
580 vertically_flip_texture, 574 vertically_flip_texture,
581 false, 575 false,
582 SkBitmap::kARGB_8888_Config, 576 SkBitmap::kARGB_8888_Config,
583 quality); 577 quality);
584 } 578 }
585 579
580 bool GLHelper::CopyTextureToImpl::IsReadBackConfigSupported(
581 SkBitmap::Config bitmap_config) {
582 if (!helper_) {
583 NOTREACHED();
piman 2014/02/20 00:32:18 nit: just DCHECK(helper_).
sivag 2014/02/21 11:40:51 Done.
584 return false;
585 }
586 return helper_->IsReadBackConfigSupported(bitmap_config);
587 }
588
586 void GLHelper::CopyTextureToImpl::ReadbackDone(Request* finished_request, 589 void GLHelper::CopyTextureToImpl::ReadbackDone(Request* finished_request,
587 int bytes_per_pixel) { 590 int bytes_per_pixel) {
588 TRACE_EVENT0("mirror", 591 TRACE_EVENT0("mirror",
589 "GLHelper::CopyTextureToImpl::CheckReadbackFramebufferComplete"); 592 "GLHelper::CopyTextureToImpl::CheckReadbackFramebufferComplete");
590 finished_request->done = true; 593 finished_request->done = true;
591 594
592 // We process transfer requests in the order they were received, regardless 595 // We process transfer requests in the order they were received, regardless
593 // of the order we get the callbacks in. 596 // of the order we get the callbacks in.
594 while (!request_queue_.empty()) { 597 while (!request_queue_.empty()) {
595 Request* request = request_queue_.front(); 598 Request* request = request_queue_.front();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 } 645 }
643 646
644 void GLHelper::CopyTextureToImpl::CancelRequests() { 647 void GLHelper::CopyTextureToImpl::CancelRequests() {
645 while (!request_queue_.empty()) { 648 while (!request_queue_.empty()) {
646 Request* request = request_queue_.front(); 649 Request* request = request_queue_.front();
647 FinishRequest(request, false); 650 FinishRequest(request, false);
648 } 651 }
649 } 652 }
650 653
651 GLHelper::GLHelper(GLES2Interface* gl, gpu::ContextSupport* context_support) 654 GLHelper::GLHelper(GLES2Interface* gl, gpu::ContextSupport* context_support)
652 : gl_(gl), 655 : gl_(gl), context_support_(context_support) {
653 context_support_(context_support), 656 for (int i = 0; i < SkBitmap::kConfigCount; ++i) {
654 initialized_565_format_check_(false), 657 format_support_table_[i] = FORMAT_NONE;
655 support_565_format_(false) {} 658 }
659 }
656 660
657 GLHelper::~GLHelper() {} 661 GLHelper::~GLHelper() {}
658 662
659 void GLHelper::CropScaleReadbackAndCleanTexture( 663 void GLHelper::CropScaleReadbackAndCleanTexture(
660 GLuint src_texture, 664 GLuint src_texture,
661 const gfx::Size& src_size, 665 const gfx::Size& src_size,
662 const gfx::Rect& src_subrect, 666 const gfx::Rect& src_subrect,
663 const gfx::Size& dst_size, 667 const gfx::Size& dst_size,
664 unsigned char* out, 668 unsigned char* out,
665 const SkBitmap::Config config, 669 const SkBitmap::Config config,
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 rect.width(), 872 rect.width(),
869 rect.height()); 873 rect.height());
870 } 874 }
871 875
872 void GLHelper::CopyTextureFullImage(GLuint texture, const gfx::Size& size) { 876 void GLHelper::CopyTextureFullImage(GLuint texture, const gfx::Size& size) {
873 content::ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, texture); 877 content::ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, texture);
874 gl_->CopyTexImage2D( 878 gl_->CopyTexImage2D(
875 GL_TEXTURE_2D, 0, GL_RGB, 0, 0, size.width(), size.height(), 0); 879 GL_TEXTURE_2D, 0, GL_RGB, 0, 0, size.width(), size.height(), 0);
876 } 880 }
877 881
878 bool GLHelper::CanUseRgb565Readback() { 882 bool GLHelper::SupportsFormat(GLint format, GLint type) {
879 if(initialized_565_format_check_){
880 return support_565_format_;
881 }
882 const int kTestSize = 64; 883 const int kTestSize = 64;
883 GLuint dst_texture = 0u; 884 GLuint dst_texture = 0u;
885 bool supports_format = false;
884 gl_->GenTextures(1, &dst_texture); 886 gl_->GenTextures(1, &dst_texture);
885 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, dst_texture); 887 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, dst_texture);
886 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 888 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
887 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 889 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); 890 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); 891 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
890 gl_->TexImage2D(GL_TEXTURE_2D, 892 gl_->TexImage2D(
891 0, 893 GL_TEXTURE_2D, 0, format, kTestSize, kTestSize, 0, format, type, NULL);
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_); 894 ScopedFramebuffer dst_framebuffer(gl_);
900 ScopedFramebufferBinder<GL_FRAMEBUFFER> framebuffer_binder(gl_, 895 ScopedFramebufferBinder<GL_FRAMEBUFFER> framebuffer_binder(gl_,
901 dst_framebuffer); 896 dst_framebuffer);
902 gl_->FramebufferTexture2D(GL_FRAMEBUFFER, 897 gl_->FramebufferTexture2D(GL_FRAMEBUFFER,
903 GL_COLOR_ATTACHMENT0, 898 GL_COLOR_ATTACHMENT0,
904 GL_TEXTURE_2D, 899 GL_TEXTURE_2D,
905 dst_texture, 900 dst_texture,
906 0); 901 0);
907 GLint ext_format = 0, ext_type = 0; 902 GLint ext_format = 0, ext_type = 0;
908 gl_->GetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &ext_format); 903 gl_->GetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &ext_format);
909 gl_->GetIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE, &ext_type); 904 gl_->GetIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE, &ext_type);
910 gl_->DeleteTextures(1, &dst_texture); 905 gl_->DeleteTextures(1, &dst_texture);
911 if ((ext_format == GL_RGB) && (ext_type == GL_UNSIGNED_SHORT_5_6_5)) { 906 if ((ext_format == format) && (ext_type == type)) {
912 support_565_format_ = true; 907 supports_format = true;
913 } 908 }
914 initialized_565_format_check_ = true; 909 return supports_format;
915 return support_565_format_; 910 }
911
912 bool GLHelper::IsReadBackConfigSupported(
913 const SkBitmap::Config& bitmap_format) {
914
piman 2014/02/20 00:32:18 nit: no blank line.
915 if (format_support_table_[bitmap_format] != FORMAT_NONE) {
916 return format_support_table_[bitmap_format];
917 }
918
919 bool supports_format = false;
920
921 switch (bitmap_format) {
922 case SkBitmap::kRGB_565_Config:
923 supports_format = SupportsFormat(GL_RGB, GL_UNSIGNED_SHORT_5_6_5);
924 break;
925 case SkBitmap::kARGB_8888_Config:
926 supports_format = SupportsFormat(GL_RGBA, GL_UNSIGNED_BYTE);
927 break;
928 case SkBitmap::kA8_Config:
929 case SkBitmap::kARGB_4444_Config:
930 default:
931 NOTREACHED();
932 supports_format = false;
933 break;
934 }
935 format_support_table_[bitmap_format] =
936 supports_format ? FORMAT_SUPPORTED : FORMAT_NOT_SUPPORTED;
937 return supports_format;
916 } 938 }
917 939
918 void GLHelper::CopyTextureToImpl::ReadbackPlane( 940 void GLHelper::CopyTextureToImpl::ReadbackPlane(
919 TextureFrameBufferPair* source, 941 TextureFrameBufferPair* source,
920 const scoped_refptr<media::VideoFrame>& target, 942 const scoped_refptr<media::VideoFrame>& target,
921 int plane, 943 int plane,
922 int size_shift, 944 int size_shift,
923 const gfx::Rect& dst_subrect, 945 const gfx::Rect& dst_subrect,
924 const base::Callback<void(bool)>& callback) { 946 const base::Callback<void(bool)>& callback) {
925 gl_->BindFramebuffer(GL_FRAMEBUFFER, source->framebuffer()); 947 gl_->BindFramebuffer(GL_FRAMEBUFFER, source->framebuffer());
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
1233 return copy_texture_to_impl_->CreateReadbackPipelineYUV(quality, 1255 return copy_texture_to_impl_->CreateReadbackPipelineYUV(quality,
1234 src_size, 1256 src_size,
1235 src_subrect, 1257 src_subrect,
1236 dst_size, 1258 dst_size,
1237 dst_subrect, 1259 dst_subrect,
1238 flip_vertically, 1260 flip_vertically,
1239 use_mrt); 1261 use_mrt);
1240 } 1262 }
1241 1263
1242 } // namespace content 1264 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698