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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/Image.cpp

Issue 2701993002: DO NOT COMMIT: Results of running new (proposed) clang-format on Blink (Closed)
Patch Set: Created 3 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) 2 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
3 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 const FloatRect& dstRect, 127 const FloatRect& dstRect,
128 const FloatRect& srcRect, 128 const FloatRect& srcRect,
129 const FloatSize& providedTileScaleFactor, 129 const FloatSize& providedTileScaleFactor,
130 TileRule hRule, 130 TileRule hRule,
131 TileRule vRule, 131 TileRule vRule,
132 SkBlendMode op) { 132 SkBlendMode op) {
133 // TODO(cavalcantii): see crbug.com/662513. 133 // TODO(cavalcantii): see crbug.com/662513.
134 FloatSize tileScaleFactor = providedTileScaleFactor; 134 FloatSize tileScaleFactor = providedTileScaleFactor;
135 if (vRule == RoundTile) { 135 if (vRule == RoundTile) {
136 float vRepetitions = 136 float vRepetitions =
137 std::max(1.0f, roundf(dstRect.height() / 137 std::max(1.0f,
138 (tileScaleFactor.height() * srcRect.height()))); 138 roundf(dstRect.height() /
139 (tileScaleFactor.height() * srcRect.height())));
139 tileScaleFactor.setHeight(dstRect.height() / 140 tileScaleFactor.setHeight(dstRect.height() /
140 (srcRect.height() * vRepetitions)); 141 (srcRect.height() * vRepetitions));
141 } 142 }
142 143
143 if (hRule == RoundTile) { 144 if (hRule == RoundTile) {
144 float hRepetitions = std::max( 145 float hRepetitions = std::max(
145 1.0f, 146 1.0f,
146 roundf(dstRect.width() / (tileScaleFactor.width() * srcRect.width()))); 147 roundf(dstRect.width() / (tileScaleFactor.width() * srcRect.width())));
147 tileScaleFactor.setWidth(dstRect.width() / 148 tileScaleFactor.setWidth(dstRect.width() /
148 (srcRect.width() * hRepetitions)); 149 (srcRect.width() * hRepetitions));
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 353
353 return true; 354 return true;
354 } 355 }
355 356
356 FloatRect Image::computeTileContaining(const FloatPoint& point, 357 FloatRect Image::computeTileContaining(const FloatPoint& point,
357 const FloatSize& tileSize, 358 const FloatSize& tileSize,
358 const FloatPoint& tilePhase, 359 const FloatPoint& tilePhase,
359 const FloatSize& tileSpacing) { 360 const FloatSize& tileSpacing) {
360 const FloatSize actualTileSize(tileSize + tileSpacing); 361 const FloatSize actualTileSize(tileSize + tileSpacing);
361 return FloatRect( 362 return FloatRect(
362 FloatPoint( 363 FloatPoint(point.x() +
363 point.x() + fmodf(fmodf(-tilePhase.x(), actualTileSize.width()) - 364 fmodf(fmodf(-tilePhase.x(), actualTileSize.width()) -
364 actualTileSize.width(), 365 actualTileSize.width(),
365 actualTileSize.width()), 366 actualTileSize.width()),
366 point.y() + fmodf(fmodf(-tilePhase.y(), actualTileSize.height()) - 367 point.y() +
367 actualTileSize.height(), 368 fmodf(fmodf(-tilePhase.y(), actualTileSize.height()) -
368 actualTileSize.height())), 369 actualTileSize.height(),
370 actualTileSize.height())),
369 tileSize); 371 tileSize);
370 } 372 }
371 373
372 FloatRect Image::computeSubsetForTile(const FloatRect& tile, 374 FloatRect Image::computeSubsetForTile(const FloatRect& tile,
373 const FloatRect& dest, 375 const FloatRect& dest,
374 const FloatSize& imageSize) { 376 const FloatSize& imageSize) {
375 DCHECK(tile.contains(dest)); 377 DCHECK(tile.contains(dest));
376 378
377 const FloatSize scale(tile.width() / imageSize.width(), 379 const FloatSize scale(tile.width() / imageSize.width(),
378 tile.height() / imageSize.height()); 380 tile.height() / imageSize.height());
379 381
380 FloatRect subset = dest; 382 FloatRect subset = dest;
381 subset.setX((dest.x() - tile.x()) / scale.width()); 383 subset.setX((dest.x() - tile.x()) / scale.width());
382 subset.setY((dest.y() - tile.y()) / scale.height()); 384 subset.setY((dest.y() - tile.y()) / scale.height());
383 subset.setWidth(dest.width() / scale.width()); 385 subset.setWidth(dest.width() / scale.width());
384 subset.setHeight(dest.height() / scale.height()); 386 subset.setHeight(dest.height() / scale.height());
385 387
386 return subset; 388 return subset;
387 } 389 }
388 390
389 } // namespace blink 391 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698