// Copyright (c) 2013 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 <limits>

#include "skia/ext/paint_simplifier.h"
#include "third_party/skia/include/core/SkPaint.h"

namespace skia {

PaintSimplifier::PaintSimplifier()
  : INHERITED() {

}

PaintSimplifier::~PaintSimplifier() {

}

bool PaintSimplifier::filter(SkPaint* paint, Type type) {

  // Preserve a modicum of text quality; black & white text is
  // just too blocky, even during a fling.
  if (type != kText_Type) {
    paint->setAntiAlias(false);
  }
  paint->setSubpixelText(false);
  paint->setLCDRenderText(false);

  // Reduce filter level to medium or less. Note that reducing the filter to
  // less than medium can have a negative effect on performance as the filtered
  // image is not cached in this case.
  paint->setFilterLevel(
      std::min(paint->getFilterLevel(), SkPaint::kMedium_FilterLevel));

  paint->setMaskFilter(NULL);

  // Uncomment this line to shade simplified tiles pink during debugging.
  //paint->setColor(SkColorSetRGB(255, 127, 127));

  return true;
}


}  // namespace skia



// Copyright (c) 2013 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 "skia/ext/paint_simplifier.h"
#include "third_party/skia/include/core/SkPaint.h"

namespace skia {

PaintSimplifier::PaintSimplifier()
  : INHERITED() {

}

PaintSimplifier::~PaintSimplifier() {

}

bool PaintSimplifier::filter(SkPaint* paint, Type type) {

  // Preserve a modicum of text quality; black & white text is
  // just too blocky, even during a fling.
  if (type != kText_Type) {
    paint->setAntiAlias(false);
  }
  paint->setSubpixelText(false);
  paint->setLCDRenderText(false);

  paint->setMaskFilter(NULL);

  // Uncomment this line to shade simplified tiles pink during debugging.
  //paint->setColor(SkColorSetRGB(255, 127, 127));

  return true;
}


}  // namespace skia



Revert 273648 "skia: Use medium filter quality in PaintSimplifier."
Revert 273648 "skia: Use medium filter quality in PaintSimplifier."

> skia: Use medium filter quality in PaintSimplifier.
> 
> Preventing all bitmap filtering in the paint simplifier is a bad
> idea as it's very cache unfriendly when down-sampling due to
> requiring both the full size decoded image and the high/medium
> quality image normally used to be cached for good performance.
> 
> However, forcing medium quality filtering is worthwhile as it's
> faster than high quality and still provides caching benefits.
> 
> BUG=
> 
> Review URL: https://codereview.chromium.org/305623008

Looks like this had a negative effect on memory usage.

TBR=reveman@chromium.org
BUG=379164

Review URL: https://codereview.chromium.org/308703006

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@273914 0039d316-1c4b-4281-b951-d872f2087c98
