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

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

Issue 9544001: ui: Let skia do the conversion work for us by using the integer version of set() function. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: peter review Created 8 years, 9 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/gfx/canvas_skia.cc ('k') | ui/gfx/native_theme_base.cc » ('j') | 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) 2011 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/native_theme_android.h" 5 #include "ui/gfx/native_theme_android.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "grit/gfx_resources.h" 11 #include "grit/gfx_resources.h"
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 canvas->drawLine(rect.x() + 1, rect.y(), kRight - 1, rect.y(), paint); 338 canvas->drawLine(rect.x() + 1, rect.y(), kRight - 1, rect.y(), paint);
339 canvas->drawLine(kRight - 1, rect.y() + 1, kRight - 1, kBottom - 1, paint); 339 canvas->drawLine(kRight - 1, rect.y() + 1, kRight - 1, kBottom - 1, paint);
340 canvas->drawLine(rect.x() + 1, kBottom - 1, kRight - 1, kBottom - 1, paint); 340 canvas->drawLine(rect.x() + 1, kBottom - 1, kRight - 1, kBottom - 1, paint);
341 canvas->drawLine(rect.x(), rect.y() + 1, rect.x(), kBottom - 1, paint); 341 canvas->drawLine(rect.x(), rect.y() + 1, rect.x(), kBottom - 1, paint);
342 } 342 }
343 343
344 paint.setColor(SK_ColorBLACK); 344 paint.setColor(SK_ColorBLACK);
345 int kLightEnd = state == PRESSED ? 1 : 0; 345 int kLightEnd = state == PRESSED ? 1 : 0;
346 int kDarkEnd = !kLightEnd; 346 int kDarkEnd = !kLightEnd;
347 SkPoint gradient_bounds[2]; 347 SkPoint gradient_bounds[2];
348 gradient_bounds[kLightEnd].set(SkIntToScalar(rect.x()), 348 gradient_bounds[kLightEnd].iset(rect.x(), rect.y());
349 SkIntToScalar(rect.y())); 349 gradient_bounds[kDarkEnd].iset(rect.x(), kBottom - 1);
350 gradient_bounds[kDarkEnd].set(SkIntToScalar(rect.x()),
351 SkIntToScalar(kBottom - 1));
352 SkColor colors[2]; 350 SkColor colors[2];
353 colors[0] = light_color; 351 colors[0] = light_color;
354 colors[1] = base_color; 352 colors[1] = base_color;
355 353
356 SkShader* shader = SkGradientShader::CreateLinear( 354 SkShader* shader = SkGradientShader::CreateLinear(
357 gradient_bounds, colors, NULL, 2, SkShader::kClamp_TileMode, NULL); 355 gradient_bounds, colors, NULL, 2, SkShader::kClamp_TileMode, NULL);
358 paint.setStyle(SkPaint::kFill_Style); 356 paint.setStyle(SkPaint::kFill_Style);
359 paint.setShader(shader); 357 paint.setShader(shader);
360 shader->unref(); 358 shader->unref();
361 359
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 605
608 DrawTiledImage(canvas, *value_image, 0, 0, tile_scale_x, tile_scale, 606 DrawTiledImage(canvas, *value_image, 0, 0, tile_scale_x, tile_scale,
609 progress_bar.value_rect_x, 607 progress_bar.value_rect_x,
610 progress_bar.value_rect_y, 608 progress_bar.value_rect_y,
611 progress_bar.value_rect_width, 609 progress_bar.value_rect_width,
612 progress_bar.value_rect_height); 610 progress_bar.value_rect_height);
613 } 611 }
614 612
615 int dest_left_border_width = static_cast<int>(left_border_image->width() * 613 int dest_left_border_width = static_cast<int>(left_border_image->width() *
616 tile_scale); 614 tile_scale);
617 SkRect dest_rect = { 615 SkRect dest_rect;
618 SkIntToScalar(rect.x()), 616 dest_rect.iset(rect.x(), rect.y(), rect.x() + dest_left_border_width,
619 SkIntToScalar(rect.y()), 617 rect.bottom());
620 SkIntToScalar(rect.x() + dest_left_border_width),
621 SkIntToScalar(rect.bottom())
622 };
623 canvas->drawBitmapRect(*left_border_image, NULL, dest_rect); 618 canvas->drawBitmapRect(*left_border_image, NULL, dest_rect);
624 619
625 int dest_right_border_width = static_cast<int>(right_border_image->width() * 620 int dest_right_border_width = static_cast<int>(right_border_image->width() *
626 tile_scale); 621 tile_scale);
627 dest_rect.set(SkIntToScalar(rect.right() - dest_right_border_width), 622 dest_rect.iset(rect.right() - dest_right_border_width, rect.y(), rect.right(),
628 SkIntToScalar(rect.y()), 623 rect.bottom());
629 SkIntToScalar(rect.right()),
630 SkIntToScalar(rect.bottom()));
631 canvas->drawBitmapRect(*right_border_image, NULL, dest_rect); 624 canvas->drawBitmapRect(*right_border_image, NULL, dest_rect);
632 } 625 }
633 626
634 bool NativeThemeAndroid::IntersectsClipRectInt(SkCanvas* canvas, 627 bool NativeThemeAndroid::IntersectsClipRectInt(SkCanvas* canvas,
635 int x, 628 int x,
636 int y, 629 int y,
637 int w, 630 int w,
638 int h) { 631 int h) {
639 SkRect clip; 632 SkRect clip;
640 return canvas->getClipBounds(&clip) && 633 return canvas->getClipBounds(&clip) &&
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 SkScalar min_diff = Clamp((hsv1[1] + hsv2[1]) * 1.2, 0.28, 0.5); 777 SkScalar min_diff = Clamp((hsv1[1] + hsv2[1]) * 1.2, 0.28, 0.5);
785 SkScalar diff = Clamp(fabs(hsv1[2] - hsv2[2]) / 2, min_diff, 0.5); 778 SkScalar diff = Clamp(fabs(hsv1[2] - hsv2[2]) / 2, min_diff, 0.5);
786 779
787 if (hsv1[2] + hsv2[2] > 1.0) 780 if (hsv1[2] + hsv2[2] > 1.0)
788 diff = -diff; 781 diff = -diff;
789 782
790 return SaturateAndBrighten(hsv2, -0.2, diff); 783 return SaturateAndBrighten(hsv2, -0.2, diff);
791 } 784 }
792 785
793 } // namespace gfx 786 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/canvas_skia.cc ('k') | ui/gfx/native_theme_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698