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

Side by Side Diff: src/views/SkWidgets.cpp

Issue 173633003: Factory methods for heap-allocated SkMaskFilter objects. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add SkTableMaskFilter::Create(table) and remove deprecated SkEmbossMaskFilter constructor. Created 6 years, 10 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 | « src/effects/SkEmbossMaskFilter.cpp ('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 1
2 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "SkWidget.h" 8 #include "SkWidget.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkKey.h" 10 #include "SkKey.h"
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 if (state == SkButtonWidget::kOn_State) 227 if (state == SkButtonWidget::kOn_State)
228 { 228 {
229 SkASSERT(focused); 229 SkASSERT(focused);
230 return "enabled-pressed"; 230 return "enabled-pressed";
231 } 231 }
232 if (focused) 232 if (focused)
233 return "enabled-focused"; 233 return "enabled-focused";
234 return "enabled"; 234 return "enabled";
235 } 235 }
236 236
237 #include "SkBlurMask.h"
237 #include "SkBlurMaskFilter.h" 238 #include "SkBlurMaskFilter.h"
238 #include "SkEmbossMaskFilter.h" 239 #include "SkEmbossMaskFilter.h"
239 240
240 static void create_emboss(SkPaint* paint, SkScalar radius, bool focus, bool pres sed) 241 static void create_emboss(SkPaint* paint, SkScalar radius, bool focus, bool pres sed)
241 { 242 {
242 SkEmbossMaskFilter::Light light; 243 SkEmbossMaskFilter::Light light;
243 244
244 light.fDirection[0] = SK_Scalar1/2; 245 light.fDirection[0] = SK_Scalar1/2;
245 light.fDirection[1] = SK_Scalar1/2; 246 light.fDirection[1] = SK_Scalar1/2;
246 light.fDirection[2] = SK_Scalar1/3; 247 light.fDirection[2] = SK_Scalar1/3;
247 light.fAmbient = 0x48; 248 light.fAmbient = 0x48;
248 light.fSpecular = 0x80; 249 light.fSpecular = 0x80;
249 250
250 if (pressed) 251 if (pressed)
251 { 252 {
252 light.fDirection[0] = -light.fDirection[0]; 253 light.fDirection[0] = -light.fDirection[0];
253 light.fDirection[1] = -light.fDirection[1]; 254 light.fDirection[1] = -light.fDirection[1];
254 } 255 }
255 if (focus) 256 if (focus)
256 light.fDirection[2] += SK_Scalar1/4; 257 light.fDirection[2] += SK_Scalar1/4;
257 258
258 paint->setMaskFilter(new SkEmbossMaskFilter(light, radius))->unref(); 259 SkScalar sigma = SkBlurMask::ConvertRadiusToSigma(radius);
260 paint->setMaskFilter(new SkEmbossMaskFilter(sigma, light))->unref();
259 } 261 }
260 262
261 void SkPushButtonWidget::onDraw(SkCanvas* canvas) 263 void SkPushButtonWidget::onDraw(SkCanvas* canvas)
262 { 264 {
263 this->INHERITED::onDraw(canvas); 265 this->INHERITED::onDraw(canvas);
264 266
265 SkString label; 267 SkString label;
266 this->getLabel(&label); 268 this->getLabel(&label);
267 269
268 SkAnimator* anim = get_skin_animator(kPushButton_SkinType); 270 SkAnimator* anim = get_skin_animator(kPushButton_SkinType);
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 void SkBitmapView::onInflate(const SkDOM& dom, const SkDOM::Node* node) 553 void SkBitmapView::onInflate(const SkDOM& dom, const SkDOM::Node* node)
552 { 554 {
553 this->INHERITED::onInflate(dom, node); 555 this->INHERITED::onInflate(dom, node);
554 556
555 const char* src = dom.findAttr(node, "src"); 557 const char* src = dom.findAttr(node, "src");
556 if (src) 558 if (src)
557 (void)this->loadBitmapFromFile(src); 559 (void)this->loadBitmapFromFile(src);
558 } 560 }
559 561
560 #endif 562 #endif
OLDNEW
« no previous file with comments | « src/effects/SkEmbossMaskFilter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698