<commit_before>// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ui/gfx/skia_util.h"

#include "base/i18n/char_iterator.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkColorFilter.h"
#include "third_party/skia/include/core/SkColorPriv.h"
#include "third_party/skia/include/core/SkUnPreMultiply.h"
#include "third_party/skia/include/effects/SkBlurMaskFilter.h"
#include "third_party/skia/include/effects/SkGradientShader.h"
#include "third_party/skia/include/effects/SkLayerDrawLooper.h"
#include "ui/gfx/image/image_skia_rep.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/shadow_value.h"

namespace gfx {

SkRect RectToSkRect(const gfx::Rect& rect) {
  SkRect r;
  r.iset(rect.x(), rect.y(), rect.right(), rect.bottom());
  return r;
}

SkIRect RectToSkIRect(const gfx::Rect& rect) {
  SkIRect r = { rect.x(), rect.y(), rect.right(), rect.bottom() };
  return r;
}

gfx::Rect SkRectToRect(const SkRect& rect) {
  return gfx::Rect(static_cast<int>(rect.left()),
                   static_cast<int>(rect.top()),
                   static_cast<int>(rect.width()),
                   static_cast<int>(rect.height()));
}

SkShader* CreateImageRepShader(const gfx::ImageSkiaRep& image_rep,
                               SkShader::TileMode tile_mode,
                               const SkMatrix& local_matrix) {
  SkShader* shader = SkShader::CreateBitmapShader(image_rep.sk_bitmap(),
      tile_mode, tile_mode);
  SkScalar scale_x = local_matrix.getScaleX();
  SkScalar scale_y = local_matrix.getScaleY();
  SkScalar bitmap_scale = SkFloatToScalar(image_rep.GetScale());

  // Unscale matrix by |bitmap_scale| such that the bitmap is drawn at the
  // correct density.
  // Convert skew and translation to pixel coordinates.<commit_msg>gfx: Simplify the implementation of RectToSkIRect() function.<commit_after>// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ui/gfx/skia_util.h"

#include "base/i18n/char_iterator.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkColorFilter.h"
#include "third_party/skia/include/core/SkColorPriv.h"
#include "third_party/skia/include/core/SkUnPreMultiply.h"
#include "third_party/skia/include/effects/SkBlurMaskFilter.h"
#include "third_party/skia/include/effects/SkGradientShader.h"
#include "third_party/skia/include/effects/SkLayerDrawLooper.h"
#include "ui/gfx/image/image_skia_rep.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/shadow_value.h"

namespace gfx {

SkRect RectToSkRect(const gfx::Rect& rect) {
  SkRect r;
  r.iset(rect.x(), rect.y(), rect.right(), rect.bottom());
  return r;
}

SkIRect RectToSkIRect(const gfx::Rect& rect) {
  return SkIRect::MakeXYWH(rect.x(), rect.y(), rect.width(), rect.height());
}

gfx::Rect SkRectToRect(const SkRect& rect) {
  return gfx::Rect(static_cast<int>(rect.left()),
                   static_cast<int>(rect.top()),
                   static_cast<int>(rect.width()),
                   static_cast<int>(rect.height()));
}

SkShader* CreateImageRepShader(const gfx::ImageSkiaRep& image_rep,
                               SkShader::TileMode tile_mode,
                               const SkMatrix& local_matrix) {
  SkShader* shader = SkShader::CreateBitmapShader(image_rep.sk_bitmap(),
      tile_mode, tile_mode);
  SkScalar scale_x = local_matrix.getScaleX();
  SkScalar scale_y = local_matrix.getScaleY();
  SkScalar bitmap_scale = SkFloatToScalar(image_rep.GetScale());

  // Unscale matrix by |bitmap_scale| such that the bitmap is drawn at the
  // correct density.
  // Convert skew and translation to pixel coordinates.
{'fraction_non_alphanumeric': 0.1313340227507756, 'fraction_numerical': 0.0031023784901758012, 'mean_word_length': 3.88510101010101, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4184972', 'n_tokens_mistral': 1309, 'n_tokens_neox': 1284, 'n_words': 266}