OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/common/gpu/client/gl_helper.h" | 5 #include "content/common/gpu/client/gl_helper.h" |
6 | 6 |
7 #include <queue> | 7 #include <queue> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 Loading... |
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 Loading... |
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; |
| 354 // Start with ARGB8888 params as any other format which is not |
| 355 // supported is already asserted above. |
| 356 GLenum format = GL_RGBA , type = GL_UNSIGNED_BYTE; |
348 gl_->GenTextures(1, &dst_texture); | 357 gl_->GenTextures(1, &dst_texture); |
349 { | 358 { |
350 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, dst_texture); | 359 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, dst_texture); |
351 GLenum format = readback_config_rgb565 ? GL_RGB : GL_RGBA; | 360 switch (config) { |
352 GLenum type = readback_config_rgb565 ? | 361 case SkBitmap::kARGB_8888_Config: |
353 GL_UNSIGNED_SHORT_5_6_5 : | 362 // Do nothing params already set. |
354 GL_UNSIGNED_BYTE; | 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 DCHECK(texture); |
430 ScopedFramebuffer dst_framebuffer(gl_); | 475 ScopedFramebuffer dst_framebuffer(gl_); |
431 ScopedFramebufferBinder<GL_FRAMEBUFFER> framebuffer_binder(gl_, | 476 ScopedFramebufferBinder<GL_FRAMEBUFFER> framebuffer_binder(gl_, |
432 dst_framebuffer); | 477 dst_framebuffer); |
433 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, texture); | 478 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, texture); |
434 gl_->FramebufferTexture2D(GL_FRAMEBUFFER, | 479 gl_->FramebufferTexture2D(GL_FRAMEBUFFER, |
435 GL_COLOR_ATTACHMENT0, | 480 GL_COLOR_ATTACHMENT0, |
436 GL_TEXTURE_2D, | 481 GL_TEXTURE_2D, |
437 texture, | 482 texture, |
438 0); | 483 0); |
439 int bytes_per_pixel = readback_config_rgb565 ? 2 : 4; | 484 int bytes_per_pixel = 4; |
| 485 switch (bitmap_config) { |
| 486 case SkBitmap::kARGB_8888_Config: |
| 487 // Do nothing params already set. |
| 488 break; |
| 489 case SkBitmap::kRGB_565_Config: |
| 490 bytes_per_pixel = 2; |
| 491 break; |
| 492 default: |
| 493 NOTREACHED(); |
| 494 break; |
| 495 } |
440 ReadbackAsync(dst_size, | 496 ReadbackAsync(dst_size, |
441 dst_size.width() * bytes_per_pixel, | 497 dst_size.width() * bytes_per_pixel, |
442 dst_size.width() * bytes_per_pixel, | 498 dst_size.width() * bytes_per_pixel, |
443 out, | 499 out, |
444 readback_config_rgb565, | 500 bitmap_config, |
445 callback); | 501 callback); |
446 gl_->DeleteTextures(1, &texture); | 502 gl_->DeleteTextures(1, &texture); |
447 } | 503 } |
448 | 504 |
449 void GLHelper::CopyTextureToImpl::ReadbackTextureSync(GLuint texture, | 505 void GLHelper::CopyTextureToImpl::ReadbackTextureSync(GLuint texture, |
450 const gfx::Rect& src_rect, | 506 const gfx::Rect& src_rect, |
451 unsigned char* out, | 507 unsigned char* out, |
452 SkBitmap::Config config) { | 508 SkBitmap::Config config) { |
| 509 DCHECK((config == SkBitmap::kRGB_565_Config) || |
| 510 (config == SkBitmap::kARGB_8888_Config)); |
453 ScopedFramebuffer dst_framebuffer(gl_); | 511 ScopedFramebuffer dst_framebuffer(gl_); |
454 ScopedFramebufferBinder<GL_FRAMEBUFFER> framebuffer_binder(gl_, | 512 ScopedFramebufferBinder<GL_FRAMEBUFFER> framebuffer_binder(gl_, |
455 dst_framebuffer); | 513 dst_framebuffer); |
456 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, texture); | 514 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, texture); |
457 gl_->FramebufferTexture2D( | 515 gl_->FramebufferTexture2D( |
458 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0); | 516 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) ? | 517 GLenum format = (config == SkBitmap::kRGB_565_Config) ? |
462 GL_RGB : | 518 GL_RGB : |
463 GL_RGBA; | 519 GL_RGBA; |
464 GLenum type = (config == SkBitmap::kRGB_565_Config) ? | 520 GLenum type = (config == SkBitmap::kRGB_565_Config) ? |
465 GL_UNSIGNED_SHORT_5_6_5 : | 521 GL_UNSIGNED_SHORT_5_6_5 : |
466 GL_UNSIGNED_BYTE; | 522 GL_UNSIGNED_BYTE; |
467 gl_->ReadPixels(src_rect.x(), | 523 gl_->ReadPixels(src_rect.x(), |
468 src_rect.y(), | 524 src_rect.y(), |
469 src_rect.width(), | 525 src_rect.width(), |
470 src_rect.height(), | 526 src_rect.height(), |
471 format, | 527 format, |
472 type, | 528 type, |
473 out); | 529 out); |
474 } | 530 } |
475 | 531 |
476 GLuint GLHelper::CopyTextureToImpl::CopyAndScaleTexture( | 532 GLuint GLHelper::CopyTextureToImpl::CopyAndScaleTexture( |
477 GLuint src_texture, | 533 GLuint src_texture, |
478 const gfx::Size& src_size, | 534 const gfx::Size& src_size, |
479 const gfx::Size& dst_size, | 535 const gfx::Size& dst_size, |
480 bool vertically_flip_texture, | 536 bool vertically_flip_texture, |
481 GLHelper::ScalerQuality quality) { | 537 GLHelper::ScalerQuality quality) { |
482 return ScaleTexture(src_texture, | 538 return ScaleTexture(src_texture, |
483 src_size, | 539 src_size, |
484 gfx::Rect(src_size), | 540 gfx::Rect(src_size), |
485 dst_size, | 541 dst_size, |
486 vertically_flip_texture, | 542 vertically_flip_texture, |
487 false, | 543 false, |
488 false, | 544 SkBitmap::kARGB_8888_Config, |
489 quality); | 545 quality); |
490 } | 546 } |
491 | 547 |
492 void GLHelper::CopyTextureToImpl::ReadbackDone(Request* finished_request, | 548 void GLHelper::CopyTextureToImpl::ReadbackDone(Request* finished_request, |
493 int bytes_per_pixel) { | 549 int bytes_per_pixel) { |
494 TRACE_EVENT0("mirror", | 550 TRACE_EVENT0("mirror", |
495 "GLHelper::CopyTextureToImpl::CheckReadbackFramebufferComplete"); | 551 "GLHelper::CopyTextureToImpl::CheckReadbackFramebufferComplete"); |
496 finished_request->done = true; | 552 finished_request->done = true; |
497 | 553 |
498 // We process transfer requests in the order they were received, regardless | 554 // We process transfer requests in the order they were received, regardless |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 support_565_format_(false) {} | 617 support_565_format_(false) {} |
562 | 618 |
563 GLHelper::~GLHelper() {} | 619 GLHelper::~GLHelper() {} |
564 | 620 |
565 void GLHelper::CropScaleReadbackAndCleanTexture( | 621 void GLHelper::CropScaleReadbackAndCleanTexture( |
566 GLuint src_texture, | 622 GLuint src_texture, |
567 const gfx::Size& src_size, | 623 const gfx::Size& src_size, |
568 const gfx::Rect& src_subrect, | 624 const gfx::Rect& src_subrect, |
569 const gfx::Size& dst_size, | 625 const gfx::Size& dst_size, |
570 unsigned char* out, | 626 unsigned char* out, |
571 bool readback_config_rgb565, | 627 const SkBitmap::Config config, |
572 const base::Callback<void(bool)>& callback) { | 628 const base::Callback<void(bool)>& callback) { |
573 InitCopyTextToImpl(); | 629 InitCopyTextToImpl(); |
574 copy_texture_to_impl_->CropScaleReadbackAndCleanTexture( | 630 copy_texture_to_impl_->CropScaleReadbackAndCleanTexture( |
575 src_texture, | 631 src_texture, |
576 src_size, | 632 src_size, |
577 src_subrect, | 633 src_subrect, |
578 dst_size, | 634 dst_size, |
579 out, | 635 out, |
580 readback_config_rgb565, | 636 config, |
581 callback, | 637 callback, |
582 GLHelper::SCALER_QUALITY_FAST); | 638 GLHelper::SCALER_QUALITY_FAST); |
583 } | 639 } |
584 | 640 |
585 void GLHelper::CropScaleReadbackAndCleanMailbox( | 641 void GLHelper::CropScaleReadbackAndCleanMailbox( |
586 const gpu::Mailbox& src_mailbox, | 642 const gpu::Mailbox& src_mailbox, |
587 uint32 sync_point, | 643 uint32 sync_point, |
588 const gfx::Size& src_size, | 644 const gfx::Size& src_size, |
589 const gfx::Rect& src_subrect, | 645 const gfx::Rect& src_subrect, |
590 const gfx::Size& dst_size, | 646 const gfx::Size& dst_size, |
591 unsigned char* out, | 647 unsigned char* out, |
592 bool readback_config_rgb565, | 648 const SkBitmap::Config bitmap_config, |
593 const base::Callback<void(bool)>& callback) { | 649 const base::Callback<void(bool)>& callback) { |
594 GLuint mailbox_texture = ConsumeMailboxToTexture(src_mailbox, sync_point); | 650 GLuint mailbox_texture = ConsumeMailboxToTexture(src_mailbox, sync_point); |
595 CropScaleReadbackAndCleanTexture( | 651 CropScaleReadbackAndCleanTexture( |
596 mailbox_texture, src_size, src_subrect, dst_size, out, | 652 mailbox_texture, src_size, src_subrect, dst_size, out, |
597 readback_config_rgb565, | 653 bitmap_config, |
598 callback); | 654 callback); |
599 gl_->DeleteTextures(1, &mailbox_texture); | 655 gl_->DeleteTextures(1, &mailbox_texture); |
600 } | 656 } |
601 | 657 |
602 void GLHelper::ReadbackTextureSync(GLuint texture, | 658 void GLHelper::ReadbackTextureSync(GLuint texture, |
603 const gfx::Rect& src_rect, | 659 const gfx::Rect& src_rect, |
604 unsigned char* out, | 660 unsigned char* out, |
605 SkBitmap::Config format) { | 661 SkBitmap::Config format) { |
606 InitCopyTextToImpl(); | 662 InitCopyTextToImpl(); |
607 copy_texture_to_impl_->ReadbackTextureSync(texture, src_rect, out, format); | 663 copy_texture_to_impl_->ReadbackTextureSync(texture, src_rect, out, format); |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
819 int size_shift, | 875 int size_shift, |
820 const gfx::Rect& dst_subrect, | 876 const gfx::Rect& dst_subrect, |
821 const base::Callback<void(bool)>& callback) { | 877 const base::Callback<void(bool)>& callback) { |
822 gl_->BindFramebuffer(GL_FRAMEBUFFER, source->framebuffer()); | 878 gl_->BindFramebuffer(GL_FRAMEBUFFER, source->framebuffer()); |
823 size_t offset = target->stride(plane) * (dst_subrect.y() >> size_shift) + | 879 size_t offset = target->stride(plane) * (dst_subrect.y() >> size_shift) + |
824 (dst_subrect.x() >> size_shift); | 880 (dst_subrect.x() >> size_shift); |
825 ReadbackAsync(source->size(), | 881 ReadbackAsync(source->size(), |
826 dst_subrect.width() >> size_shift, | 882 dst_subrect.width() >> size_shift, |
827 target->stride(plane), | 883 target->stride(plane), |
828 target->data(plane) + offset, | 884 target->data(plane) + offset, |
829 false, | 885 SkBitmap::kARGB_8888_Config, |
830 callback); | 886 callback); |
831 } | 887 } |
832 | 888 |
833 const float GLHelper::CopyTextureToImpl::kRGBtoYColorWeights[] = { | 889 const float GLHelper::CopyTextureToImpl::kRGBtoYColorWeights[] = { |
834 0.257f, 0.504f, 0.098f, 0.0625f}; | 890 0.257f, 0.504f, 0.098f, 0.0625f}; |
835 const float GLHelper::CopyTextureToImpl::kRGBtoUColorWeights[] = { | 891 const float GLHelper::CopyTextureToImpl::kRGBtoUColorWeights[] = { |
836 -0.148f, -0.291f, 0.439f, 0.5f}; | 892 -0.148f, -0.291f, 0.439f, 0.5f}; |
837 const float GLHelper::CopyTextureToImpl::kRGBtoVColorWeights[] = { | 893 const float GLHelper::CopyTextureToImpl::kRGBtoVColorWeights[] = { |
838 0.439f, -0.368f, -0.071f, 0.5f}; | 894 0.439f, -0.368f, -0.071f, 0.5f}; |
839 | 895 |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1130 return copy_texture_to_impl_->CreateReadbackPipelineYUV(quality, | 1186 return copy_texture_to_impl_->CreateReadbackPipelineYUV(quality, |
1131 src_size, | 1187 src_size, |
1132 src_subrect, | 1188 src_subrect, |
1133 dst_size, | 1189 dst_size, |
1134 dst_subrect, | 1190 dst_subrect, |
1135 flip_vertically, | 1191 flip_vertically, |
1136 use_mrt); | 1192 use_mrt); |
1137 } | 1193 } |
1138 | 1194 |
1139 } // namespace content | 1195 } // namespace content |
OLD | NEW |