Skip to content

Commit

Permalink
Clean up naming of paint-related identifiers
Browse files Browse the repository at this point in the history
This is a followup to https://codereview.chromium.org/2640983002 that
only changed types.  This should be purely mechanical.

This is the last set of renames.

BUG=671433

Review-Url: https://codereview.chromium.org/2697663002
Cr-Commit-Position: refs/heads/master@{#450474}
  • Loading branch information
quisquous authored and Commit bot committed Feb 14, 2017
1 parent f4a164c commit 3283082
Show file tree
Hide file tree
Showing 25 changed files with 178 additions and 181 deletions.
10 changes: 5 additions & 5 deletions apps/ui/views/app_window_frame_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -305,17 +305,17 @@ void AppWindowFrameView::OnPaint(gfx::Canvas* canvas) {

SetButtonImagesForFrame();
// TODO(benwells): different look for inactive by default.
cc::PaintFlags paint;
paint.setAntiAlias(false);
paint.setStyle(cc::PaintFlags::kFill_Style);
paint.setColor(CurrentFrameColor());
cc::PaintFlags flags;
flags.setAntiAlias(false);
flags.setStyle(cc::PaintFlags::kFill_Style);
flags.setColor(CurrentFrameColor());
gfx::Path path;
path.moveTo(0, 0);
path.lineTo(width(), 0);
path.lineTo(width(), kCaptionHeight);
path.lineTo(0, kCaptionHeight);
path.close();
canvas->DrawPath(path, paint);
canvas->DrawPath(path, flags);
}

const char* AppWindowFrameView::GetClassName() const { return kViewClassName; }
Expand Down
23 changes: 11 additions & 12 deletions chrome/browser/download/download_shelf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include "content/public/browser/download_item.h"
#include "content/public/browser/download_manager.h"
#include "content/public/browser/web_contents.h"
#include "third_party/skia/include/core/SkPaint.h"
#include "third_party/skia/include/core/SkPath.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/theme_provider.h"
Expand Down Expand Up @@ -75,16 +74,16 @@ void DownloadShelf::PaintDownloadProgress(
const base::TimeDelta& progress_time,
int percent_done) {
// Draw background (light blue circle).
cc::PaintFlags bg_paint;
bg_paint.setStyle(cc::PaintFlags::kFill_Style);
cc::PaintFlags bg_flags;
bg_flags.setStyle(cc::PaintFlags::kFill_Style);
SkColor indicator_color =
theme_provider.GetColor(ThemeProperties::COLOR_TAB_THROBBER_SPINNING);
bg_paint.setColor(SkColorSetA(indicator_color, 0x33));
bg_paint.setAntiAlias(true);
bg_flags.setColor(SkColorSetA(indicator_color, 0x33));
bg_flags.setAntiAlias(true);
const SkScalar kCenterPoint = kProgressIndicatorSize / 2.f;
SkPath bg;
bg.addCircle(kCenterPoint, kCenterPoint, kCenterPoint);
canvas->DrawPath(bg, bg_paint);
canvas->DrawPath(bg, bg_flags);

// Calculate progress.
SkScalar sweep_angle = 0.f;
Expand All @@ -104,12 +103,12 @@ void DownloadShelf::PaintDownloadProgress(
progress.addArc(
SkRect::MakeLTRB(0, 0, kProgressIndicatorSize, kProgressIndicatorSize),
start_pos, sweep_angle);
cc::PaintFlags progress_paint;
progress_paint.setColor(indicator_color);
progress_paint.setStyle(cc::PaintFlags::kStroke_Style);
progress_paint.setStrokeWidth(1.7f);
progress_paint.setAntiAlias(true);
canvas->DrawPath(progress, progress_paint);
cc::PaintFlags progress_flags;
progress_flags.setColor(indicator_color);
progress_flags.setStyle(cc::PaintFlags::kStroke_Style);
progress_flags.setStrokeWidth(1.7f);
progress_flags.setAntiAlias(true);
canvas->DrawPath(progress, progress_flags);
}

// static
Expand Down
8 changes: 4 additions & 4 deletions chrome/browser/extensions/bookmark_app_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@ class GeneratedIconImageSource : public gfx::CanvasImageSource {
#endif

// Draw a rounded rect of the given |color|.
cc::PaintFlags background_paint;
background_paint.setAntiAlias(true);
background_paint.setColor(color_);
cc::PaintFlags background_flags;
background_flags.setAntiAlias(true);
background_flags.setColor(color_);

gfx::Rect icon_rect(icon_inset, icon_inset, icon_size, icon_size);
canvas->DrawRoundRect(icon_rect, border_radius, background_paint);
canvas->DrawRoundRect(icon_rect, border_radius, background_flags);

// The text rect's size needs to be odd to center the text correctly.
gfx::Rect text_rect(icon_inset, icon_inset, icon_size + 1, icon_size + 1);
Expand Down
24 changes: 12 additions & 12 deletions chrome/browser/profiles/profile_avatar_icon_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -189,21 +189,21 @@ void AvatarImageSource::Draw(gfx::Canvas* canvas) {
SkFloatToScalar(x + border_size - 0.5f), // right
SkFloatToScalar(y + border_size - 0.5f)); // bottom

cc::PaintFlags paint;
paint.setColor(border_color);
paint.setStyle(cc::PaintFlags::kStroke_Style);
paint.setStrokeWidth(SkIntToScalar(1));
cc::PaintFlags flags;
flags.setColor(border_color);
flags.setStyle(cc::PaintFlags::kStroke_Style);
flags.setStrokeWidth(SkIntToScalar(1));

canvas->DrawPath(path, paint);
canvas->DrawPath(path, flags);
} else if (border_ == BORDER_ETCHED) {
// Give the avatar an etched look by drawing a highlight on the bottom and
// right edges.
SkColor shadow_color = SkColorSetARGB(83, 0, 0, 0);
SkColor highlight_color = SkColorSetARGB(96, 255, 255, 255);

cc::PaintFlags paint;
paint.setStyle(cc::PaintFlags::kStroke_Style);
paint.setStrokeWidth(SkIntToScalar(1));
cc::PaintFlags flags;
flags.setStyle(cc::PaintFlags::kStroke_Style);
flags.setStrokeWidth(SkIntToScalar(1));

SkPath path;

Expand All @@ -218,8 +218,8 @@ void AvatarImageSource::Draw(gfx::Canvas* canvas) {
// Draw right to the top-right, stopping within the last pixel.
path.rLineTo(SkFloatToScalar(width_ - 0.5f), SkIntToScalar(0));

paint.setColor(shadow_color);
canvas->DrawPath(path, paint);
flags.setColor(shadow_color);
canvas->DrawPath(path, flags);

path.reset();

Expand All @@ -233,8 +233,8 @@ void AvatarImageSource::Draw(gfx::Canvas* canvas) {
// Draw up to the top-right.
path.rLineTo(SkIntToScalar(0), SkFloatToScalar(-height_ + 1.5f));

paint.setColor(highlight_color);
canvas->DrawPath(path, paint);
flags.setColor(highlight_color);
canvas->DrawPath(path, flags);
}
}

Expand Down
33 changes: 16 additions & 17 deletions chrome/browser/ui/extensions/icon_with_badge_image_source.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "cc/paint/paint_flags.h"
#include "chrome/browser/extensions/extension_action.h"
#include "chrome/grit/theme_resources.h"
#include "third_party/skia/include/core/SkPaint.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/color_palette.h"
Expand Down Expand Up @@ -148,20 +147,20 @@ void IconWithBadgeImageSource::PaintBadge(gfx::Canvas* canvas) {
? (size().width() - badge_width) / 2
: size().width() - badge_width,
size().height() - kBadgeHeight, badge_width, kBadgeHeight);
cc::PaintFlags rect_paint;
rect_paint.setStyle(cc::PaintFlags::kFill_Style);
rect_paint.setAntiAlias(true);
rect_paint.setColor(background_color);
cc::PaintFlags rect_flags;
rect_flags.setStyle(cc::PaintFlags::kFill_Style);
rect_flags.setAntiAlias(true);
rect_flags.setColor(background_color);

// Clear part of the background icon.
gfx::Rect cutout_rect(rect);
cutout_rect.Inset(-1, -1);
cc::PaintFlags cutout_paint = rect_paint;
cutout_paint.setBlendMode(SkBlendMode::kClear);
canvas->DrawRoundRect(cutout_rect, 2, cutout_paint);
cc::PaintFlags cutout_flags = rect_flags;
cutout_flags.setBlendMode(SkBlendMode::kClear);
canvas->DrawRoundRect(cutout_rect, 2, cutout_flags);

// Paint the backdrop.
canvas->DrawRoundRect(rect, 1, rect_paint);
canvas->DrawRoundRect(rect, 1, rect_flags);

// Paint the text.
rect.Inset(std::max(kPadding, (rect.width() - text_width) / 2),
Expand All @@ -175,14 +174,14 @@ void IconWithBadgeImageSource::PaintPageActionDecoration(gfx::Canvas* canvas) {
int major_radius = std::ceil(size().width() / 5.0);
int minor_radius = std::ceil(major_radius / 2.0);
gfx::Point center_point(major_radius + 1, size().height() - (major_radius)-1);
cc::PaintFlags paint;
paint.setAntiAlias(true);
paint.setStyle(cc::PaintFlags::kFill_Style);
paint.setColor(SK_ColorTRANSPARENT);
paint.setBlendMode(SkBlendMode::kSrc);
canvas->DrawCircle(center_point, major_radius, paint);
paint.setColor(decoration_color);
canvas->DrawCircle(center_point, minor_radius, paint);
cc::PaintFlags flags;
flags.setAntiAlias(true);
flags.setStyle(cc::PaintFlags::kFill_Style);
flags.setColor(SK_ColorTRANSPARENT);
flags.setBlendMode(SkBlendMode::kSrc);
canvas->DrawCircle(center_point, major_radius, flags);
flags.setColor(decoration_color);
canvas->DrawCircle(center_point, minor_radius, flags);
}

void IconWithBadgeImageSource::PaintBlockedActionDecoration(
Expand Down
20 changes: 10 additions & 10 deletions chrome/browser/ui/libgtkui/native_theme_gtk2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ void NativeThemeGtk2::PaintMenuPopupBackground(
const gfx::Size& size,
const MenuBackgroundExtraParams& menu_background) const {
if (menu_background.corner_radius > 0) {
cc::PaintFlags paint;
paint.setStyle(cc::PaintFlags::kFill_Style);
paint.setFlags(cc::PaintFlags::kAntiAlias_Flag);
paint.setColor(GetSystemColor(kColorId_MenuBackgroundColor));
cc::PaintFlags flags;
flags.setStyle(cc::PaintFlags::kFill_Style);
flags.setFlags(cc::PaintFlags::kAntiAlias_Flag);
flags.setColor(GetSystemColor(kColorId_MenuBackgroundColor));

gfx::Path path;
SkRect rect = SkRect::MakeWH(SkIntToScalar(size.width()),
Expand All @@ -88,7 +88,7 @@ void NativeThemeGtk2::PaintMenuPopupBackground(
radius, radius, radius, radius};
path.addRoundRect(rect, radii);

canvas->drawPath(path, paint);
canvas->drawPath(path, flags);
} else {
canvas->drawColor(GetSystemColor(kColorId_MenuBackgroundColor),
SkBlendMode::kSrc);
Expand All @@ -101,28 +101,28 @@ void NativeThemeGtk2::PaintMenuItemBackground(
const gfx::Rect& rect,
const MenuItemExtraParams& menu_item) const {
SkColor color;
cc::PaintFlags paint;
cc::PaintFlags flags;
switch (state) {
case NativeTheme::kNormal:
case NativeTheme::kDisabled:
color = GetSystemColor(NativeTheme::kColorId_MenuBackgroundColor);
paint.setColor(color);
flags.setColor(color);
break;
case NativeTheme::kHovered:
color =
GetSystemColor(NativeTheme::kColorId_FocusedMenuItemBackgroundColor);
paint.setColor(color);
flags.setColor(color);
break;
default:
NOTREACHED() << "Invalid state " << state;
break;
}
if (menu_item.corner_radius > 0) {
const SkScalar radius = SkIntToScalar(menu_item.corner_radius);
canvas->drawRoundRect(gfx::RectToSkRect(rect), radius, radius, paint);
canvas->drawRoundRect(gfx::RectToSkRect(rect), radius, radius, flags);
return;
}
canvas->drawRect(gfx::RectToSkRect(rect), paint);
canvas->drawRect(gfx::RectToSkRect(rect), flags);
}

SkColor NativeThemeGtk2::GetSystemColor(ColorId color_id) const {
Expand Down
17 changes: 8 additions & 9 deletions chrome/browser/ui/views/create_application_shortcut_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#include "net/url_request/url_request.h"
#include "skia/ext/image_operations.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkPaint.h"
#include "third_party/skia/include/core/SkRect.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/layout.h"
Expand Down Expand Up @@ -184,12 +183,12 @@ void AppInfoView::OnPaint(gfx::Canvas* canvas) {
SkIntToScalar(bounds.bottom())
};

cc::PaintFlags border_paint;
border_paint.setAntiAlias(true);
border_paint.setARGB(0xFF, 0xC8, 0xC8, 0xC8);
cc::PaintFlags border_flags;
border_flags.setAntiAlias(true);
border_flags.setARGB(0xFF, 0xC8, 0xC8, 0xC8);

canvas->sk_canvas()->drawRoundRect(border_rect, SkIntToScalar(2),
SkIntToScalar(2), border_paint);
SkIntToScalar(2), border_flags);

SkRect inner_rect = {
border_rect.fLeft + SkDoubleToScalar(0.5),
Expand All @@ -198,11 +197,11 @@ void AppInfoView::OnPaint(gfx::Canvas* canvas) {
border_rect.fBottom - SkDoubleToScalar(0.5),
};

cc::PaintFlags inner_paint;
inner_paint.setAntiAlias(true);
inner_paint.setARGB(0xFF, 0xF8, 0xF8, 0xF8);
cc::PaintFlags inner_flags;
inner_flags.setAntiAlias(true);
inner_flags.setARGB(0xFF, 0xF8, 0xF8, 0xF8);
canvas->sk_canvas()->drawRoundRect(inner_rect, SkDoubleToScalar(1.5),
SkDoubleToScalar(1.5), inner_paint);
SkDoubleToScalar(1.5), inner_flags);
}

} // namespace
Expand Down
6 changes: 3 additions & 3 deletions chrome/browser/ui/views/download/download_item_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -730,11 +730,11 @@ void DownloadItemView::DrawIcon(gfx::Canvas* canvas) {
// Draw the icon image.
int icon_x = progress_x + DownloadShelf::kFiletypeIconOffset;
int icon_y = progress_y + DownloadShelf::kFiletypeIconOffset;
cc::PaintFlags paint;
cc::PaintFlags flags;
// Use an alpha to make the image look disabled.
if (!enabled())
paint.setAlpha(120);
canvas->DrawImageInt(*icon->ToImageSkia(), icon_x, icon_y, paint);
flags.setAlpha(120);
canvas->DrawImageInt(*icon->ToImageSkia(), icon_x, icon_y, flags);
}

void DownloadItemView::OnFocus() {
Expand Down
6 changes: 3 additions & 3 deletions chrome/browser/ui/views/frame/browser_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -482,9 +482,9 @@ void BrowserView::Paint1pxHorizontalLine(gfx::Canvas* canvas,
gfx::RectF rect(gfx::ScaleRect(gfx::RectF(bounds), scale));
const float inset = rect.height() - 1;
rect.Inset(0, at_bottom ? inset : 0, 0, at_bottom ? 0 : inset);
cc::PaintFlags paint;
paint.setColor(color);
canvas->sk_canvas()->drawRect(gfx::RectFToSkRect(rect), paint);
cc::PaintFlags flags;
flags.setColor(color);
canvas->sk_canvas()->drawRect(gfx::RectFToSkRect(rect), flags);
}

void BrowserView::InitStatusBubble() {
Expand Down
10 changes: 5 additions & 5 deletions chrome/browser/ui/views/infobars/infobar_container_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,22 @@ class ContentShadow : public views::View {
// views::View:
void OnPaint(gfx::Canvas* canvas) override {
// The first shader (small shadow) blurs from 0 to kSmallShadowHeight.
cc::PaintFlags paint;
paint.setShader(gfx::CreateGradientShader(
cc::PaintFlags flags;
flags.setShader(gfx::CreateGradientShader(
0, kSmallShadowHeight, SkColorSetA(SK_ColorBLACK, kSmallShadowAlpha),
SkColorSetA(SK_ColorBLACK, SK_AlphaTRANSPARENT)));
gfx::Rect small_shadow_bounds = GetLocalBounds();
small_shadow_bounds.set_height(kSmallShadowHeight);
canvas->DrawRect(small_shadow_bounds, paint);
canvas->DrawRect(small_shadow_bounds, flags);

// The second shader (large shadow) is solid from 0 to kSmallShadowHeight
// (blending with the first shader) and then blurs from kSmallShadowHeight
// to kLargeShadowHeight.
paint.setShader(gfx::CreateGradientShader(
flags.setShader(gfx::CreateGradientShader(
kSmallShadowHeight, height(),
SkColorSetA(SK_ColorBLACK, kLargeShadowAlpha),
SkColorSetA(SK_ColorBLACK, SK_AlphaTRANSPARENT)));
canvas->DrawRect(GetLocalBounds(), paint);
canvas->DrawRect(GetLocalBounds(), flags);
}

private:
Expand Down
20 changes: 10 additions & 10 deletions chrome/browser/ui/views/location_bar/background_with_1_px_border.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,20 @@ void BackgroundWith1PxBorder::Paint(gfx::Canvas* canvas,
path.addRoundRect(gfx::RectFToSkRect(border_rect_f), scaled_corner_radius,
scaled_corner_radius);

cc::PaintFlags paint;
paint.setStyle(cc::PaintFlags::kStroke_Style);
paint.setStrokeWidth(1);
paint.setAntiAlias(true);
cc::PaintFlags flags;
flags.setStyle(cc::PaintFlags::kStroke_Style);
flags.setStrokeWidth(1);
flags.setAntiAlias(true);

SkPath stroke_path;
paint.getFillPath(path, &stroke_path);
flags.getFillPath(path, &stroke_path);

SkPath fill_path;
Op(path, stroke_path, kDifference_SkPathOp, &fill_path);
paint.setStyle(cc::PaintFlags::kFill_Style);
paint.setColor(get_color());
canvas->sk_canvas()->drawPath(fill_path, paint);
flags.setStyle(cc::PaintFlags::kFill_Style);
flags.setColor(get_color());
canvas->sk_canvas()->drawPath(fill_path, flags);

paint.setColor(border_color_);
canvas->sk_canvas()->drawPath(stroke_path, paint);
flags.setColor(border_color_);
canvas->sk_canvas()->drawPath(stroke_path, flags);
}
Loading

0 comments on commit 3283082

Please sign in to comment.