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

Side by Side Diff: content/browser/compositor/surface_utils.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 4 years, 6 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 | « components/display_compositor/gl_helper_readback_support.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/surface_utils.h" 5 #include "content/browser/compositor/surface_utils.h"
6 6
7 #include "base/callback_helpers.h" 7 #include "base/callback_helpers.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "cc/output/copy_output_result.h" 10 #include "cc/output/copy_output_result.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 const content::ReadbackRequestCallback& callback, 61 const content::ReadbackRequestCallback& callback,
62 std::unique_ptr<cc::CopyOutputResult> result) { 62 std::unique_ptr<cc::CopyOutputResult> result) {
63 #if defined(OS_ANDROID) && !defined(USE_AURA) 63 #if defined(OS_ANDROID) && !defined(USE_AURA)
64 // TODO(wjmaclean): See if there's an equivalent pathway for Android and 64 // TODO(wjmaclean): See if there's an equivalent pathway for Android and
65 // implement it here. 65 // implement it here.
66 callback.Run(SkBitmap(), content::READBACK_FAILED); 66 callback.Run(SkBitmap(), content::READBACK_FAILED);
67 #else 67 #else
68 DCHECK(result->HasTexture()); 68 DCHECK(result->HasTexture());
69 base::ScopedClosureRunner scoped_callback_runner( 69 base::ScopedClosureRunner scoped_callback_runner(
70 base::Bind(callback, SkBitmap(), content::READBACK_FAILED)); 70 base::Bind(callback, SkBitmap(), content::READBACK_FAILED));
71 content::ImageTransportFactory* factory =
72 content::ImageTransportFactory::GetInstance();
73 display_compositor::GLHelper* gl_helper = factory->GetGLHelper();
74 if (!gl_helper)
75 return;
76 if(!gl_helper->IsReadbackConfigSupported(color_type))
77 return;
71 78
72 // TODO(siva.gunturi): We should be able to validate the format here using
73 // GLHelper::IsReadbackConfigSupported before we processs the result.
74 // See crbug.com/415682 and crbug.com/415131.
75 std::unique_ptr<SkBitmap> bitmap(new SkBitmap); 79 std::unique_ptr<SkBitmap> bitmap(new SkBitmap);
76 if (!bitmap->tryAllocPixels(SkImageInfo::Make( 80 if (!bitmap->tryAllocPixels(SkImageInfo::Make(
77 dst_size_in_pixel.width(), dst_size_in_pixel.height(), color_type, 81 dst_size_in_pixel.width(), dst_size_in_pixel.height(), color_type,
78 kOpaque_SkAlphaType))) { 82 kOpaque_SkAlphaType))) {
79 scoped_callback_runner.Reset(base::Bind( 83 scoped_callback_runner.Reset(base::Bind(
80 callback, SkBitmap(), content::READBACK_BITMAP_ALLOCATION_FAILURE)); 84 callback, SkBitmap(), content::READBACK_BITMAP_ALLOCATION_FAILURE));
81 return; 85 return;
82 } 86 }
83 87
84 content::ImageTransportFactory* factory =
85 content::ImageTransportFactory::GetInstance();
86 display_compositor::GLHelper* gl_helper = factory->GetGLHelper();
87 if (!gl_helper)
88 return;
89
90 std::unique_ptr<SkAutoLockPixels> bitmap_pixels_lock( 88 std::unique_ptr<SkAutoLockPixels> bitmap_pixels_lock(
91 new SkAutoLockPixels(*bitmap)); 89 new SkAutoLockPixels(*bitmap));
92 uint8_t* pixels = static_cast<uint8_t*>(bitmap->getPixels()); 90 uint8_t* pixels = static_cast<uint8_t*>(bitmap->getPixels());
93 91
94 cc::TextureMailbox texture_mailbox; 92 cc::TextureMailbox texture_mailbox;
95 std::unique_ptr<cc::SingleReleaseCallback> release_callback; 93 std::unique_ptr<cc::SingleReleaseCallback> release_callback;
96 result->TakeTexture(&texture_mailbox, &release_callback); 94 result->TakeTexture(&texture_mailbox, &release_callback);
97 DCHECK(texture_mailbox.IsTexture()); 95 DCHECK(texture_mailbox.IsTexture());
98 96
99 ignore_result(scoped_callback_runner.Release()); 97 ignore_result(scoped_callback_runner.Release());
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 return; 197 return;
200 } 198 }
201 199
202 DCHECK(result->HasBitmap()); 200 DCHECK(result->HasBitmap());
203 // Software path 201 // Software path
204 PrepareBitmapCopyOutputResult(output_size_in_pixel, color_type, callback, 202 PrepareBitmapCopyOutputResult(output_size_in_pixel, color_type, callback,
205 std::move(result)); 203 std::move(result));
206 } 204 }
207 205
208 } // namespace content 206 } // namespace content
OLDNEW
« no previous file with comments | « components/display_compositor/gl_helper_readback_support.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698