in an effort to excise callers of setBitmapDevice, I think we can eliminate
the SkCanvas parameter altogether, and just put a temp one on the stack. Review URL: https://codereview.appspot.com/6571071 git-svn-id: http://skia.googlecode.com/svn/trunk@5730 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
67a97b3a56
commit
be584d7820
@ -9,18 +9,16 @@
|
|||||||
#include "SkStream.h"
|
#include "SkStream.h"
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
class SkCanvas;
|
|
||||||
struct State4;
|
struct State4;
|
||||||
|
|
||||||
//extern int comparePaths(const SkPath& one, const SkPath& two);
|
//extern int comparePaths(const SkPath& one, const SkPath& two);
|
||||||
extern int comparePaths(const SkPath& one, const SkPath& two, SkBitmap& bitmap,
|
extern int comparePaths(const SkPath& one, const SkPath& two, SkBitmap& bitmap);
|
||||||
SkCanvas* canvas);
|
|
||||||
extern void comparePathsTiny(const SkPath& one, const SkPath& two);
|
extern void comparePathsTiny(const SkPath& one, const SkPath& two);
|
||||||
extern bool drawAsciiPaths(const SkPath& one, const SkPath& two,
|
extern bool drawAsciiPaths(const SkPath& one, const SkPath& two,
|
||||||
bool drawPaths);
|
bool drawPaths);
|
||||||
extern void showPath(const SkPath& path, const char* str = NULL);
|
extern void showPath(const SkPath& path, const char* str = NULL);
|
||||||
extern bool testSimplify(const SkPath& path, bool fill, SkPath& out,
|
extern bool testSimplify(const SkPath& path, bool fill, SkPath& out,
|
||||||
SkBitmap& bitmap, SkCanvas* canvas = 0);
|
SkBitmap& bitmap);
|
||||||
extern bool testSimplifyx(SkPath& path, bool useXor, SkPath& out,
|
extern bool testSimplifyx(SkPath& path, bool useXor, SkPath& out,
|
||||||
State4& state, const char* pathStr);
|
State4& state, const char* pathStr);
|
||||||
extern bool testSimplifyx(const SkPath& path);
|
extern bool testSimplifyx(const SkPath& path);
|
||||||
@ -42,7 +40,6 @@ struct State4 {
|
|||||||
int testsRun;
|
int testsRun;
|
||||||
char filename[256];
|
char filename[256];
|
||||||
|
|
||||||
SkCanvas* canvas;
|
|
||||||
SkBitmap bitmap;
|
SkBitmap bitmap;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -74,18 +74,14 @@ void showPath(const SkPath& path, const char* str) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int pathsDrawTheSame(const SkPath& one, const SkPath& two,
|
static int pathsDrawTheSame(const SkPath& one, const SkPath& two,
|
||||||
SkBitmap& bits, SkCanvas* c, int& error2x2) {
|
SkBitmap& bits, int& error2x2) {
|
||||||
SkCanvas* canvasPtr = c;
|
|
||||||
if (!c) {
|
|
||||||
canvasPtr = new SkCanvas(bits);
|
|
||||||
}
|
|
||||||
const int bitWidth = 64;
|
const int bitWidth = 64;
|
||||||
const int bitHeight = 64;
|
const int bitHeight = 64;
|
||||||
if (bits.width() == 0) {
|
if (bits.width() == 0) {
|
||||||
bits.setConfig(SkBitmap::kARGB_8888_Config, bitWidth * 2, bitHeight);
|
bits.setConfig(SkBitmap::kARGB_8888_Config, bitWidth * 2, bitHeight);
|
||||||
bits.allocPixels();
|
bits.allocPixels();
|
||||||
canvasPtr->setBitmapDevice(bits);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SkRect larger = one.getBounds();
|
SkRect larger = one.getBounds();
|
||||||
larger.join(two.getBounds());
|
larger.join(two.getBounds());
|
||||||
SkScalar largerWidth = larger.width();
|
SkScalar largerWidth = larger.width();
|
||||||
@ -105,7 +101,8 @@ static int pathsDrawTheSame(const SkPath& one, const SkPath& two,
|
|||||||
one.transform(scale, &scaledOne);
|
one.transform(scale, &scaledOne);
|
||||||
two.transform(scale, &scaledTwo);
|
two.transform(scale, &scaledTwo);
|
||||||
const SkRect& bounds1 = scaledOne.getBounds();
|
const SkRect& bounds1 = scaledOne.getBounds();
|
||||||
SkCanvas& canvas = *canvasPtr;
|
|
||||||
|
SkCanvas canvas(bits);
|
||||||
canvas.drawColor(SK_ColorWHITE);
|
canvas.drawColor(SK_ColorWHITE);
|
||||||
SkPaint paint;
|
SkPaint paint;
|
||||||
canvas.save();
|
canvas.save();
|
||||||
@ -133,9 +130,6 @@ static int pathsDrawTheSame(const SkPath& one, const SkPath& two,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!c) {
|
|
||||||
delete canvasPtr;
|
|
||||||
}
|
|
||||||
if (errors2 >= 6 || errors > 160) {
|
if (errors2 >= 6 || errors > 160) {
|
||||||
SkDebugf("%s errors2=%d errors=%d\n", __FUNCTION__, errors2, errors);
|
SkDebugf("%s errors2=%d errors=%d\n", __FUNCTION__, errors2, errors);
|
||||||
}
|
}
|
||||||
@ -198,10 +192,9 @@ bool drawAsciiPaths(const SkPath& one, const SkPath& two, bool drawPaths) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int comparePaths(const SkPath& one, const SkPath& two, SkBitmap& bitmap,
|
int comparePaths(const SkPath& one, const SkPath& two, SkBitmap& bitmap) {
|
||||||
SkCanvas* canvas) {
|
|
||||||
int errors2x2;
|
int errors2x2;
|
||||||
int errors = pathsDrawTheSame(one, two, bitmap, canvas, errors2x2);
|
int errors = pathsDrawTheSame(one, two, bitmap, errors2x2);
|
||||||
if (errors2x2 == 0) {
|
if (errors2x2 == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -246,8 +239,7 @@ void comparePathsTiny(const SkPath& one, const SkPath& two) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool testSimplify(const SkPath& path, bool fill, SkPath& out, SkBitmap& bitmap,
|
bool testSimplify(const SkPath& path, bool fill, SkPath& out, SkBitmap& bitmap) {
|
||||||
SkCanvas* canvas) {
|
|
||||||
if (gShowPath) {
|
if (gShowPath) {
|
||||||
showPath(path);
|
showPath(path);
|
||||||
}
|
}
|
||||||
@ -255,7 +247,7 @@ bool testSimplify(const SkPath& path, bool fill, SkPath& out, SkBitmap& bitmap,
|
|||||||
if (!gComparePaths) {
|
if (!gComparePaths) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return comparePaths(path, out, bitmap, canvas) == 0;
|
return comparePaths(path, out, bitmap) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool testSimplifyx(SkPath& path, bool useXor, SkPath& out, State4& state,
|
bool testSimplifyx(SkPath& path, bool useXor, SkPath& out, State4& state,
|
||||||
@ -269,7 +261,7 @@ bool testSimplifyx(SkPath& path, bool useXor, SkPath& out, State4& state,
|
|||||||
if (!gComparePaths) {
|
if (!gComparePaths) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
int result = comparePaths(path, out, state.bitmap, state.canvas);
|
int result = comparePaths(path, out, state.bitmap);
|
||||||
if (result && gPathStrAssert) {
|
if (result && gPathStrAssert) {
|
||||||
SkDebugf("addTest %s\n", state.filename);
|
SkDebugf("addTest %s\n", state.filename);
|
||||||
char temp[8192];
|
char temp[8192];
|
||||||
@ -286,7 +278,7 @@ bool testSimplifyx(const SkPath& path) {
|
|||||||
SkPath out;
|
SkPath out;
|
||||||
simplifyx(path, out);
|
simplifyx(path, out);
|
||||||
SkBitmap bitmap;
|
SkBitmap bitmap;
|
||||||
int result = comparePaths(path, out, bitmap, 0);
|
int result = comparePaths(path, out, bitmap);
|
||||||
if (result && gPathStrAssert) {
|
if (result && gPathStrAssert) {
|
||||||
SkASSERT(0);
|
SkASSERT(0);
|
||||||
}
|
}
|
||||||
@ -308,7 +300,6 @@ pthread_cond_t State4::checkQueue = PTHREAD_COND_INITIALIZER;
|
|||||||
State4::State4() {
|
State4::State4() {
|
||||||
bitmap.setConfig(SkBitmap::kARGB_8888_Config, 150 * 2, 100);
|
bitmap.setConfig(SkBitmap::kARGB_8888_Config, 150 * 2, 100);
|
||||||
bitmap.allocPixels();
|
bitmap.allocPixels();
|
||||||
canvas = new SkCanvas(bitmap);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void createThread(State4* statePtr, void* (*testFun)(void* )) {
|
void createThread(State4* statePtr, void* (*testFun)(void* )) {
|
||||||
|
Loading…
Reference in New Issue
Block a user