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

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

Issue 1829093002: Use sk_sp-based APIs for SkColorFilter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Respond to reviews Created 4 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/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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 // Paint |scaledBitmap| to alpha-only |grayscale_bitmap|. 143 // Paint |scaledBitmap| to alpha-only |grayscale_bitmap|.
144 SkBitmap grayscale_bitmap; 144 SkBitmap grayscale_bitmap;
145 bool success = grayscale_bitmap.tryAllocPixels( 145 bool success = grayscale_bitmap.tryAllocPixels(
146 SkImageInfo::MakeA8(scaled_bitmap.width(), scaled_bitmap.height())); 146 SkImageInfo::MakeA8(scaled_bitmap.width(), scaled_bitmap.height()));
147 if (!success) { 147 if (!success) {
148 callback.Run(SkBitmap(), content::READBACK_BITMAP_ALLOCATION_FAILURE); 148 callback.Run(SkBitmap(), content::READBACK_BITMAP_ALLOCATION_FAILURE);
149 return; 149 return;
150 } 150 }
151 SkCanvas canvas(grayscale_bitmap); 151 SkCanvas canvas(grayscale_bitmap);
152 SkPaint paint; 152 SkPaint paint;
153 skia::RefPtr<SkColorFilter> filter = 153 paint.setColorFilter(SkLumaColorFilter::Make());
154 skia::AdoptRef(SkLumaColorFilter::Create());
155 paint.setColorFilter(filter.get());
156 canvas.drawBitmap(scaled_bitmap, SkIntToScalar(0), SkIntToScalar(0), &paint); 154 canvas.drawBitmap(scaled_bitmap, SkIntToScalar(0), SkIntToScalar(0), &paint);
157 callback.Run(grayscale_bitmap, content::READBACK_SUCCESS); 155 callback.Run(grayscale_bitmap, content::READBACK_SUCCESS);
158 } 156 }
159 157
160 } // namespace 158 } // namespace
161 159
162 namespace content { 160 namespace content {
163 161
164 scoped_ptr<cc::SurfaceIdAllocator> CreateSurfaceIdAllocator() { 162 scoped_ptr<cc::SurfaceIdAllocator> CreateSurfaceIdAllocator() {
165 #if defined(OS_ANDROID) 163 #if defined(OS_ANDROID)
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 return; 200 return;
203 } 201 }
204 202
205 DCHECK(result->HasBitmap()); 203 DCHECK(result->HasBitmap());
206 // Software path 204 // Software path
207 PrepareBitmapCopyOutputResult(output_size_in_pixel, color_type, callback, 205 PrepareBitmapCopyOutputResult(output_size_in_pixel, color_type, callback,
208 std::move(result)); 206 std::move(result));
209 } 207 }
210 208
211 } // namespace content 209 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698