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

Side by Side Diff: content/browser/compositor/delegated_frame_host.cc

Issue 570003002: [Aura] Use GLHelper support to validate format before processing texture (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 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 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 566
567 // static 567 // static
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 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
577 GLHelper* gl_helper = factory->GetGLHelper();
578 if (!gl_helper)
579 return;
580
581 if (!gl_helper->IsReadbackConfigSupported(color_type))
582 return;
576 583
577 scoped_ptr<SkBitmap> bitmap(new SkBitmap); 584 scoped_ptr<SkBitmap> bitmap(new SkBitmap);
578 if (!bitmap->tryAllocPixels(SkImageInfo::Make(dst_size_in_pixel.width(), 585 if (!bitmap->tryAllocPixels(SkImageInfo::Make(dst_size_in_pixel.width(),
579 dst_size_in_pixel.height(), 586 dst_size_in_pixel.height(),
580 color_type, 587 color_type,
581 kOpaque_SkAlphaType))) 588 kOpaque_SkAlphaType)))
582 return; 589 return;
583 590
584 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
585 GLHelper* gl_helper = factory->GetGLHelper();
586 if (!gl_helper)
587 return;
588
589 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock( 591 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock(
590 new SkAutoLockPixels(*bitmap)); 592 new SkAutoLockPixels(*bitmap));
591 uint8* pixels = static_cast<uint8*>(bitmap->getPixels()); 593 uint8* pixels = static_cast<uint8*>(bitmap->getPixels());
592 594
593 cc::TextureMailbox texture_mailbox; 595 cc::TextureMailbox texture_mailbox;
594 scoped_ptr<cc::SingleReleaseCallback> release_callback; 596 scoped_ptr<cc::SingleReleaseCallback> release_callback;
595 result->TakeTexture(&texture_mailbox, &release_callback); 597 result->TakeTexture(&texture_mailbox, &release_callback);
596 DCHECK(texture_mailbox.IsTexture()); 598 DCHECK(texture_mailbox.IsTexture());
597 599
598 ignore_result(scoped_callback_runner.Release()); 600 ignore_result(scoped_callback_runner.Release());
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
976 if (frame_provider_.get()) { 978 if (frame_provider_.get()) {
977 new_layer->SetShowDelegatedContent(frame_provider_.get(), 979 new_layer->SetShowDelegatedContent(frame_provider_.get(),
978 current_frame_size_in_dip_); 980 current_frame_size_in_dip_);
979 } 981 }
980 if (!surface_id_.is_null()) { 982 if (!surface_id_.is_null()) {
981 new_layer->SetShowSurface(surface_id_, current_frame_size_in_dip_); 983 new_layer->SetShowSurface(surface_id_, current_frame_size_in_dip_);
982 } 984 }
983 } 985 }
984 986
985 } // namespace content 987 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698