OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkBitmap.h" | 8 #include "SkBitmap.h" |
9 #include "SkBitmapController.h" | 9 #include "SkBitmapController.h" |
10 #include "SkBitmapProvider.h" | 10 #include "SkBitmapProvider.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 invScaleX = scale.width(); | 98 invScaleX = scale.width(); |
99 invScaleY = scale.height(); | 99 invScaleY = scale.height(); |
100 } | 100 } |
101 invScaleX = SkScalarAbs(invScaleX); | 101 invScaleX = SkScalarAbs(invScaleX); |
102 invScaleY = SkScalarAbs(invScaleY); | 102 invScaleY = SkScalarAbs(invScaleY); |
103 | 103 |
104 if (SkScalarNearlyEqual(invScaleX, 1) && SkScalarNearlyEqual(invScaleY, 1))
{ | 104 if (SkScalarNearlyEqual(invScaleX, 1) && SkScalarNearlyEqual(invScaleY, 1))
{ |
105 return false; // no need for HQ | 105 return false; // no need for HQ |
106 } | 106 } |
107 | 107 |
108 #ifndef SK_SUPPORT_LEGACY_HQ_DOWNSAMPLING | |
109 if (invScaleX > 1 || invScaleY > 1) { | 108 if (invScaleX > 1 || invScaleY > 1) { |
110 return false; // only use HQ when upsampling | 109 return false; // only use HQ when upsampling |
111 } | 110 } |
112 #endif | 111 |
113 | |
114 const int dstW = SkScalarRoundToScalar(provider.width() / invScaleX); | 112 const int dstW = SkScalarRoundToScalar(provider.width() / invScaleX); |
115 const int dstH = SkScalarRoundToScalar(provider.height() / invScaleY); | 113 const int dstH = SkScalarRoundToScalar(provider.height() / invScaleY); |
116 const SkBitmapCacheDesc desc = provider.makeCacheDesc(dstW, dstH); | 114 const SkBitmapCacheDesc desc = provider.makeCacheDesc(dstW, dstH); |
117 | 115 |
118 if (!SkBitmapCache::FindWH(desc, &fResultBitmap)) { | 116 if (!SkBitmapCache::FindWH(desc, &fResultBitmap)) { |
119 SkBitmap orig; | 117 SkBitmap orig; |
120 if (!provider.asBitmap(&orig)) { | 118 if (!provider.asBitmap(&orig)) { |
121 return false; | 119 return false; |
122 } | 120 } |
123 SkAutoPixmapUnlock src; | 121 SkAutoPixmapUnlock src; |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 fResultBitmap.getColorTable()); | 219 fResultBitmap.getColorTable()); |
222 } | 220 } |
223 | 221 |
224 SkBitmapController::State* SkDefaultBitmapController::onRequestBitmap(const SkBi
tmapProvider& bm, | 222 SkBitmapController::State* SkDefaultBitmapController::onRequestBitmap(const SkBi
tmapProvider& bm, |
225 const SkMa
trix& inverse, | 223 const SkMa
trix& inverse, |
226 SkFilterQu
ality quality, | 224 SkFilterQu
ality quality, |
227 void* stor
age, size_t size) { | 225 void* stor
age, size_t size) { |
228 return SkInPlaceNewCheck<SkDefaultBitmapControllerState>(storage, size, bm,
inverse, quality); | 226 return SkInPlaceNewCheck<SkDefaultBitmapControllerState>(storage, size, bm,
inverse, quality); |
229 } | 227 } |
230 | 228 |
OLD | NEW |