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

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

Issue 2823003002: SkBitmap and SkPixelRef no longer need lock/unlock (Closed)
Patch Set: win fix after rebase Created 3 years, 8 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/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 15 matching lines...) Expand all
26 #include "ui/compositor/compositor.h" // nogncheck 26 #include "ui/compositor/compositor.h" // nogncheck
27 #endif 27 #endif
28 28
29 namespace { 29 namespace {
30 30
31 #if !defined(OS_ANDROID) || defined(USE_AURA) 31 #if !defined(OS_ANDROID) || defined(USE_AURA)
32 void CopyFromCompositingSurfaceFinished( 32 void CopyFromCompositingSurfaceFinished(
33 const content::ReadbackRequestCallback& callback, 33 const content::ReadbackRequestCallback& callback,
34 std::unique_ptr<cc::SingleReleaseCallback> release_callback, 34 std::unique_ptr<cc::SingleReleaseCallback> release_callback,
35 std::unique_ptr<SkBitmap> bitmap, 35 std::unique_ptr<SkBitmap> bitmap,
36 std::unique_ptr<SkAutoLockPixels> bitmap_pixels_lock,
37 bool result) { 36 bool result) {
38 bitmap_pixels_lock.reset();
39
40 gpu::SyncToken sync_token; 37 gpu::SyncToken sync_token;
41 if (result) { 38 if (result) {
42 display_compositor::GLHelper* gl_helper = 39 display_compositor::GLHelper* gl_helper =
43 content::ImageTransportFactory::GetInstance()->GetGLHelper(); 40 content::ImageTransportFactory::GetInstance()->GetGLHelper();
44 if (gl_helper) 41 if (gl_helper)
45 gl_helper->GenerateSyncToken(&sync_token); 42 gl_helper->GenerateSyncToken(&sync_token);
46 } 43 }
47 const bool lost_resource = !sync_token.HasData(); 44 const bool lost_resource = !sync_token.HasData();
48 release_callback->Run(sync_token, lost_resource); 45 release_callback->Run(sync_token, lost_resource);
49 46
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 callback, SkBitmap(), content::READBACK_BITMAP_ALLOCATION_FAILURE)); 78 callback, SkBitmap(), content::READBACK_BITMAP_ALLOCATION_FAILURE));
82 return; 79 return;
83 } 80 }
84 81
85 content::ImageTransportFactory* factory = 82 content::ImageTransportFactory* factory =
86 content::ImageTransportFactory::GetInstance(); 83 content::ImageTransportFactory::GetInstance();
87 display_compositor::GLHelper* gl_helper = factory->GetGLHelper(); 84 display_compositor::GLHelper* gl_helper = factory->GetGLHelper();
88 if (!gl_helper) 85 if (!gl_helper)
89 return; 86 return;
90 87
91 std::unique_ptr<SkAutoLockPixels> bitmap_pixels_lock(
92 new SkAutoLockPixels(*bitmap));
93 uint8_t* pixels = static_cast<uint8_t*>(bitmap->getPixels()); 88 uint8_t* pixels = static_cast<uint8_t*>(bitmap->getPixels());
94 89
95 cc::TextureMailbox texture_mailbox; 90 cc::TextureMailbox texture_mailbox;
96 std::unique_ptr<cc::SingleReleaseCallback> release_callback; 91 std::unique_ptr<cc::SingleReleaseCallback> release_callback;
97 result->TakeTexture(&texture_mailbox, &release_callback); 92 result->TakeTexture(&texture_mailbox, &release_callback);
98 DCHECK(texture_mailbox.IsTexture()); 93 DCHECK(texture_mailbox.IsTexture());
99 94
100 ignore_result(scoped_callback_runner.Release()); 95 ignore_result(scoped_callback_runner.Release());
101 96
102 gl_helper->CropScaleReadbackAndCleanMailbox( 97 gl_helper->CropScaleReadbackAndCleanMailbox(
103 texture_mailbox.mailbox(), texture_mailbox.sync_token(), result->size(), 98 texture_mailbox.mailbox(), texture_mailbox.sync_token(), result->size(),
104 gfx::Rect(result->size()), dst_size_in_pixel, pixels, color_type, 99 gfx::Rect(result->size()), dst_size_in_pixel, pixels, color_type,
105 base::Bind(&CopyFromCompositingSurfaceFinished, callback, 100 base::Bind(&CopyFromCompositingSurfaceFinished, callback,
106 base::Passed(&release_callback), base::Passed(&bitmap), 101 base::Passed(&release_callback), base::Passed(&bitmap)),
107 base::Passed(&bitmap_pixels_lock)),
108 display_compositor::GLHelper::SCALER_QUALITY_GOOD); 102 display_compositor::GLHelper::SCALER_QUALITY_GOOD);
109 #endif 103 #endif
110 } 104 }
111 105
112 void PrepareBitmapCopyOutputResult( 106 void PrepareBitmapCopyOutputResult(
113 const gfx::Size& dst_size_in_pixel, 107 const gfx::Size& dst_size_in_pixel,
114 const SkColorType preferred_color_type, 108 const SkColorType preferred_color_type,
115 const content::ReadbackRequestCallback& callback, 109 const content::ReadbackRequestCallback& callback,
116 std::unique_ptr<cc::CopyOutputResult> result) { 110 std::unique_ptr<cc::CopyOutputResult> result) {
117 SkColorType color_type = preferred_color_type; 111 SkColorType color_type = preferred_color_type;
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 return; 207 return;
214 } 208 }
215 209
216 DCHECK(result->HasBitmap()); 210 DCHECK(result->HasBitmap());
217 // Software path 211 // Software path
218 PrepareBitmapCopyOutputResult(output_size_in_pixel, color_type, callback, 212 PrepareBitmapCopyOutputResult(output_size_in_pixel, color_type, callback,
219 std::move(result)); 213 std::move(result));
220 } 214 }
221 215
222 } // namespace content 216 } // namespace content
OLDNEW
« no previous file with comments | « components/wallpaper/wallpaper_resizer_unittest.cc ('k') | content/browser/devtools/devtools_frame_trace_recorder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698