Backed out changeset 44fa7b379742 (bug 1388396)

This commit is contained in:
Sebastian Hengst 2017-09-13 09:50:24 +02:00
Родитель d0007e88ac
Коммит 30e285a9cb
4 изменённых файлов: 2 добавлений и 45 удалений

Просмотреть файл

@ -28,7 +28,6 @@ import org.mozilla.gecko.icons.preparation.SuggestedSitePreparer;
import org.mozilla.gecko.icons.processing.ColorProcessor;
import org.mozilla.gecko.icons.processing.DiskProcessor;
import org.mozilla.gecko.icons.processing.MemoryProcessor;
import org.mozilla.gecko.icons.processing.MinimumSizeProcessor;
import org.mozilla.gecko.icons.processing.Processor;
import org.mozilla.gecko.icons.processing.ResizingProcessor;
@ -127,11 +126,7 @@ import java.util.concurrent.TimeUnit;
new ColorProcessor(),
// Store the icon in the memory cache
new MemoryProcessor(),
// Substitute a generated icon if the final result is not large enough.
// Expected to be called after ResizingProcessor.
new MinimumSizeProcessor()
new MemoryProcessor()
);
private static final ExecutorService EXECUTOR;

Просмотреть файл

@ -55,7 +55,7 @@ public class IconGenerator implements IconLoader {
/**
* Generate default favicon for the given page URL.
*/
public static IconResponse generate(Context context, String pageURL) {
@VisibleForTesting static IconResponse generate(Context context, String pageURL) {
final Resources resources = context.getResources();
final int widthAndHeight = resources.getDimensionPixelSize(R.dimen.favicon_bg);
final int roundedCorners = resources.getDimensionPixelOffset(R.dimen.favicon_corner_radius);

Просмотреть файл

@ -1,37 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko.icons.processing;
import org.mozilla.gecko.icons.IconRequest;
import org.mozilla.gecko.icons.IconResponse;
import org.mozilla.gecko.icons.loader.IconGenerator;
/**
* Substitutes a generated image for the given icon if it doesn't not meet the minimum size requirement.
*
* Ideally, we would discard images while we're loading them: if we found an icon that was too small, we
* would have the opportunity to search other places before generating an icon and we wouldn't duplicate
* the generate icon call. However, this turned out to be non-trivial: a single icon will appear as two
* different sizes when given to the loader, the original size the first time it's loaded and the size after
* {@link ResizingProcessor} the second time, when it's loaded from the cache. It turned out to be much simpler
* to enforce the requirement that...
*
* This processor is expected to be called after {@link ResizingProcessor}.
*/
public class MinimumSizeProcessor implements Processor {
@Override
public void process(final IconRequest request, final IconResponse response) {
// We expect that this bitmap has already been scaled by ResizingProcessor.
if (response.getBitmap().getWidth() >= request.getMinimumSizePxAfterScaling()) {
return;
}
// This is fragile: ideally, we can return the generated response but instead we're mutating the argument.
final IconResponse generatedResponse = IconGenerator.generate(request.getContext(), request.getPageUrl());
response.updateBitmap(generatedResponse.getBitmap());
response.updateColor(generatedResponse.getColor());
}
}

Просмотреть файл

@ -750,7 +750,6 @@ gbjar.sources += ['java/org/mozilla/gecko/' + x for x in [
'icons/processing/ColorProcessor.java',
'icons/processing/DiskProcessor.java',
'icons/processing/MemoryProcessor.java',
'icons/processing/MinimumSizeProcessor.java',
'icons/processing/Processor.java',
'icons/processing/ResizingProcessor.java',
'icons/storage/DiskStorage.java',