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

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

Issue 807853003: Use GLHelper support to validate format before processing texture. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use single glhelper call. Created 5 years, 11 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
« no previous file with comments | « no previous file | content/common/gpu/client/gl_helper_readback_support.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 callback.Run(*bitmap, 610 callback.Run(*bitmap,
611 result ? content::READBACK_SUCCESS : content::READBACK_FAILED); 611 result ? content::READBACK_SUCCESS : content::READBACK_FAILED);
612 } 612 }
613 613
614 // static 614 // static
615 void DelegatedFrameHost::PrepareTextureCopyOutputResult( 615 void DelegatedFrameHost::PrepareTextureCopyOutputResult(
616 const gfx::Size& dst_size_in_pixel, 616 const gfx::Size& dst_size_in_pixel,
617 const SkColorType color_type, 617 const SkColorType color_type,
618 ReadbackRequestCallback& callback, 618 ReadbackRequestCallback& callback,
619 scoped_ptr<cc::CopyOutputResult> result) { 619 scoped_ptr<cc::CopyOutputResult> result) {
620 DCHECK(result->HasTexture()); 620 DCHECK(result->HasTexture());
danakj 2015/01/08 05:56:31 Nit: blank line between dcheck and code
sivag 2015/01/08 11:03:31 Done.
621 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
622 GLHelper* gl_helper = factory->GetGLHelper();
623 if (!gl_helper) {
624 callback.Run(SkBitmap(), content::READBACK_FAILED);
625 return;
626 }
627 if (!gl_helper->IsReadbackConfigSupported(color_type)) {
628 callback.Run(SkBitmap(), content::READBACK_FORMAT_NOT_SUPPORTED);
629 return;
630 }
631
621 base::ScopedClosureRunner scoped_callback_runner( 632 base::ScopedClosureRunner scoped_callback_runner(
danakj 2015/01/08 05:56:31 Maybe move this to the top of the function, and ju
sivag 2015/01/08 11:03:31 Done.
622 base::Bind(callback, SkBitmap(), content::READBACK_FAILED)); 633 base::Bind(callback, SkBitmap(), content::READBACK_FAILED));
623 634
624 // TODO(sikugu): We should be able to validate the format here using
625 // GLHelper::IsReadbackConfigSupported before we processs the result.
626 // See crbug.com/415682.
627 scoped_ptr<SkBitmap> bitmap(new SkBitmap); 635 scoped_ptr<SkBitmap> bitmap(new SkBitmap);
628 if (!bitmap->tryAllocPixels(SkImageInfo::Make(dst_size_in_pixel.width(), 636 if (!bitmap->tryAllocPixels(SkImageInfo::Make(dst_size_in_pixel.width(),
629 dst_size_in_pixel.height(), 637 dst_size_in_pixel.height(),
630 color_type, 638 color_type,
631 kOpaque_SkAlphaType))) 639 kOpaque_SkAlphaType)))
632 return; 640 return;
633 641
634 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
635 GLHelper* gl_helper = factory->GetGLHelper();
636 if (!gl_helper)
637 return;
638
639 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock( 642 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock(
640 new SkAutoLockPixels(*bitmap)); 643 new SkAutoLockPixels(*bitmap));
641 uint8* pixels = static_cast<uint8*>(bitmap->getPixels()); 644 uint8* pixels = static_cast<uint8*>(bitmap->getPixels());
642 645
643 cc::TextureMailbox texture_mailbox; 646 cc::TextureMailbox texture_mailbox;
644 scoped_ptr<cc::SingleReleaseCallback> release_callback; 647 scoped_ptr<cc::SingleReleaseCallback> release_callback;
645 result->TakeTexture(&texture_mailbox, &release_callback); 648 result->TakeTexture(&texture_mailbox, &release_callback);
646 DCHECK(texture_mailbox.IsTexture()); 649 DCHECK(texture_mailbox.IsTexture());
647 650
648 ignore_result(scoped_callback_runner.Release()); 651 ignore_result(scoped_callback_runner.Release());
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 cc::SurfaceManager* manager = factory->GetSurfaceManager(); 1036 cc::SurfaceManager* manager = factory->GetSurfaceManager();
1034 new_layer->SetShowSurface( 1037 new_layer->SetShowSurface(
1035 surface_id_, base::Bind(&SatisfyCallback, base::Unretained(manager)), 1038 surface_id_, base::Bind(&SatisfyCallback, base::Unretained(manager)),
1036 base::Bind(&RequireCallback, base::Unretained(manager)), 1039 base::Bind(&RequireCallback, base::Unretained(manager)),
1037 current_surface_size_, current_scale_factor_, 1040 current_surface_size_, current_scale_factor_,
1038 current_frame_size_in_dip_); 1041 current_frame_size_in_dip_);
1039 } 1042 }
1040 } 1043 }
1041 1044
1042 } // namespace content 1045 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/common/gpu/client/gl_helper_readback_support.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698