forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New class to simplify rasterization.
skia::PaintSimplifier subclasses SkDrawFilter to reduce the quality of draws. The intent is to be able to place less of a burden on the rasterizer during Android flings or other situations where we need a lot of pixels but they won't spend long on screen. This CL does not actually invoke the PaintSimplifier. The code is extracted from https://codereview.chromium.org/12210081/; deciding when to simplify will be a separate CL. BUG=174945 TBR=reed Review URL: https://chromiumcodereview.appspot.com/12207157 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@182475 0039d316-1c4b-4281-b951-d872f2087c98
- Loading branch information
tomhudson@chromium.org
committed
Feb 14, 2013
1 parent
8ebd568
commit e98e66f
Showing
3 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// 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->setFilterBitmap(false); | ||
paint->setMaskFilter(NULL); | ||
|
||
// Uncomment this line to shade simplified tiles pink during debugging. | ||
//paint->setColor(SkColorSetRGB(255, 127, 127)); | ||
|
||
return true; | ||
} | ||
|
||
|
||
} // namespace skia | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// 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. | ||
|
||
#ifndef SKIA_EXT_PAINT_SIMPLIFIER_H | ||
#define SKIA_EXT_PAINT_SIMPLIFIER_H | ||
|
||
#include "base/values.h" | ||
#include "third_party/skia/include/core/SkDrawFilter.h" | ||
|
||
class SkPaint; | ||
|
||
namespace skia { | ||
|
||
/* | ||
When installed on a SkCanvas, reduces the quality of all draws | ||
to that canvas. This improves rasterization speed during flings. | ||
We turn off blurs, filters, and antialiasing *except for* text. | ||
*/ | ||
class SK_API PaintSimplifier : public SkDrawFilter { | ||
public: | ||
PaintSimplifier(); | ||
virtual ~PaintSimplifier(); | ||
virtual bool filter(SkPaint*, Type) OVERRIDE; | ||
|
||
private: | ||
typedef SkDrawFilter INHERITED; | ||
}; | ||
|
||
} // namespace skia | ||
|
||
#endif // SKIA_EXT_PAINT_SIMPLIFIER_H | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters