Result of running tools/sanitize_source_files.py (which was added in https://codereview.appspot.com/6465078/)
This CL is part II of IV (I broke down the 1280 files into 4 CLs).
Review URL: https://codereview.appspot.com/6474054
git-svn-id: http://skia.googlecode.com/svn/trunk@5263 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/experimental/DrawingBoard/SampleDrawingClient.cpp b/experimental/DrawingBoard/SampleDrawingClient.cpp
index 02b7a3b..fbefbc8 100644
--- a/experimental/DrawingBoard/SampleDrawingClient.cpp
+++ b/experimental/DrawingBoard/SampleDrawingClient.cpp
@@ -12,22 +12,22 @@
/**
* Drawing Client
*
- * A drawing client that allows a user to perform simple brush stokes with
- * a selected color and brush size. The drawing client communicates with a
+ * A drawing client that allows a user to perform simple brush stokes with
+ * a selected color and brush size. The drawing client communicates with a
* drawing server to send/receive data to/from other clients connected to the
* same server. The drawing client stores data in fData and fBuffer depending on
* the data type. Append type means that the drawing data is a completed stroke
- * and Replace type means that the drawing data is in progress and will be
- * replaced by subsequent data. fData and fBuffer are read by a pipe reader and
+ * and Replace type means that the drawing data is in progress and will be
+ * replaced by subsequent data. fData and fBuffer are read by a pipe reader and
* reproduce the drawing. When the client is in a normal state, the data stored
* on the client and the server should be identical.
* The drawing client is also able to switch between vector and bitmap drawing.
* The drawing client also renders the latest drawing stroke locally in order to
- * produce better reponses. This can be disabled by calling
- * controller.disablePlayBack(), which will introduce a lag between the input
+ * produce better reponses. This can be disabled by calling
+ * controller.disablePlayBack(), which will introduce a lag between the input
* and the drawing.
* Note: in order to keep up with the drawing data, the client will try to read
- * a few times each frame in case more than one frame worth of data has been
+ * a few times each frame in case more than one frame worth of data has been
* received and render them together. This behavior can be adjusted by tweaking
* MAX_READ_PER_FRAME or disabled by turning fSync to false
*/
@@ -36,7 +36,7 @@
class DrawingClientView : public SampleView {
public:
- DrawingClientView() {
+ DrawingClientView() {
fSocket = NULL;
fTotalBytesRead = 0;
fPalette = new SkColorPalette;
@@ -57,29 +57,29 @@
fData.reset();
fBuffer.reset();
}
-
+
virtual void requestMenu(SkOSMenu* menu) {
menu->setTitle("Drawing Client");
- menu->appendTextField("Server IP", "Server IP", this->getSinkID(),
+ menu->appendTextField("Server IP", "Server IP", this->getSinkID(),
"IP address or hostname");
menu->appendSwitch("Vector", "Vector", this->getSinkID(), fVector);
- menu->appendSlider("Brush Size", "Brush Size", this->getSinkID(), 1.0,
+ menu->appendSlider("Brush Size", "Brush Size", this->getSinkID(), 1.0,
100.0, fBrushSize);
menu->appendSwitch("Anti-Aliasing", "AA", this->getSinkID(), fAA);
- menu->appendSwitch("Show Color Palette", "Palette", this->getSinkID(),
+ menu->appendSwitch("Show Color Palette", "Palette", this->getSinkID(),
fPaletteVisible);
menu->appendSwitch("Sync", "Sync", this->getSinkID(), fSync);
menu->appendAction("Clear", this->getSinkID());
}
-
+
protected:
-
+
static void readData(int cid, const void* data, size_t size,
SkSocket::DataType type, void* context) {
DrawingClientView* view = (DrawingClientView*)context;
view->onRead(cid, data, size, type);
}
-
+
void onRead(int cid, const void* data, size_t size, SkSocket::DataType type) {
if (size > 0) {
fBuffer.reset();
@@ -92,20 +92,20 @@
}
}
}
-
+
bool onQuery(SkEvent* evt) {
if (SampleCode::TitleQ(*evt)) {
SampleCode::TitleR(evt, "Drawing Client");
return true;
}
-
+
return this->INHERITED::onQuery(evt);
}
-
+
bool onEvent(const SkEvent& evt) {;
if (SkOSMenu::FindSliderValue(evt, "Brush Size", &fBrushSize))
return true;
-
+
SkString s;
if (SkOSMenu::FindText(evt, "Server IP", &s)) {
if (NULL != fSocket) {
@@ -137,11 +137,11 @@
}
return this->INHERITED::onEvent(evt);
}
-
+
virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y) {
return new Click(this);
}
-
+
virtual bool onClick(SkView::Click* click) {
switch (click->fState) {
case SkView::Click::kDown_State:
@@ -161,20 +161,20 @@
}
return true;
}
-
+
virtual void onDrawContent(SkCanvas* canvas) {
if (fSocket) {
if (fSocket->isConnected()) {
if (fSync) {
int count = 0;
while (fSocket->readPacket(readData, this) > 0 &&
- count < MAX_READ_PER_FRAME)
+ count < MAX_READ_PER_FRAME)
++count;
}
- else
+ else
fSocket->readPacket(readData, this);
}
- else
+ else
fSocket->connectToServer();
}
size_t bytesRead = 0;
@@ -186,7 +186,7 @@
tempCanvas = canvas;
else
tempCanvas = &bufferCanvas;
- SkGPipeReader reader(tempCanvas);
+ SkGPipeReader reader(tempCanvas);
status = reader.playback(fData.begin() + fTotalBytesRead,
fData.count() - fTotalBytesRead,
&bytesRead);
@@ -197,22 +197,22 @@
fTotalBytesRead = 0;
else
canvas->drawBitmap(fBase, 0, 0, NULL);
-
+
size_t totalBytesRead = 0;
while (totalBytesRead < fBuffer.count()) {
SkGPipeReader reader(canvas);
- status = reader.playback(fBuffer.begin() + totalBytesRead,
- fBuffer.count() - totalBytesRead,
+ status = reader.playback(fBuffer.begin() + totalBytesRead,
+ fBuffer.count() - totalBytesRead,
&bytesRead);
SkASSERT(SkGPipeReader::kError_Status != status);
totalBytesRead += bytesRead;
}
-
+
SkNetPipeController controller(canvas);
SkGPipeWriter writer;
- SkCanvas* writerCanvas = writer.startRecording(&controller,
+ SkCanvas* writerCanvas = writer.startRecording(&controller,
SkGPipeWriter::kCrossProcess_Flag);
-
+
//controller.disablePlayback();
SkPaint p;
p.setColor(fPalette->getColor());
@@ -224,16 +224,16 @@
p.setPathEffect(new SkCornerPathEffect(55))->unref();
writerCanvas->drawPath(fCurrLine, p);
writer.endRecording();
-
+
controller.writeToSocket(fSocket, fType);
if (fType == SkSocket::kPipeAppend_type && fSocket) {
fSocket->suspendWrite();
fCurrLine.reset();
}
-
+
this->inval(NULL);
}
-
+
virtual void onSizeChange() {
this->INHERITED::onSizeChange();
fPalette->setLoc(this->width()-100, 0);
@@ -241,7 +241,7 @@
fBase.allocPixels(NULL);
this->clearBitmap();
}
-
+
private:
void clear() {
fData.reset();
@@ -267,7 +267,7 @@
bool fAA;
bool fSync;
bool fVector;
-
+
typedef SampleView INHERITED;
};
diff --git a/experimental/DrawingBoard/SampleDrawingServer.cpp b/experimental/DrawingBoard/SampleDrawingServer.cpp
index c79f8d3..fa059fa 100644
--- a/experimental/DrawingBoard/SampleDrawingServer.cpp
+++ b/experimental/DrawingBoard/SampleDrawingServer.cpp
@@ -11,14 +11,14 @@
/**
* Drawing Server
*
- * This simple drawing server can accept connections from multiple drawing
- * clients simultaneously. It accumulates drawing data from each client each
+ * This simple drawing server can accept connections from multiple drawing
+ * clients simultaneously. It accumulates drawing data from each client each
* frame, stores it in the appropriate place, and then broadcasts incremental
* changes back to all the clients. Each logical packet, meaning one brush
* stoke in this case can be of two types, append and replace. Append types are
* completed strokes ready to be stored in the fData queue and will no longer be
- * modified. Replace types are drawing operations that are still in progress on
- * the client side, so they are appended to fBuffer. The location and size of
+ * modified. Replace types are drawing operations that are still in progress on
+ * the client side, so they are appended to fBuffer. The location and size of
* the buffered data for each client is stored in a map and updated properly.
* Each time a new replace drawing call is received from a client, its previous
* buffered data is discarded.
@@ -28,7 +28,7 @@
class DrawingServerView : public SampleView {
public:
- DrawingServerView(){
+ DrawingServerView(){
fServer = new SkTCPServer(40000);
fServer->suspendWrite();
fTotalBytesRead = fTotalBytesWritten = 0;
@@ -40,24 +40,24 @@
fBuffer.reset();
fClientMap.clear();
}
-
+
virtual void requestMenu(SkOSMenu* menu) {
menu->setTitle("Drawing Server");
menu->appendAction("Clear", this->getSinkID());
menu->appendSwitch("Vector", "Vector", this->getSinkID(), fVector);
}
-
+
protected:
- static void readData(int cid, const void* data, size_t size,
+ static void readData(int cid, const void* data, size_t size,
SkSocket::DataType type, void* context) {
DrawingServerView* view = (DrawingServerView*)context;
view->onRead(cid, data, size, type);
}
-
+
void onRead(int cid, const void* data, size_t size, SkSocket::DataType type) {
if (NULL == data && size <= 0)
return;
-
+
ClientState* cs;
std::map<int, ClientState*>::iterator it = fClientMap.find(cid);
if (it == fClientMap.end()) { //New client
@@ -69,10 +69,10 @@
else {
cs = it->second;
}
-
+
if (type == SkSocket::kPipeReplace_type) {
fBuffer.remove(cs->bufferBase, cs->bufferSize);
-
+
for (it = fClientMap.begin(); it != fClientMap.end(); ++it) {
if (cid == it->first)
continue;
@@ -83,7 +83,7 @@
}
}
}
-
+
cs->bufferBase = fBuffer.count();
cs->bufferSize = size;
fBuffer.append(size, (const char*)data);
@@ -101,7 +101,7 @@
//other types of data
}
}
-
+
bool onQuery(SkEvent* evt) {
if (SampleCode::TitleQ(*evt)) {
SampleCode::TitleR(evt, "Drawing Server");
@@ -109,7 +109,7 @@
}
return this->INHERITED::onQuery(evt);
}
-
+
bool onEvent(const SkEvent& evt) {
if (SkOSMenu::FindAction(evt, "Clear")) {
this->clear();
@@ -121,8 +121,8 @@
}
return this->INHERITED::onEvent(evt);
}
-
-
+
+
virtual void onDrawContent(SkCanvas* canvas) {
if (fCurrMatrix != canvas->getTotalMatrix()) {
fTotalBytesRead = 0;
@@ -136,7 +136,7 @@
else {
fServer->suspendWrite();
}
-
+
size_t bytesRead;
SkGPipeReader::Status stat;
SkCanvas bufferCanvas(fBase);
@@ -159,7 +159,7 @@
} else {
canvas->drawBitmap(fBase, 0, 0, NULL);
}
-
+
size_t totalBytesRead = 0;
while (totalBytesRead < fBuffer.count()) {
SkGPipeReader reader(canvas);
@@ -169,22 +169,22 @@
SkASSERT(SkGPipeReader::kError_Status != stat);
totalBytesRead += bytesRead;
}
-
- fServer->writePacket(fBuffer.begin(), fBuffer.count(),
+
+ fServer->writePacket(fBuffer.begin(), fBuffer.count(),
SkSocket::kPipeReplace_type);
this->inval(NULL);
}
-
+
virtual void onSizeChange() {
this->INHERITED::onSizeChange();
- fBase.setConfig(SkBitmap::kARGB_8888_Config,
- this->width(),
+ fBase.setConfig(SkBitmap::kARGB_8888_Config,
+ this->width(),
this->height());
fBase.allocPixels(NULL);
this->clearBitmap();
}
-
+
private:
void clear() {
fData.reset();
@@ -197,12 +197,12 @@
fTotalBytesRead = 0;
fBase.eraseColor(fBGColor);
}
-
+
struct ClientState {
int bufferBase;
int bufferSize;
};
-
+
std::map<int, ClientState*> fClientMap;
SkTDArray<char> fData;
SkTDArray<char> fBuffer;
diff --git a/experimental/DrawingBoard/SkColorPalette.cpp b/experimental/DrawingBoard/SkColorPalette.cpp
index a7ceb2e..566c134 100644
--- a/experimental/DrawingBoard/SkColorPalette.cpp
+++ b/experimental/DrawingBoard/SkColorPalette.cpp
@@ -16,7 +16,7 @@
fGradientRect = SkRect::MakeWH(SkIntToScalar(100), SkIntToScalar(100));
fSelected = 0;
fCurrColor = 0xFF000000;
-
+
fColors[0] = SK_ColorWHITE;
fColors[1] = SK_ColorBLACK;
fColors[2] = SK_ColorRED;
@@ -27,15 +27,15 @@
bool SkColorPalette::onEvent(const SkEvent& evt) {
return this->INHERITED::onEvent(evt);
}
-
+
void SkColorPalette::onDraw(SkCanvas* canvas) {
canvas->drawColor(SK_ColorWHITE);
-
+
SkPaint paint;
paint.setAntiAlias(true);
-
+
canvas->translate(PalettePadding, PalettePadding);
-
+
for (int i = 0; i < PaletteSlots; ++i) {
if (fSelected == i) {
paint.setStrokeWidth(SkIntToScalar(3));
@@ -43,7 +43,7 @@
else {
paint.setStrokeWidth(1);
}
-
+
paint.setStyle(SkPaint::kStroke_Style);
paint.setColor(SK_ColorBLACK);
canvas->drawRect(fSlotRect, paint);
@@ -57,16 +57,16 @@
SkPoint p = SkPoint::Make(0,0);
SkPoint q = SkPoint::Make(this->width(), 0);
SkPoint pts[] = {p, q};
-
- SkColor colors[] = { SK_ColorRED, SK_ColorYELLOW, SK_ColorGREEN,
+
+ SkColor colors[] = { SK_ColorRED, SK_ColorYELLOW, SK_ColorGREEN,
SK_ColorCYAN, SK_ColorBLUE, SK_ColorMAGENTA,SK_ColorRED};
SkScalar colorPositions[] = { 0, 0.2, 0.4, 0.5, 0.6, 0.8, 1.0};
-
-
- SkShader* shader1 = SkGradientShader::CreateLinear(pts, colors, colorPositions,7,
+
+
+ SkShader* shader1 = SkGradientShader::CreateLinear(pts, colors, colorPositions,7,
SkShader::kMirror_TileMode);
paint.setShader(shader1)->unref();
-
+
canvas->drawRect(fGradientRect, paint);
//this->INHERITED::onDraw(canvas);
@@ -127,7 +127,7 @@
//account for padding
cursorPosition.fX -= PalettePadding;
cursorPosition.fY -= PalettePadding;
-
+
if (cursorPosition.fX < 0 || cursorPosition.fX > fSlotRect.width() ||
cursorPosition.fY < 0 || cursorPosition.fY > (fSlotRect.height() + PalettePadding) * PaletteSlots) {
return -1;
@@ -143,8 +143,8 @@
}
SkColor SkColorPalette::selectColorFromGradient(SkPoint& cursorPosition) {
- float h = cursorPosition.fX/fGradientRect.width();
- float s = 1.0 - cursorPosition.fY/fGradientRect.height();
+ float h = cursorPosition.fX/fGradientRect.width();
+ float s = 1.0 - cursorPosition.fY/fGradientRect.height();
float v = 1.0;
float _h,r,g,b;
float _1, _2, _3;
@@ -155,38 +155,38 @@
_1 = v * (1 - s);
_2 = v * (1 - s * (_h - _i));
_3 = v * (1 - s * (1 - (_h - _i)));
-
+
if (_i == 0) {
- r = v;
- g = _3;
+ r = v;
+ g = _3;
b = _1;
}
else if (_i == 1) {
- r = _2;
- g = v;
+ r = _2;
+ g = v;
b = _1;
}
else if (_i == 2) {
- r = _1;
- g = v;
+ r = _1;
+ g = v;
b = _3;
}
else if (_i == 3) {
- r = _1;
- g = _2;
+ r = _1;
+ g = _2;
b = v;
}
else if (_i == 4) {
- r = _3;
- g = _1;
+ r = _3;
+ g = _1;
b = v;
}
else {
- r = v;
- g = _1;
+ r = v;
+ g = _1;
b = _2;
};
-
+
SkColor retval = 0xFF000000;
retval += ((int)(r * 255) << 16);
retval += ((int)(g * 255) << 8);
diff --git a/experimental/DrawingBoard/SkNetPipeController.cpp b/experimental/DrawingBoard/SkNetPipeController.cpp
index 71db86a..a61ca64 100644
--- a/experimental/DrawingBoard/SkNetPipeController.cpp
+++ b/experimental/DrawingBoard/SkNetPipeController.cpp
@@ -21,13 +21,13 @@
int SkNetPipeController::writeToSocket(SkSocket* sockfd, SkSocket::DataType type) {
if (NULL != sockfd && fTotalWritten > 4)
return sockfd->writePacket(fBlock, fBytesWritten, type);
- else
+ else
return -1;
}
void* SkNetPipeController::requestBlock(size_t minRequest, size_t* actual) {
sk_free(fBlock);
-
+
fBlockSize = minRequest * 4;
fBlock = sk_malloc_throw(fBlockSize);
fBytesWritten = 0;
@@ -37,15 +37,15 @@
void SkNetPipeController::notifyWritten(size_t bytes) {
SkASSERT(fBytesWritten + bytes <= fBlockSize);
-
+
if (fPlayback) {
fStatus = fReader.playback((const char*)fBlock + fBytesWritten, bytes);
}
-
+
SkASSERT(SkGPipeReader::kError_Status != fStatus);
fBytesWritten += bytes;
fTotalWritten += bytes;
-
+
fAtomsWritten += 1;
}
diff --git a/experimental/DrawingBoard/SkNetPipeController.h b/experimental/DrawingBoard/SkNetPipeController.h
index 334fd8c..081239b 100644
--- a/experimental/DrawingBoard/SkNetPipeController.h
+++ b/experimental/DrawingBoard/SkNetPipeController.h
@@ -14,14 +14,14 @@
public:
SkNetPipeController(SkCanvas* target);
~SkNetPipeController();
-
+
virtual void* requestBlock(size_t minRequest, size_t* actual);
virtual void notifyWritten(size_t bytes);
-
+
int writeToSocket(SkSocket* sockfd, SkSocket::DataType type);
void enablePlayback() { fPlayback = true; }
void disablePlayback() { fPlayback = false; }
-
+
private:
SkGPipeReader fReader;
bool fPlayback;
@@ -30,7 +30,7 @@
size_t fBytesWritten;
int fAtomsWritten;
size_t fTotalWritten;
-
+
SkGPipeReader::Status fStatus;
};
#endif