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

Side by Side Diff: ui/gfx/skbitmap_operations.cc

Issue 1939143002: Remove all uses of skia::RefPtr and stale includes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 7 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/gfx/skbitmap_operations.h" 5 #include "ui/gfx/skbitmap_operations.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <string.h> 9 #include <string.h>
10 #include <algorithm> 10 #include <algorithm>
11 11
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "skia/ext/refptr.h"
14 #include "third_party/skia/include/core/SkBitmap.h" 13 #include "third_party/skia/include/core/SkBitmap.h"
15 #include "third_party/skia/include/core/SkCanvas.h" 14 #include "third_party/skia/include/core/SkCanvas.h"
16 #include "third_party/skia/include/core/SkColorFilter.h" 15 #include "third_party/skia/include/core/SkColorFilter.h"
17 #include "third_party/skia/include/core/SkColorPriv.h" 16 #include "third_party/skia/include/core/SkColorPriv.h"
17 #include "third_party/skia/include/core/SkRefCnt.h"
f(malita) 2016/05/04 15:49:58 Nit: I don't think we handle sk_sps explicitly in
tomhudson 2016/05/04 16:51:54 Done. (At one intermediate stage we had sk_sp<SkIm
18 #include "third_party/skia/include/core/SkUnPreMultiply.h" 18 #include "third_party/skia/include/core/SkUnPreMultiply.h"
19 #include "third_party/skia/include/effects/SkBlurImageFilter.h" 19 #include "third_party/skia/include/effects/SkBlurImageFilter.h"
20 #include "ui/gfx/geometry/insets.h" 20 #include "ui/gfx/geometry/insets.h"
21 #include "ui/gfx/geometry/point.h" 21 #include "ui/gfx/geometry/point.h"
22 #include "ui/gfx/geometry/size.h" 22 #include "ui/gfx/geometry/size.h"
23 23
24 // static 24 // static
25 SkBitmap SkBitmapOperations::CreateInvertedBitmap(const SkBitmap& image) { 25 SkBitmap SkBitmapOperations::CreateInvertedBitmap(const SkBitmap& image) {
26 DCHECK(image.colorType() == kN32_SkColorType); 26 DCHECK(image.colorType() == kN32_SkColorType);
27 27
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 733
734 SkPaint paint; 734 SkPaint paint;
735 for (size_t i = 0; i < shadows.size(); ++i) { 735 for (size_t i = 0; i < shadows.size(); ++i) {
736 const gfx::ShadowValue& shadow = shadows[i]; 736 const gfx::ShadowValue& shadow = shadows[i];
737 SkBitmap shadow_image = SkBitmapOperations::CreateColorMask(bitmap, 737 SkBitmap shadow_image = SkBitmapOperations::CreateColorMask(bitmap,
738 shadow.color()); 738 shadow.color());
739 739
740 // The blur is halved to produce a shadow that correctly fits within the 740 // The blur is halved to produce a shadow that correctly fits within the
741 // |shadow_margin|. 741 // |shadow_margin|.
742 SkScalar sigma = SkDoubleToScalar(shadow.blur() / 2); 742 SkScalar sigma = SkDoubleToScalar(shadow.blur() / 2);
743 skia::RefPtr<SkImageFilter> filter = 743 paint.setImageFilter(SkBlurImageFilter::Make(sigma, sigma, nullptr));
744 skia::AdoptRef(SkBlurImageFilter::Create(sigma, sigma));
745 paint.setImageFilter(filter.get());
746 744
747 canvas.saveLayer(0, &paint); 745 canvas.saveLayer(0, &paint);
748 canvas.drawBitmap(shadow_image, 746 canvas.drawBitmap(shadow_image,
749 SkIntToScalar(shadow.x()), 747 SkIntToScalar(shadow.x()),
750 SkIntToScalar(shadow.y())); 748 SkIntToScalar(shadow.y()));
751 canvas.restore(); 749 canvas.restore();
752 } 750 }
753 751
754 canvas.drawBitmap(bitmap, SkIntToScalar(0), SkIntToScalar(0)); 752 canvas.drawBitmap(bitmap, SkIntToScalar(0), SkIntToScalar(0));
755 return image_with_shadow; 753 return image_with_shadow;
(...skipping 29 matching lines...) Expand all
785 canvas.translate(SkFloatToScalar(result.width() * 0.5f), 783 canvas.translate(SkFloatToScalar(result.width() * 0.5f),
786 SkFloatToScalar(result.height() * 0.5f)); 784 SkFloatToScalar(result.height() * 0.5f));
787 canvas.rotate(angle); 785 canvas.rotate(angle);
788 canvas.translate(-SkFloatToScalar(source.width() * 0.5f), 786 canvas.translate(-SkFloatToScalar(source.width() * 0.5f),
789 -SkFloatToScalar(source.height() * 0.5f)); 787 -SkFloatToScalar(source.height() * 0.5f));
790 canvas.drawBitmap(source, 0, 0); 788 canvas.drawBitmap(source, 0, 0);
791 canvas.flush(); 789 canvas.flush();
792 790
793 return result; 791 return result;
794 } 792 }
OLDNEW
« ui/gfx/platform_font_win.cc ('K') | « ui/gfx/scoped_sk_region.h ('k') | ui/gfx/skia_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698