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

Side by Side Diff: skia/ext/opacity_filter_canvas.cc

Issue 1925433002: Replace SkTLazy with base::Optional (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Include 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 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 "skia/ext/opacity_filter_canvas.h" 5 #include "skia/ext/opacity_filter_canvas.h"
6 #include "third_party/skia/include/core/SkPaint.h" 6 #include "third_party/skia/include/core/SkPaint.h"
7 #include "third_party/skia/include/core/SkTLazy.h"
8 7
9 namespace skia { 8 namespace skia {
10 9
11 OpacityFilterCanvas::OpacityFilterCanvas(SkCanvas* canvas, 10 OpacityFilterCanvas::OpacityFilterCanvas(SkCanvas* canvas,
12 float opacity, 11 float opacity,
13 bool disable_image_filtering) 12 bool disable_image_filtering)
14 : INHERITED(canvas), 13 : INHERITED(canvas),
15 alpha_(SkScalarRoundToInt(opacity * 255)), 14 alpha_(SkScalarRoundToInt(opacity * 255)),
16 disable_image_filtering_(disable_image_filtering) { } 15 disable_image_filtering_(disable_image_filtering) { }
17 16
18 bool OpacityFilterCanvas::onFilter(SkTCopyOnFirstWrite<SkPaint>* paint, Type) co nst { 17 bool OpacityFilterCanvas::onFilter(SkTCopyOnFirstWrite<SkPaint>* paint, Type) co nst {
bungeman-chromium 2016/04/27 18:32:54 Unfortunately (and I hadn't looked at this before)
vmpstr 2016/04/27 18:36:52 I think that it's ok to include SkTLazy.h (especia
vmpstr 2016/04/27 18:39:34 That being said, opacity_filter_canvas.h includes
19 // TODO(fmalita): with the new onFilter() API we could override alpha even 18 // TODO(fmalita): with the new onFilter() API we could override alpha even
20 // when the original paint is null; is this something we should do? 19 // when the original paint is null; is this something we should do?
21 if (*paint) { 20 if (*paint) {
22 if (alpha_ < 255) 21 if (alpha_ < 255)
23 paint->writable()->setAlpha(alpha_); 22 paint->writable()->setAlpha(alpha_);
24 23
25 if (disable_image_filtering_) 24 if (disable_image_filtering_)
26 paint->writable()->setFilterQuality(kNone_SkFilterQuality); 25 paint->writable()->setFilterQuality(kNone_SkFilterQuality);
27 } 26 }
28 27
29 return true; 28 return true;
30 } 29 }
31 30
32 void OpacityFilterCanvas::onDrawPicture(const SkPicture* picture, 31 void OpacityFilterCanvas::onDrawPicture(const SkPicture* picture,
33 const SkMatrix* matrix, 32 const SkMatrix* matrix,
34 const SkPaint* paint) { 33 const SkPaint* paint) {
35 SkTCopyOnFirstWrite<SkPaint> filteredPaint(paint); 34 SkTCopyOnFirstWrite<SkPaint> filteredPaint(paint);
36 if (this->onFilter(&filteredPaint, kPicture_Type)) { 35 if (this->onFilter(&filteredPaint, kPicture_Type)) {
37 // Unfurl pictures in order to filter nested paints. 36 // Unfurl pictures in order to filter nested paints.
38 this->SkCanvas::onDrawPicture(picture, matrix, filteredPaint); 37 this->SkCanvas::onDrawPicture(picture, matrix, filteredPaint);
39 } 38 }
40 } 39 }
41 40
42 } // namespace skia 41 } // namespace skia
OLDNEW
« skia/ext/benchmarking_canvas.cc ('K') | « skia/ext/benchmarking_canvas.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698