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

Side by Side Diff: ui/views/painter.cc

Issue 291843003: use simpler gradient factories (in prep for removing SkUnitMapper param) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « ui/views/controls/progress_bar.cc ('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/views/painter.h" 5 #include "ui/views/painter.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "third_party/skia/include/effects/SkGradientShader.h" 9 #include "third_party/skia/include/effects/SkGradientShader.h"
10 #include "ui/base/resource/resource_bundle.h" 10 #include "ui/base/resource/resource_bundle.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 void GradientPainter::Paint(gfx::Canvas* canvas, const gfx::Size& size) { 144 void GradientPainter::Paint(gfx::Canvas* canvas, const gfx::Size& size) {
145 SkPaint paint; 145 SkPaint paint;
146 SkPoint p[2]; 146 SkPoint p[2];
147 p[0].iset(0, 0); 147 p[0].iset(0, 0);
148 if (horizontal_) 148 if (horizontal_)
149 p[1].iset(size.width(), 0); 149 p[1].iset(size.width(), 0);
150 else 150 else
151 p[1].iset(0, size.height()); 151 p[1].iset(0, size.height());
152 152
153 skia::RefPtr<SkShader> s = skia::AdoptRef(SkGradientShader::CreateLinear( 153 skia::RefPtr<SkShader> s = skia::AdoptRef(SkGradientShader::CreateLinear(
154 p, colors_.get(), pos_.get(), count_, SkShader::kClamp_TileMode, NULL)); 154 p, colors_.get(), pos_.get(), count_, SkShader::kClamp_TileMode));
155 paint.setStyle(SkPaint::kFill_Style); 155 paint.setStyle(SkPaint::kFill_Style);
156 paint.setShader(s.get()); 156 paint.setShader(s.get());
157 157
158 canvas->sk_canvas()->drawRectCoords(SkIntToScalar(0), SkIntToScalar(0), 158 canvas->sk_canvas()->drawRectCoords(SkIntToScalar(0), SkIntToScalar(0),
159 SkIntToScalar(size.width()), 159 SkIntToScalar(size.width()),
160 SkIntToScalar(size.height()), paint); 160 SkIntToScalar(size.height()), paint);
161 } 161 }
162 162
163 // ImagePainter --------------------------------------------------------------- 163 // ImagePainter ---------------------------------------------------------------
164 164
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 canvas->DrawImageInt(*images_[LEFT], 0, 0); 314 canvas->DrawImageInt(*images_[LEFT], 0, 0);
315 canvas->DrawImageInt(*images_[RIGHT], size.width() - images_[RIGHT]->width(), 315 canvas->DrawImageInt(*images_[RIGHT], size.width() - images_[RIGHT]->width(),
316 0); 316 0);
317 canvas->TileImageInt( 317 canvas->TileImageInt(
318 *images_[CENTER], images_[LEFT]->width(), 0, 318 *images_[CENTER], images_[LEFT]->width(), 0,
319 size.width() - images_[LEFT]->width() - images_[RIGHT]->width(), 319 size.width() - images_[LEFT]->width() - images_[RIGHT]->width(),
320 images_[LEFT]->height()); 320 images_[LEFT]->height());
321 } 321 }
322 322
323 } // namespace views 323 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/progress_bar.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698