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

Side by Side Diff: sky/engine/platform/graphics/skia/NativeImageSkia.cpp

Issue 839143002: Roll Chrome into Mojo. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Rebase Created 5 years, 11 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 | « sky/engine/platform/graphics/ReplayingCanvas.h ('k') | testing/buildbot/chromium.fyi.json » ('j') | 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 * Copyright (c) 2008, Google Inc. All rights reserved. 2 * Copyright (c) 2008, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 SkISize scaledImageSize = SkISize::Make(clampToInteger(roundf(imageSize.widt h() * scaleX)), 84 SkISize scaledImageSize = SkISize::Make(clampToInteger(roundf(imageSize.widt h() * scaleX)),
85 clampToInteger(roundf(imageSize.height() * scaleY))); 85 clampToInteger(roundf(imageSize.height() * scaleY)));
86 86
87 SkRect imageRect = SkRect::MakeWH(imageSize.width(), imageSize.height()); 87 SkRect imageRect = SkRect::MakeWH(imageSize.width(), imageSize.height());
88 SkRect scaledImageRect = SkRect::MakeWH(scaledImageSize.width(), scaledImage Size.height()); 88 SkRect scaledImageRect = SkRect::MakeWH(scaledImageSize.width(), scaledImage Size.height());
89 89
90 SkMatrix scaleTransform; 90 SkMatrix scaleTransform;
91 scaleTransform.setRectToRect(imageRect, scaledImageRect, SkMatrix::kFill_Sca leToFit); 91 scaleTransform.setRectToRect(imageRect, scaledImageRect, SkMatrix::kFill_Sca leToFit);
92 scaleTransform.mapRect(scaledSrcRect, srcRect); 92 scaleTransform.mapRect(scaledSrcRect, srcRect);
93 93
94 scaledSrcRect->intersect(scaledImageRect); 94 bool ok = scaledSrcRect->intersect(scaledImageRect);
95 ASSERT_UNUSED(ok, ok);
95 SkIRect enclosingScaledSrcRect = enclosingIntRect(*scaledSrcRect); 96 SkIRect enclosingScaledSrcRect = enclosingIntRect(*scaledSrcRect);
96 97
97 // |enclosingScaledSrcRect| can be larger than |scaledImageSize| because 98 // |enclosingScaledSrcRect| can be larger than |scaledImageSize| because
98 // of float inaccuracy so clip to get inside. 99 // of float inaccuracy so clip to get inside.
99 enclosingScaledSrcRect.intersect(SkIRect::MakeSize(scaledImageSize)); 100 ok = enclosingScaledSrcRect.intersect(SkIRect::MakeSize(scaledImageSize));
101 ASSERT_UNUSED(ok, ok);
100 102
101 // scaledSrcRect is relative to the pixel snapped fragment we're extracting. 103 // scaledSrcRect is relative to the pixel snapped fragment we're extracting.
102 scaledSrcRect->offset(-enclosingScaledSrcRect.x(), -enclosingScaledSrcRect.y ()); 104 scaledSrcRect->offset(-enclosingScaledSrcRect.x(), -enclosingScaledSrcRect.y ());
103 105
104 return resizedBitmap(scaledImageSize, enclosingScaledSrcRect); 106 return resizedBitmap(scaledImageSize, enclosingScaledSrcRect);
105 } 107 }
106 108
107 NativeImageSkia::NativeImageSkia() 109 NativeImageSkia::NativeImageSkia()
108 : m_resizeRequests(0) 110 : m_resizeRequests(0)
109 { 111 {
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 SkIRect NativeImageSkia::ImageResourceInfo::rectInSubset(const SkIRect& otherSca ledImageSubset) 362 SkIRect NativeImageSkia::ImageResourceInfo::rectInSubset(const SkIRect& otherSca ledImageSubset)
361 { 363 {
362 if (!scaledImageSubset.contains(otherScaledImageSubset)) 364 if (!scaledImageSubset.contains(otherScaledImageSubset))
363 return SkIRect::MakeEmpty(); 365 return SkIRect::MakeEmpty();
364 SkIRect subsetRect = otherScaledImageSubset; 366 SkIRect subsetRect = otherScaledImageSubset;
365 subsetRect.offset(-scaledImageSubset.x(), -scaledImageSubset.y()); 367 subsetRect.offset(-scaledImageSubset.x(), -scaledImageSubset.y());
366 return subsetRect; 368 return subsetRect;
367 } 369 }
368 370
369 } // namespace blink 371 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/platform/graphics/ReplayingCanvas.h ('k') | testing/buildbot/chromium.fyi.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698