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

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

Issue 2094803005: Fix PrepareTextureCopyOutputResult to avoid ScopedCallbackRunner. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_closure_runner
Patch Set: RunAndReset Created 4 years, 5 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 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 71
72 // TODO(siva.gunturi): We should be able to validate the format here using 72 // TODO(siva.gunturi): We should be able to validate the format here using
73 // GLHelper::IsReadbackConfigSupported before we processs the result. 73 // GLHelper::IsReadbackConfigSupported before we processs the result.
74 // See crbug.com/415682 and crbug.com/415131. 74 // See crbug.com/415682 and crbug.com/415131.
75 std::unique_ptr<SkBitmap> bitmap(new SkBitmap); 75 std::unique_ptr<SkBitmap> bitmap(new SkBitmap);
76 if (!bitmap->tryAllocPixels(SkImageInfo::Make( 76 if (!bitmap->tryAllocPixels(SkImageInfo::Make(
77 dst_size_in_pixel.width(), dst_size_in_pixel.height(), color_type, 77 dst_size_in_pixel.width(), dst_size_in_pixel.height(), color_type,
78 kOpaque_SkAlphaType))) { 78 kOpaque_SkAlphaType))) {
79 scoped_callback_runner.Reset(base::Bind( 79 scoped_callback_runner.ReplaceClosure(base::Bind(
no sievers 2016/07/06 19:12:13 Ah so |callback| ended up getting called twice?
Sergey Ulanov 2016/07/06 19:13:32 Correct. Previously Reset() was calling the old ca
80 callback, SkBitmap(), content::READBACK_BITMAP_ALLOCATION_FAILURE)); 80 callback, SkBitmap(), content::READBACK_BITMAP_ALLOCATION_FAILURE));
81 return; 81 return;
82 } 82 }
83 83
84 content::ImageTransportFactory* factory = 84 content::ImageTransportFactory* factory =
85 content::ImageTransportFactory::GetInstance(); 85 content::ImageTransportFactory::GetInstance();
86 display_compositor::GLHelper* gl_helper = factory->GetGLHelper(); 86 display_compositor::GLHelper* gl_helper = factory->GetGLHelper();
87 if (!gl_helper) 87 if (!gl_helper)
88 return; 88 return;
89 89
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 return; 201 return;
202 } 202 }
203 203
204 DCHECK(result->HasBitmap()); 204 DCHECK(result->HasBitmap());
205 // Software path 205 // Software path
206 PrepareBitmapCopyOutputResult(output_size_in_pixel, color_type, callback, 206 PrepareBitmapCopyOutputResult(output_size_in_pixel, color_type, callback,
207 std::move(result)); 207 std::move(result));
208 } 208 }
209 209
210 } // namespace content 210 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698