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

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

Issue 2015083004: Use initialized canvas to create network icons. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
Patch Set: Created 4 years, 6 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
« no previous file with comments | « ui/gfx/canvas.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/canvas.h" 5 #include "ui/gfx/canvas.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
(...skipping 24 matching lines...) Expand all
35 // skia::PlatformCanvas instances are initialized to 0 by Cairo, but 35 // skia::PlatformCanvas instances are initialized to 0 by Cairo, but
36 // uninitialized on other platforms. 36 // uninitialized on other platforms.
37 if (!is_opaque) 37 if (!is_opaque)
38 canvas_->clear(SkColorSetARGB(0, 0, 0, 0)); 38 canvas_->clear(SkColorSetARGB(0, 0, 0, 0));
39 #endif 39 #endif
40 40
41 SkScalar scale_scalar = SkFloatToScalar(image_scale); 41 SkScalar scale_scalar = SkFloatToScalar(image_scale);
42 canvas_->scale(scale_scalar, scale_scalar); 42 canvas_->scale(scale_scalar, scale_scalar);
43 } 43 }
44 44
45 Canvas::Canvas(const ImageSkiaRep& image_rep, bool is_opaque)
46 : image_scale_(image_rep.scale()),
47 canvas_(sk_sp<SkCanvas>(
48 skia::CreatePlatformCanvas(image_rep.pixel_width(),
49 image_rep.pixel_height(),
50 is_opaque))) {
51 SkScalar scale_scalar = SkFloatToScalar(image_scale_);
52 canvas_->scale(scale_scalar, scale_scalar);
53 DrawImageInt(ImageSkia(image_rep), 0, 0);
54 }
55
56 Canvas::Canvas() 45 Canvas::Canvas()
57 : image_scale_(1.f), 46 : image_scale_(1.f),
58 canvas_(sk_sp<SkCanvas>(skia::CreatePlatformCanvas(0, 0, false))) {} 47 canvas_(sk_sp<SkCanvas>(skia::CreatePlatformCanvas(0, 0, false))) {}
59 48
60 Canvas::Canvas(sk_sp<SkCanvas> canvas, float image_scale) 49 Canvas::Canvas(sk_sp<SkCanvas> canvas, float image_scale)
61 : image_scale_(image_scale), canvas_(std::move(canvas)) { 50 : image_scale_(image_scale), canvas_(std::move(canvas)) {
62 DCHECK(canvas_); 51 DCHECK(canvas_);
63 } 52 }
64 53
65 Canvas::~Canvas() { 54 Canvas::~Canvas() {
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 p.setFilterQuality(filter ? kLow_SkFilterQuality : kNone_SkFilterQuality); 548 p.setFilterQuality(filter ? kLow_SkFilterQuality : kNone_SkFilterQuality);
560 p.setShader(CreateImageRepShaderForScale( 549 p.setShader(CreateImageRepShaderForScale(
561 image_rep, SkShader::kRepeat_TileMode, shader_scale, 550 image_rep, SkShader::kRepeat_TileMode, shader_scale,
562 remove_image_scale ? image_rep.scale() : 1.f)); 551 remove_image_scale ? image_rep.scale() : 1.f));
563 552
564 // The rect will be filled by the bitmap. 553 // The rect will be filled by the bitmap.
565 canvas_->drawRect(dest_rect, p); 554 canvas_->drawRect(dest_rect, p);
566 } 555 }
567 556
568 } // namespace gfx 557 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/canvas.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698