OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/browser/compositor/delegated_frame_host.h" | 5 #include "content/browser/compositor/delegated_frame_host.h" |
6 | 6 |
7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "cc/output/compositor_frame.h" | 9 #include "cc/output/compositor_frame.h" |
10 #include "cc/output/compositor_frame_ack.h" | 10 #include "cc/output/compositor_frame_ack.h" |
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 void DelegatedFrameHost::PrepareTextureCopyOutputResult( | 568 void DelegatedFrameHost::PrepareTextureCopyOutputResult( |
569 const gfx::Size& dst_size_in_pixel, | 569 const gfx::Size& dst_size_in_pixel, |
570 const SkColorType color_type, | 570 const SkColorType color_type, |
571 const base::Callback<void(bool, const SkBitmap&)>& callback, | 571 const base::Callback<void(bool, const SkBitmap&)>& callback, |
572 scoped_ptr<cc::CopyOutputResult> result) { | 572 scoped_ptr<cc::CopyOutputResult> result) { |
573 DCHECK(result->HasTexture()); | 573 DCHECK(result->HasTexture()); |
574 base::ScopedClosureRunner scoped_callback_runner( | 574 base::ScopedClosureRunner scoped_callback_runner( |
575 base::Bind(callback, false, SkBitmap())); | 575 base::Bind(callback, false, SkBitmap())); |
576 | 576 |
577 scoped_ptr<SkBitmap> bitmap(new SkBitmap); | 577 scoped_ptr<SkBitmap> bitmap(new SkBitmap); |
578 if (!bitmap->allocPixels(SkImageInfo::Make(dst_size_in_pixel.width(), | 578 if (!bitmap->tryAllocPixels(SkImageInfo::Make(dst_size_in_pixel.width(), |
579 dst_size_in_pixel.height(), | 579 dst_size_in_pixel.height(), |
580 color_type, | 580 color_type, |
581 kOpaque_SkAlphaType))) | 581 kOpaque_SkAlphaType))) |
582 return; | 582 return; |
583 | 583 |
584 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 584 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
585 GLHelper* gl_helper = factory->GetGLHelper(); | 585 GLHelper* gl_helper = factory->GetGLHelper(); |
586 if (!gl_helper) | 586 if (!gl_helper) |
587 return; | 587 return; |
588 | 588 |
589 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock( | 589 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock( |
590 new SkAutoLockPixels(*bitmap)); | 590 new SkAutoLockPixels(*bitmap)); |
591 uint8* pixels = static_cast<uint8*>(bitmap->getPixels()); | 591 uint8* pixels = static_cast<uint8*>(bitmap->getPixels()); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 DCHECK_EQ(scaled_bitmap.colorType(), kN32_SkColorType); | 642 DCHECK_EQ(scaled_bitmap.colorType(), kN32_SkColorType); |
643 callback.Run(true, scaled_bitmap); | 643 callback.Run(true, scaled_bitmap); |
644 return; | 644 return; |
645 } | 645 } |
646 DCHECK_EQ(color_type, kAlpha_8_SkColorType); | 646 DCHECK_EQ(color_type, kAlpha_8_SkColorType); |
647 // The software path currently always returns N32 bitmap regardless of the | 647 // The software path currently always returns N32 bitmap regardless of the |
648 // |color_type| we ask for. | 648 // |color_type| we ask for. |
649 DCHECK_EQ(scaled_bitmap.colorType(), kN32_SkColorType); | 649 DCHECK_EQ(scaled_bitmap.colorType(), kN32_SkColorType); |
650 // Paint |scaledBitmap| to alpha-only |grayscale_bitmap|. | 650 // Paint |scaledBitmap| to alpha-only |grayscale_bitmap|. |
651 SkBitmap grayscale_bitmap; | 651 SkBitmap grayscale_bitmap; |
652 bool success = grayscale_bitmap.allocPixels( | 652 bool success = grayscale_bitmap.tryAllocPixels( |
653 SkImageInfo::MakeA8(scaled_bitmap.width(), scaled_bitmap.height())); | 653 SkImageInfo::MakeA8(scaled_bitmap.width(), scaled_bitmap.height())); |
654 if (!success) { | 654 if (!success) { |
655 callback.Run(false, SkBitmap()); | 655 callback.Run(false, SkBitmap()); |
656 return; | 656 return; |
657 } | 657 } |
658 SkCanvas canvas(grayscale_bitmap); | 658 SkCanvas canvas(grayscale_bitmap); |
659 SkPaint paint; | 659 SkPaint paint; |
660 skia::RefPtr<SkColorFilter> filter = | 660 skia::RefPtr<SkColorFilter> filter = |
661 skia::AdoptRef(SkLumaColorFilter::Create()); | 661 skia::AdoptRef(SkLumaColorFilter::Create()); |
662 paint.setColorFilter(filter.get()); | 662 paint.setColorFilter(filter.get()); |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
976 if (frame_provider_.get()) { | 976 if (frame_provider_.get()) { |
977 new_layer->SetShowDelegatedContent(frame_provider_.get(), | 977 new_layer->SetShowDelegatedContent(frame_provider_.get(), |
978 current_frame_size_in_dip_); | 978 current_frame_size_in_dip_); |
979 } | 979 } |
980 if (!surface_id_.is_null()) { | 980 if (!surface_id_.is_null()) { |
981 new_layer->SetShowSurface(surface_id_, current_frame_size_in_dip_); | 981 new_layer->SetShowSurface(surface_id_, current_frame_size_in_dip_); |
982 } | 982 } |
983 } | 983 } |
984 | 984 |
985 } // namespace content | 985 } // namespace content |
OLD | NEW |