code style
git-svn-id: http://skia.googlecode.com/svn/trunk@1153 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
6b7aee387d
commit
feb8cc870d
@ -23,13 +23,13 @@ bool SkColorFilter::asColorMode(SkColor* color, SkXfermode::Mode* mode) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkColorFilter::filterSpan16(const uint16_t s[], int count, uint16_t d[])
|
void SkColorFilter::filterSpan16(const uint16_t s[], int count, uint16_t d[]) {
|
||||||
{
|
|
||||||
SkASSERT(this->getFlags() & SkColorFilter::kHasFilter16_Flag);
|
SkASSERT(this->getFlags() & SkColorFilter::kHasFilter16_Flag);
|
||||||
SkASSERT(!"missing implementation of SkColorFilter::filterSpan16");
|
SkASSERT(!"missing implementation of SkColorFilter::filterSpan16");
|
||||||
|
|
||||||
if (d != s)
|
if (d != s) {
|
||||||
memcpy(d, s, count * sizeof(uint16_t));
|
memcpy(d, s, count * sizeof(uint16_t));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SkColor SkColorFilter::filterColor(SkColor c) {
|
SkColor SkColorFilter::filterColor(SkColor c) {
|
||||||
@ -40,76 +40,66 @@ SkColor SkColorFilter::filterColor(SkColor c) {
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
SkFilterShader::SkFilterShader(SkShader* shader, SkColorFilter* filter)
|
SkFilterShader::SkFilterShader(SkShader* shader, SkColorFilter* filter) {
|
||||||
{
|
|
||||||
fShader = shader; shader->ref();
|
fShader = shader; shader->ref();
|
||||||
fFilter = filter; filter->ref();
|
fFilter = filter; filter->ref();
|
||||||
}
|
}
|
||||||
|
|
||||||
SkFilterShader::SkFilterShader(SkFlattenableReadBuffer& buffer) :
|
SkFilterShader::SkFilterShader(SkFlattenableReadBuffer& buffer) :
|
||||||
INHERITED(buffer)
|
INHERITED(buffer) {
|
||||||
{
|
|
||||||
fShader = static_cast<SkShader*>(buffer.readFlattenable());
|
fShader = static_cast<SkShader*>(buffer.readFlattenable());
|
||||||
fFilter = static_cast<SkColorFilter*>(buffer.readFlattenable());
|
fFilter = static_cast<SkColorFilter*>(buffer.readFlattenable());
|
||||||
}
|
}
|
||||||
|
|
||||||
SkFilterShader::~SkFilterShader()
|
SkFilterShader::~SkFilterShader() {
|
||||||
{
|
|
||||||
fFilter->unref();
|
fFilter->unref();
|
||||||
fShader->unref();
|
fShader->unref();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkFilterShader::beginSession()
|
void SkFilterShader::beginSession() {
|
||||||
{
|
|
||||||
this->INHERITED::beginSession();
|
this->INHERITED::beginSession();
|
||||||
fShader->beginSession();
|
fShader->beginSession();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkFilterShader::endSession()
|
void SkFilterShader::endSession() {
|
||||||
{
|
|
||||||
fShader->endSession();
|
fShader->endSession();
|
||||||
this->INHERITED::endSession();
|
this->INHERITED::endSession();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkFilterShader::flatten(SkFlattenableWriteBuffer& buffer)
|
void SkFilterShader::flatten(SkFlattenableWriteBuffer& buffer) {
|
||||||
{
|
|
||||||
this->INHERITED::flatten(buffer);
|
this->INHERITED::flatten(buffer);
|
||||||
buffer.writeFlattenable(fShader);
|
buffer.writeFlattenable(fShader);
|
||||||
buffer.writeFlattenable(fFilter);
|
buffer.writeFlattenable(fFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t SkFilterShader::getFlags()
|
uint32_t SkFilterShader::getFlags() {
|
||||||
{
|
|
||||||
uint32_t shaderF = fShader->getFlags();
|
uint32_t shaderF = fShader->getFlags();
|
||||||
uint32_t filterF = fFilter->getFlags();
|
uint32_t filterF = fFilter->getFlags();
|
||||||
|
|
||||||
// if the filter doesn't support 16bit, clear the matching bit in the shader
|
// if the filter doesn't support 16bit, clear the matching bit in the shader
|
||||||
if (!(filterF & SkColorFilter::kHasFilter16_Flag))
|
if (!(filterF & SkColorFilter::kHasFilter16_Flag)) {
|
||||||
shaderF &= ~SkShader::kHasSpan16_Flag;
|
shaderF &= ~SkShader::kHasSpan16_Flag;
|
||||||
|
}
|
||||||
// if the filter might change alpha, clear the opaque flag in the shader
|
// if the filter might change alpha, clear the opaque flag in the shader
|
||||||
if (!(filterF & SkColorFilter::kAlphaUnchanged_Flag))
|
if (!(filterF & SkColorFilter::kAlphaUnchanged_Flag)) {
|
||||||
shaderF &= ~(SkShader::kOpaqueAlpha_Flag | SkShader::kHasSpan16_Flag);
|
shaderF &= ~(SkShader::kOpaqueAlpha_Flag | SkShader::kHasSpan16_Flag);
|
||||||
|
}
|
||||||
return shaderF;
|
return shaderF;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SkFilterShader::setContext(const SkBitmap& device,
|
bool SkFilterShader::setContext(const SkBitmap& device,
|
||||||
const SkPaint& paint,
|
const SkPaint& paint,
|
||||||
const SkMatrix& matrix)
|
const SkMatrix& matrix) {
|
||||||
{
|
|
||||||
return this->INHERITED::setContext(device, paint, matrix) &&
|
return this->INHERITED::setContext(device, paint, matrix) &&
|
||||||
fShader->setContext(device, paint, matrix);
|
fShader->setContext(device, paint, matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkFilterShader::shadeSpan(int x, int y, SkPMColor result[], int count)
|
void SkFilterShader::shadeSpan(int x, int y, SkPMColor result[], int count) {
|
||||||
{
|
|
||||||
fShader->shadeSpan(x, y, result, count);
|
fShader->shadeSpan(x, y, result, count);
|
||||||
fFilter->filterSpan(result, count, result);
|
fFilter->filterSpan(result, count, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkFilterShader::shadeSpan16(int x, int y, uint16_t result[], int count)
|
void SkFilterShader::shadeSpan16(int x, int y, uint16_t result[], int count) {
|
||||||
{
|
|
||||||
SkASSERT(fShader->getFlags() & SkShader::kHasSpan16_Flag);
|
SkASSERT(fShader->getFlags() & SkShader::kHasSpan16_Flag);
|
||||||
SkASSERT(fFilter->getFlags() & SkColorFilter::kHasFilter16_Flag);
|
SkASSERT(fFilter->getFlags() & SkColorFilter::kHasFilter16_Flag);
|
||||||
|
|
||||||
|
@ -22,33 +22,31 @@
|
|||||||
#include "SkDraw.h"
|
#include "SkDraw.h"
|
||||||
#include "SkRegion.h"
|
#include "SkRegion.h"
|
||||||
|
|
||||||
bool SkMaskFilter::filterMask(SkMask*, const SkMask&, const SkMatrix&, SkIPoint*)
|
bool SkMaskFilter::filterMask(SkMask*, const SkMask&, const SkMatrix&,
|
||||||
{
|
SkIPoint*) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SkMaskFilter::filterPath(const SkPath& devPath, const SkMatrix& matrix,
|
bool SkMaskFilter::filterPath(const SkPath& devPath, const SkMatrix& matrix,
|
||||||
const SkRegion& clip, SkBounder* bounder,
|
const SkRegion& clip, SkBounder* bounder,
|
||||||
SkBlitter* blitter)
|
SkBlitter* blitter) {
|
||||||
{
|
|
||||||
SkMask srcM, dstM;
|
SkMask srcM, dstM;
|
||||||
|
|
||||||
if (!SkDraw::DrawToMask(devPath, &clip.getBounds(), this, &matrix, &srcM,
|
if (!SkDraw::DrawToMask(devPath, &clip.getBounds(), this, &matrix, &srcM,
|
||||||
SkMask::kComputeBoundsAndRenderImage_CreateMode))
|
SkMask::kComputeBoundsAndRenderImage_CreateMode)) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SkAutoMaskImage autoSrc(&srcM, false);
|
SkAutoMaskImage autoSrc(&srcM, false);
|
||||||
|
|
||||||
if (!this->filterMask(&dstM, srcM, matrix, NULL))
|
if (!this->filterMask(&dstM, srcM, matrix, NULL)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
SkAutoMaskImage autoDst(&dstM, false);
|
SkAutoMaskImage autoDst(&dstM, false);
|
||||||
SkRegion::Cliperator clipper(clip, dstM.fBounds);
|
SkRegion::Cliperator clipper(clip, dstM.fBounds);
|
||||||
|
|
||||||
if (!clipper.done() && (bounder == NULL || bounder->doIRect(dstM.fBounds)))
|
if (!clipper.done() && (bounder == NULL || bounder->doIRect(dstM.fBounds))) {
|
||||||
{
|
|
||||||
const SkIRect& cr = clipper.rect();
|
const SkIRect& cr = clipper.rect();
|
||||||
do {
|
do {
|
||||||
blitter->blitMask(dstM, cr);
|
blitter->blitMask(dstM, cr);
|
||||||
|
@ -19,19 +19,17 @@
|
|||||||
#include "SkPath.h"
|
#include "SkPath.h"
|
||||||
#include "SkBuffer.h"
|
#include "SkBuffer.h"
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
SkPairPathEffect::SkPairPathEffect(SkPathEffect* pe0, SkPathEffect* pe1)
|
SkPairPathEffect::SkPairPathEffect(SkPathEffect* pe0, SkPathEffect* pe1)
|
||||||
: fPE0(pe0), fPE1(pe1)
|
: fPE0(pe0), fPE1(pe1) {
|
||||||
{
|
|
||||||
SkASSERT(pe0);
|
SkASSERT(pe0);
|
||||||
SkASSERT(pe1);
|
SkASSERT(pe1);
|
||||||
fPE0->ref();
|
fPE0->ref();
|
||||||
fPE1->ref();
|
fPE1->ref();
|
||||||
}
|
}
|
||||||
|
|
||||||
SkPairPathEffect::~SkPairPathEffect()
|
SkPairPathEffect::~SkPairPathEffect() {
|
||||||
{
|
|
||||||
fPE0->unref();
|
fPE0->unref();
|
||||||
fPE1->unref();
|
fPE1->unref();
|
||||||
}
|
}
|
||||||
@ -39,62 +37,63 @@ SkPairPathEffect::~SkPairPathEffect()
|
|||||||
/*
|
/*
|
||||||
Format: [oe0-factory][pe1-factory][pe0-size][pe0-data][pe1-data]
|
Format: [oe0-factory][pe1-factory][pe0-size][pe0-data][pe1-data]
|
||||||
*/
|
*/
|
||||||
void SkPairPathEffect::flatten(SkFlattenableWriteBuffer& buffer)
|
void SkPairPathEffect::flatten(SkFlattenableWriteBuffer& buffer) {
|
||||||
{
|
|
||||||
buffer.writeFlattenable(fPE0);
|
buffer.writeFlattenable(fPE0);
|
||||||
buffer.writeFlattenable(fPE1);
|
buffer.writeFlattenable(fPE1);
|
||||||
}
|
}
|
||||||
|
|
||||||
SkPairPathEffect::SkPairPathEffect(SkFlattenableReadBuffer& buffer)
|
SkPairPathEffect::SkPairPathEffect(SkFlattenableReadBuffer& buffer) {
|
||||||
{
|
|
||||||
fPE0 = (SkPathEffect*)buffer.readFlattenable();
|
fPE0 = (SkPathEffect*)buffer.readFlattenable();
|
||||||
fPE1 = (SkPathEffect*)buffer.readFlattenable();
|
fPE1 = (SkPathEffect*)buffer.readFlattenable();
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
bool SkComposePathEffect::filterPath(SkPath* dst, const SkPath& src, SkScalar* width)
|
bool SkComposePathEffect::filterPath(SkPath* dst, const SkPath& src,
|
||||||
{
|
SkScalar* width) {
|
||||||
SkPath tmp;
|
SkPath tmp;
|
||||||
const SkPath* ptr = &src;
|
const SkPath* ptr = &src;
|
||||||
|
|
||||||
if (fPE1->filterPath(&tmp, src, width))
|
if (fPE1->filterPath(&tmp, src, width)) {
|
||||||
ptr = &tmp;
|
ptr = &tmp;
|
||||||
|
}
|
||||||
return fPE0->filterPath(dst, *ptr, width);
|
return fPE0->filterPath(dst, *ptr, width);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
bool SkSumPathEffect::filterPath(SkPath* dst, const SkPath& src, SkScalar* width)
|
bool SkSumPathEffect::filterPath(SkPath* dst, const SkPath& src,
|
||||||
{
|
SkScalar* width) {
|
||||||
// use bit-or so that we always call both, even if the first one succeeds
|
// use bit-or so that we always call both, even if the first one succeeds
|
||||||
return fPE0->filterPath(dst, src, width) | fPE1->filterPath(dst, src, width);
|
return fPE0->filterPath(dst, src, width) | fPE1->filterPath(dst, src, width);
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "SkStroke.h"
|
#include "SkStroke.h"
|
||||||
|
|
||||||
SkStrokePathEffect::SkStrokePathEffect(const SkPaint& paint)
|
SkStrokePathEffect::SkStrokePathEffect(const SkPaint& paint)
|
||||||
: fWidth(paint.getStrokeWidth()), fMiter(paint.getStrokeMiter()),
|
: fWidth(paint.getStrokeWidth()), fMiter(paint.getStrokeMiter()),
|
||||||
fStyle(SkToU8(paint.getStyle())), fJoin(SkToU8(paint.getStrokeJoin())), fCap(SkToU8(paint.getStrokeCap()))
|
fStyle(SkToU8(paint.getStyle())), fJoin(SkToU8(paint.getStrokeJoin())),
|
||||||
{
|
fCap(SkToU8(paint.getStrokeCap())) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SkStrokePathEffect::SkStrokePathEffect(SkScalar width, SkPaint::Style style, SkPaint::Join join, SkPaint::Cap cap, SkScalar miter)
|
SkStrokePathEffect::SkStrokePathEffect(SkScalar width, SkPaint::Style style,
|
||||||
: fWidth(width), fMiter(miter), fStyle(SkToU8(style)), fJoin(SkToU8(join)), fCap(SkToU8(cap))
|
SkPaint::Join join, SkPaint::Cap cap, SkScalar miter)
|
||||||
{
|
: fWidth(width), fMiter(miter), fStyle(SkToU8(style)),
|
||||||
if (miter < 0) // signal they want the default
|
fJoin(SkToU8(join)), fCap(SkToU8(cap)) {
|
||||||
|
if (miter < 0) { // signal they want the default
|
||||||
fMiter = SK_DefaultMiterLimit;
|
fMiter = SK_DefaultMiterLimit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SkStrokePathEffect::filterPath(SkPath* dst, const SkPath& src, SkScalar* width)
|
bool SkStrokePathEffect::filterPath(SkPath* dst, const SkPath& src,
|
||||||
{
|
SkScalar* width) {
|
||||||
if (fWidth < 0 || fStyle == SkPaint::kFill_Style)
|
if (fWidth < 0 || fStyle == SkPaint::kFill_Style) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (fStyle == SkPaint::kStroke_Style && fWidth == 0) // hairline
|
if (fStyle == SkPaint::kStroke_Style && fWidth == 0) { // hairline
|
||||||
{
|
|
||||||
*width = 0;
|
*width = 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -111,18 +110,15 @@ bool SkStrokePathEffect::filterPath(SkPath* dst, const SkPath& src, SkScalar* wi
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
SkFlattenable::Factory SkStrokePathEffect::getFactory()
|
SkFlattenable::Factory SkStrokePathEffect::getFactory() {
|
||||||
{
|
|
||||||
return CreateProc;
|
return CreateProc;
|
||||||
}
|
}
|
||||||
|
|
||||||
SkFlattenable* SkStrokePathEffect::CreateProc(SkFlattenableReadBuffer& buffer)
|
SkFlattenable* SkStrokePathEffect::CreateProc(SkFlattenableReadBuffer& buffer) {
|
||||||
{
|
|
||||||
return SkNEW_ARGS(SkStrokePathEffect, (buffer));
|
return SkNEW_ARGS(SkStrokePathEffect, (buffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkStrokePathEffect::flatten(SkFlattenableWriteBuffer& buffer)
|
void SkStrokePathEffect::flatten(SkFlattenableWriteBuffer& buffer) {
|
||||||
{
|
|
||||||
buffer.writeScalar(fWidth);
|
buffer.writeScalar(fWidth);
|
||||||
buffer.writeScalar(fMiter);
|
buffer.writeScalar(fMiter);
|
||||||
buffer.write8(fStyle);
|
buffer.write8(fStyle);
|
||||||
@ -130,8 +126,7 @@ void SkStrokePathEffect::flatten(SkFlattenableWriteBuffer& buffer)
|
|||||||
buffer.write8(fCap);
|
buffer.write8(fCap);
|
||||||
}
|
}
|
||||||
|
|
||||||
SkStrokePathEffect::SkStrokePathEffect(SkFlattenableReadBuffer& buffer)
|
SkStrokePathEffect::SkStrokePathEffect(SkFlattenableReadBuffer& buffer) {
|
||||||
{
|
|
||||||
fWidth = buffer.readScalar();
|
fWidth = buffer.readScalar();
|
||||||
fMiter = buffer.readScalar();
|
fMiter = buffer.readScalar();
|
||||||
fStyle = buffer.readU8();
|
fStyle = buffer.readU8();
|
||||||
@ -139,4 +134,3 @@ SkStrokePathEffect::SkStrokePathEffect(SkFlattenableReadBuffer& buffer)
|
|||||||
fCap = buffer.readU8();
|
fCap = buffer.readU8();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,21 +25,19 @@ SkRasterizer::SkRasterizer(SkFlattenableReadBuffer&) {}
|
|||||||
|
|
||||||
bool SkRasterizer::rasterize(const SkPath& fillPath, const SkMatrix& matrix,
|
bool SkRasterizer::rasterize(const SkPath& fillPath, const SkMatrix& matrix,
|
||||||
const SkIRect* clipBounds, SkMaskFilter* filter,
|
const SkIRect* clipBounds, SkMaskFilter* filter,
|
||||||
SkMask* mask, SkMask::CreateMode mode)
|
SkMask* mask, SkMask::CreateMode mode) {
|
||||||
{
|
|
||||||
SkIRect storage;
|
SkIRect storage;
|
||||||
|
|
||||||
if (clipBounds && filter && SkMask::kJustRenderImage_CreateMode != mode)
|
if (clipBounds && filter && SkMask::kJustRenderImage_CreateMode != mode) {
|
||||||
{
|
|
||||||
SkIPoint margin;
|
SkIPoint margin;
|
||||||
SkMask srcM, dstM;
|
SkMask srcM, dstM;
|
||||||
|
|
||||||
srcM.fFormat = SkMask::kA8_Format;
|
srcM.fFormat = SkMask::kA8_Format;
|
||||||
srcM.fBounds.set(0, 0, 1, 1);
|
srcM.fBounds.set(0, 0, 1, 1);
|
||||||
srcM.fImage = NULL;
|
srcM.fImage = NULL;
|
||||||
if (!filter->filterMask(&dstM, srcM, matrix, &margin))
|
if (!filter->filterMask(&dstM, srcM, matrix, &margin)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
storage = *clipBounds;
|
storage = *clipBounds;
|
||||||
storage.inset(-margin.fX, -margin.fY);
|
storage.inset(-margin.fX, -margin.fY);
|
||||||
clipBounds = &storage;
|
clipBounds = &storage;
|
||||||
@ -52,8 +50,7 @@ bool SkRasterizer::rasterize(const SkPath& fillPath, const SkMatrix& matrix,
|
|||||||
*/
|
*/
|
||||||
bool SkRasterizer::onRasterize(const SkPath& fillPath, const SkMatrix& matrix,
|
bool SkRasterizer::onRasterize(const SkPath& fillPath, const SkMatrix& matrix,
|
||||||
const SkIRect* clipBounds,
|
const SkIRect* clipBounds,
|
||||||
SkMask* mask, SkMask::CreateMode mode)
|
SkMask* mask, SkMask::CreateMode mode) {
|
||||||
{
|
|
||||||
SkPath devPath;
|
SkPath devPath;
|
||||||
|
|
||||||
fillPath.transform(matrix, &devPath);
|
fillPath.transform(matrix, &devPath);
|
||||||
|
Loading…
Reference in New Issue
Block a user