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

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: Created 5 years, 12 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 593 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 if (gl_helper) 604 if (gl_helper)
605 sync_point = gl_helper->InsertSyncPoint(); 605 sync_point = gl_helper->InsertSyncPoint();
606 } 606 }
607 bool lost_resource = sync_point == 0; 607 bool lost_resource = sync_point == 0;
608 release_callback->Run(sync_point, lost_resource); 608 release_callback->Run(sync_point, lost_resource);
609 609
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
danakj 2015/01/06 16:16:19 just one // is enough
sivag 2015/01/07 09:33:32 Done.
615 bool DelegatedFrameHost::IsReadbackConfigSupported(SkColorType color_type) {
616 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
617 GLHelper* gl_helper = factory->GetGLHelper();
618 if (!gl_helper)
619 return false;
620 if (!gl_helper->IsReadbackConfigSupported(color_type))
621 return false;
622 return true;
623 }
624
614 // static 625 // static
615 void DelegatedFrameHost::PrepareTextureCopyOutputResult( 626 void DelegatedFrameHost::PrepareTextureCopyOutputResult(
616 const gfx::Size& dst_size_in_pixel, 627 const gfx::Size& dst_size_in_pixel,
617 const SkColorType color_type, 628 const SkColorType color_type,
618 ReadbackRequestCallback& callback, 629 ReadbackRequestCallback& callback,
619 scoped_ptr<cc::CopyOutputResult> result) { 630 scoped_ptr<cc::CopyOutputResult> result) {
620 DCHECK(result->HasTexture()); 631 DCHECK(result->HasTexture());
632
633 if (!IsReadbackConfigSupported(color_type))
danakj 2015/01/06 16:16:19 This makes us GetGLHelper() twice, IWBN to only ca
sivag 2015/01/07 09:33:32 Done.
634 callback.Run(SkBitmap(), content::READBACK_FORMAT_NOT_SUPPORTED);
635
621 base::ScopedClosureRunner scoped_callback_runner( 636 base::ScopedClosureRunner scoped_callback_runner(
622 base::Bind(callback, SkBitmap(), content::READBACK_FAILED)); 637 base::Bind(callback, SkBitmap(), content::READBACK_FAILED));
623 638
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); 639 scoped_ptr<SkBitmap> bitmap(new SkBitmap);
628 if (!bitmap->tryAllocPixels(SkImageInfo::Make(dst_size_in_pixel.width(), 640 if (!bitmap->tryAllocPixels(SkImageInfo::Make(dst_size_in_pixel.width(),
629 dst_size_in_pixel.height(), 641 dst_size_in_pixel.height(),
630 color_type, 642 color_type,
631 kOpaque_SkAlphaType))) 643 kOpaque_SkAlphaType)))
632 return; 644 return;
633 645
634 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); 646 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
635 GLHelper* gl_helper = factory->GetGLHelper(); 647 GLHelper* gl_helper = factory->GetGLHelper();
636 if (!gl_helper) 648 if (!gl_helper)
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 cc::SurfaceManager* manager = factory->GetSurfaceManager(); 1045 cc::SurfaceManager* manager = factory->GetSurfaceManager();
1034 new_layer->SetShowSurface( 1046 new_layer->SetShowSurface(
1035 surface_id_, base::Bind(&SatisfyCallback, base::Unretained(manager)), 1047 surface_id_, base::Bind(&SatisfyCallback, base::Unretained(manager)),
1036 base::Bind(&RequireCallback, base::Unretained(manager)), 1048 base::Bind(&RequireCallback, base::Unretained(manager)),
1037 current_surface_size_, current_scale_factor_, 1049 current_surface_size_, current_scale_factor_,
1038 current_frame_size_in_dip_); 1050 current_frame_size_in_dip_);
1039 } 1051 }
1040 } 1052 }
1041 1053
1042 } // namespace content 1054 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/compositor/delegated_frame_host.h ('k') | content/common/gpu/client/gl_helper_readback_support.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698