Revert "CreatePlatformGLTestContext_egl:  Try GLES 3, then GLES 2."

This reverts commit 0593a840b107c1abd312a03ef4000ddb58454f94.

Reason for revert: Fails with Nexus7-GPU-Tegra3-arm

Original change's description:
> CreatePlatformGLTestContext_egl:  Try GLES 3, then GLES 2.
>
> Also cleanup.
>
> Change-Id: I186a7d7f509bc7852241c083414495b6182b916c
> Reviewed-on: https://skia-review.googlesource.com/115922
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Hal Canary <fd9641b23487c8ee78406c27513624c460600766@google.com>

TBR=bsalomon@google.com,fd9641b23487c8ee78406c27513624c460600766@google.com

Change-Id: I5f276a89d1b880212861986b5385e567ac884c62
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/116142
Reviewed-by: Hal Canary <fd9641b23487c8ee78406c27513624c460600766@google.com>
Commit-Queue: Hal Canary <fd9641b23487c8ee78406c27513624c460600766@google.com>

--- tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp
+++ tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp
@@ -72,26 +72,6 @@
     EGLSurface fSurface;
 };

-static EGLContext create_gles_egl_context(EGLDisplay display,
-                                          EGLConfig surfaceConfig,
-                                          EGLContext eglShareContext,
-                                          EGLint eglContextClientVersion) {
-    const EGLint contextAttribsForOpenGLES[] = {
-        EGL_CONTEXT_CLIENT_VERSION,
-        eglContextClientVersion,
-        EGL_NONE
-    };
-    return eglCreateContext(display, surfaceConfig, eglShareContext, contextAttribsForOpenGLES);
-}
-static EGLContext create_gl_egl_context(EGLDisplay display,
-                                        EGLConfig surfaceConfig,
-                                        EGLContext eglShareContext) {
-    const EGLint contextAttribsForOpenGL[] = {
-        EGL_NONE
-    };
-    return eglCreateContext(display, surfaceConfig, eglShareContext, contextAttribsForOpenGL);
-}
-
 EGLGLTestContext::EGLGLTestContext(GrGLStandard forcedGpuAPI, EGLGLTestContext* shareContext)
     : fContext(EGL_NO_CONTEXT)
     , fDisplay(EGL_NO_DISPLAY)
@@ -99,19 +79,43 @@

     EGLContext eglShareContext = shareContext ? shareContext->fContext : nullptr;

-    static const GrGLStandard kStandards[] = {
-        kGL_GrGLStandard,
-        kGLES_GrGLStandard,
+    static const EGLint kEGLContextAttribsForOpenGL[] = {
+        EGL_NONE
     };

-    size_t apiLimit = SK_ARRAY_COUNT(kStandards);
+    static const EGLint kEGLContextAttribsForOpenGLES[] = {
+        EGL_CONTEXT_CLIENT_VERSION, 2,
+        EGL_NONE
+    };
+
+    static const struct {
+        const EGLint* fContextAttribs;
+        EGLenum fAPI;
+        EGLint  fRenderableTypeBit;
+        GrGLStandard fStandard;
+    } kAPIs[] = {
+        {   // OpenGL
+            kEGLContextAttribsForOpenGL,
+            EGL_OPENGL_API,
+            EGL_OPENGL_BIT,
+            kGL_GrGLStandard
+        },
+        {   // OpenGL ES. This seems to work for both ES2 and 3 (when available).
+            kEGLContextAttribsForOpenGLES,
+            EGL_OPENGL_ES_API,
+            EGL_OPENGL_ES2_BIT,
+            kGLES_GrGLStandard
+        },
+    };
+
+    size_t apiLimit = SK_ARRAY_COUNT(kAPIs);
     size_t api = 0;
     if (forcedGpuAPI == kGL_GrGLStandard) {
         apiLimit = 1;
     } else if (forcedGpuAPI == kGLES_GrGLStandard) {
         api = 1;
     }
-    SkASSERT(forcedGpuAPI == kNone_GrGLStandard || kStandards[api] == forcedGpuAPI);
+    SkASSERT(forcedGpuAPI == kNone_GrGLStandard || kAPIs[api].fStandard == forcedGpuAPI);

     sk_sp<const GrGLInterface> gl;

@@ -128,16 +132,15 @@
         SkDebugf("VERSION: %s\n", eglQueryString(fDisplay, EGL_VERSION));
         SkDebugf("EXTENSIONS %s\n", eglQueryString(fDisplay, EGL_EXTENSIONS));
 #endif
-        bool gles = kGLES_GrGLStandard == kStandards[api];
-
-        if (!eglBindAPI(gles ? EGL_OPENGL_ES_API : EGL_OPENGL_API)) {
+
+        if (!eglBindAPI(kAPIs[api].fAPI)) {
             continue;
         }

         EGLint numConfigs = 0;
         const EGLint configAttribs[] = {
             EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
-            EGL_RENDERABLE_TYPE, gles ? EGL_OPENGL_ES2_BIT : EGL_OPENGL_BIT,
+            EGL_RENDERABLE_TYPE, kAPIs[api].fRenderableTypeBit,
             EGL_RED_SIZE, 8,
             EGL_GREEN_SIZE, 8,
             EGL_BLUE_SIZE, 8,
@@ -156,14 +159,8 @@
             continue;
         }

-        if (gles) {
-            fContext = create_gles_egl_context(fDisplay, surfaceConfig, eglShareContext, 3);
-            if (EGL_NO_CONTEXT == fContext) {
-                fContext = create_gles_egl_context(fDisplay, surfaceConfig, eglShareContext, 2);
-            }
-        } else {
-            fContext = create_gl_egl_context(fDisplay, surfaceConfig, eglShareContext);
-        }
+        fContext = eglCreateContext(fDisplay, surfaceConfig, eglShareContext,
+                                    kAPIs[api].fContextAttribs);
         if (EGL_NO_CONTEXT == fContext) {
             SkDebugf("eglCreateContext failed.  EGL Error: 0x%08x\n", eglGetError());
             continue;


updated to use ofImageQualityTypes in setup

--- ofxVideoRecorderExample/src/testApp.cpp
+++ ofxVideoRecorderExample/src/testApp.cpp
@@ -5,7 +5,9 @@
     ofSetLogLevel(OF_LOG_NOTICE);
      vidGrabber.setDesiredFrameRate(60);
     vidGrabber.initGrabber(640, 480);
-    vidRecorder.setup("testMovie.mov", vidGrabber.width, vidGrabber.height, 60, JPEG_QUALITYSUPERB);
+    vidRecorder.setup("testMovie.mov", vidGrabber.getWidth(), vidGrabber.getHeight(), 60, OF_IMAGE_QUALITY_HIGH);
+
+    ofSetWindowShape(640,480);
 }

 void testApp::exit() {
@@ -18,14 +20,14 @@
     if(vidGrabber.isFrameNew()) {
         vidRecorder.addFrame(vidGrabber.getPixelsRef());
     }
-    char title[256];
-    sprintf(title,"%d/%d=%.2f, %.2f", vidRecorder.getNumFramesInQueue(), ofGetElapsedTimeMillis()/1000, vidRecorder.getNumFramesInQueue()/ofGetElapsedTimef(), ofGetFrameRate());
-    ofSetWindowTitle(ofToString(title));
 }

 //--------------------------------------------------------------
 void testApp::draw(){
     vidGrabber.draw(0,0);
+    char title[256];
+    sprintf(title,"frames in queue: %d\nfps: %.2f", vidRecorder.getNumFramesInQueue(), ofGetFrameRate());
+    ofDrawBitmapString(ofToString(title),20,20);
 }

 //--------------------------------------------------------------


Marking integers as unsigned to remove compiler warning

--- Ogitor/src/OgitorsRoot.cpp
+++ Ogitor/src/OgitorsRoot.cpp
@@ -188,7 +188,7 @@
     RegisterAllEditorObjects(pDisabledPluginPaths);

     OgitorsPropertyValueMap params;
-    unsigned int id = 2222222222;
+    unsigned int id = 2222222222u;
     params["object_id"] = OgitorsPropertyValue(PROP_UNSIGNED_INT, Ogre::Any(id));
     CBaseEditorFactory *factory = GetEditorObjectFactory("");
     mRootEditor = factory->CreateObject(0, params);
@@ -327,7 +327,7 @@
     }

     OgitorsPropertyValueMap params;
-    unsigned int id = 2222222222;
+    unsigned int id = 2222222222u;
     params["object_id"] = OgitorsPropertyValue(PROP_UNSIGNED_INT, Ogre::Any(id));
     CBaseEditorFactory *factory = GetEditorObjectFactory("");
     mRootEditor = factory->CreateObject(0, params);


Add parentheses around boolean operators in assert

This removes a warning and is generally a good practice.

PiperOrigin-RevId: 272613597

--- third_party/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp
+++ third_party/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp
@@ -659,8 +659,9 @@
            "unexpected dynamic offset");

     // 0-D memref corner case: they have size 1 ...
-    assert((type.getRank() == 0 && strides.empty() && sizes.size() == 1) ||
-           (strides.size() == sizes.size()) && "unexpected number of strides");
+    assert(((type.getRank() == 0 && strides.empty() && sizes.size() == 1) ||
+            (strides.size() == sizes.size())) &&
+           "unexpected number of strides");

     // Create the MemRef descriptor.
     auto structType = lowering.convertType(type);


Draw patching pointing upward.

Draw patching pointing upward.

--- viz/MLSMapVisualization.cpp
+++ viz/MLSMapVisualization.cpp
@@ -600,11 +600,13 @@
     minZ -= 5e-4f;
     maxZ += 5e-4f;
     Eigen::Vector3f normal = p.getNormal();
-    if(p.getNumerOfMeasurements() > minMeasurements)
+    if(normal.z() < 0)
+        normal *= -1.0;
+    if(p.getNumerOfMeasurements() >= minMeasurements)
     {
         if(normal.allFinite())
         {
-            geode.drawPlane(Eigen::Hyperplane<float, 3>(p.getNormal(), p.getCenter()), minZ, maxZ);
+            geode.drawPlane(Eigen::Hyperplane<float, 3>(normal, p.getCenter()), minZ, maxZ);
         }
         else
         {


Update RKP.cpp

Update RKP.cpp

--- library/CastleRKP/RKP.cpp
+++ library/CastleRKP/RKP.cpp
@@ -1,27 +1,18 @@
 /*
- * RKP.cpp - All the Remote Keypad comms and display commands
- *
- * Created: 3/30/2014 10:04:10 PM
- *
- *   Aritech Alarm Panel Arduino Internet Enabled Keypad -  CS350 - CD34 - CD72 - CD91 and more
- *
- *   For Arduino (UNO or Leonardo) with added Ethernet Shield
- *
- *   See Circuit Diagram for wiring instructions
- *
- *   Author: Ozmo
- *
- *   See: http://www.boards.ie/vbulletin/showthread.php?p=88215184
- *
+* SMTP.cpp
+*
+* Created: 4/5/2014 7:45:36 PM
+* Author: Ambrose
 */
+#include "limits.h"
+#include "SMTP.h"
+#include "Log.h"
+#include "Config.h"

-//change network settings to yours
-#include <Arduino.h>
-#include "RKP.h"
-#include "LOG.h"
-#include "Websocket.h"
-#include "SMTP.h"
-#include "Config.h"
+//for IPAddresss
+//#include "w5100.h"
+//#include "Ethernet.h"
+#include "IPAddress.h"

 //Workaround if needed for http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34734
@@ -30,353 +21,154 @@
 #define PROGMEM __attribute__((section(".progmem.data")))
 #endif

-#define nSerialBaudKP_RX 1953
-#define ixMaxPanel 40	//40 bytes enough

+int SMTP::nEmailStage=-1;
+EthernetClient SMTP::client;
+//long SMTP::mDelay=-1;
+unsigned long SMTP::mTimeout = LONG_MAX;
+boolean SMTP::bWaitForResponse = false;

-const prog_uchar allmonths[] = {"JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC"};
-const prog_uchar alldays[] = {"SUNMONTUEWEDTHUFRISAT"};
-
-String RKPClass::msKeyToSend="";
-bool RKPClass::dateFlash=true;
-bool RKPClass::mbIsPanelWarning=false;
-bool RKPClass::mbIsPanelAlarm=false;
+IPAddress SMTP::mSMTPServerIP;

-#define DISP_BUF_LEN 16+1+2		//16 characters - space - AW (will be followed by a Terminator 0)
-byte RKPClass::dispBuffer[DISP_BUF_LEN+1];
-
-
-//const char msgOff[] PROGMEM = "KeyPad OFF!";
-//const char msgOn[] PROGMEM = "KeyPad ON!";
-
-
-
-RKPClass::RKPClass()
+// protected constructor
+SMTP::SMTP()
 {
-	dispBuffer[16]='|';
-	dispBuffer[DISP_BUF_LEN]=0;
 }

-void RKPClass::loop_PanelMon(void)
+void SMTP::Init( IPAddress smptServerIP )
 {
-	static int msgbufLen = 0;
-	static byte msgbuf[ixMaxPanel];
-	static bool bReceivingPacketNow = false;
-
-	static byte lastByte=-1;
+	mSMTPServerIP = smptServerIP;
+}

-	//Note - nothing here is to be blocking
-	//- so sending emails must not block receiving serial logs
-
-	//Software UART not great at receiving for some reason :/ - ok for sending.
-	if (Serial1.available()==0)
-		return;
+void SMTP::QueueEmail()
+{
+#ifdef sEmail
+	LogLn(F("Sending Email."));
+	nEmailStage=0;
+#else
+	LogLn(F("Email Disabled."));
+#endif
+}

-	byte rx = Serial1.read();
-	//Log((char)rx);
-
-	if (bReceivingPacketNow == false)
-	{
-		if(lastByte == 0)
-		{//last char was a zero - this might be our header...
-			//It may be for us or not - but get whole message before testing so we stay in sync
-			bReceivingPacketNow = true;
-			msgbufLen=0;
-			//not necessary to balnk - but good for debug
-			for(int n=0;n<ixMaxPanel;n++)
-				msgbuf[n]=0xFF;
-			msgbuf[msgbufLen++]=rx;
-		}
-		lastByte = rx;
-		return; //wait for byte#3 (0,id,..)
+void SMTP::SendEmailProcess()
+{
+#ifdef sEmail
+
+	if(millis() > SMTP::mTimeout)
+	{//we have taken longer than 10 secs to send our email - reset and resend
+		LogLn(F("Email Reset."));
+		mTimeout=LONG_MAX; //dont reset again
+		nEmailStage=0;
+		client.println(F("QUIT"));
 	}
-	lastByte = rx;	//needed in case cs error
-
-	msgbuf[msgbufLen++]=rx;
-	if (rx!=0)
-	{//wasn't end of packet - is buffer full?
-		if (msgbufLen>=ixMaxPanel)
-		{//packet never terminated - bytes lost :(
-			Log("Buf overflow");
-			bReceivingPacketNow = false;
+
+	if (SMTP::bWaitForResponse)
+	{//We are awaiting a response
+		if (SMTP::WaitForReplyLine())
+			return;	//not yet - try next time
+	}
+
+	if (SMTP::nEmailStage==0)
+	{//Connect
+		SMTP::mTimeout = millis() + 10000; //10 sec to send...or will resend
+
+		LogLn(F("--Start SendMail--"));
+
+		Log(F("Cleaning buffers..{"));while(client.available()) Log(client.read()); LogLn("}");
+
+		LogLn(F("Connecting..."));
+		if(!client.connect(SMTP::mSMTPServerIP,25) /*|| !client.connected()*/)
+		{
+			LogLn(F("connection failed"));
 			return;
 		}
+		LogLn(F("Confirmed Connected"));
+		SMTP::bWaitForResponse=true;
+		return;
 	}
-	else
-	{//End of the packet
-		bReceivingPacketNow = false;

-		byte idDev = (msgbuf[0] & 0xf0)>>4; //ID of remote that message is for 0x0-0xf are valid ids
-
-		//Uncomment to Display all packets
-		//LogHex(msgbuf,msgbufLen);Log(F("DevID:"));LogLn(idDev);
+	if (nEmailStage==1)
+	{
+		LogLn(F("Sending helo"));
+		SMTP::client.println("helo 1.2.3.4");
+		SMTP::bWaitForResponse=true;
+		return;
+	}

-		byte cs = 0;
-		for(int n=0;n<msgbufLen;n++)
+	if (nEmailStage==2) //set to 20 to test retry
+	{
+		LogLn(F("From.."));
+		SMTP::client.println("MAIL From: "sEmail);	//(sender)
+		SMTP::bWaitForResponse=true;
+		return;
+	}
+
+	if (nEmailStage==3)
+	{//recipient address
+		LogLn(F("To.."));
+		SMTP::client.println("RCPT To: "sEmail);		//client.println("RCPT To: <ambrosec@gmail.com>");
+		SMTP::bWaitForResponse=true;
+		return;
+	}
+
+	if (nEmailStage==4)
+	{
+		LogLn(F("Sending DATA"));
+		SMTP::client.println("DATA");
+		SMTP::bWaitForResponse=true;
+		return;
+	}
+
+	if (nEmailStage==5)
+	{
+		LogLn(F("Sending message"));
+		SMTP::client.println("To: "sEmail);
+		SMTP::client.println("From: TheHouse <" sEmail ">");
+		SMTP::client.println("Subject: House Calling. Alarm.\r\n");
+
 		{
-			byte rx = msgbuf[n];
-			if (n<msgbufLen-2) //dont sum cs or terminator
-				cs+=rx;
-			//Log((char)rx);
+			SMTP::client.println("The House Alarm has gone off\r\n");
+			SMTP::client.println("EndLog");
 		}
-		if (cs != msgbuf[msgbufLen-2])
+
+		SMTP::client.println(".");
+		SMTP::bWaitForResponse=true;
+		return;
+	}
+
+	if (nEmailStage==6)
+	{
+		SMTP::mTimeout = LONG_MAX; //cancel any timeout timer
+		LogLn(F("Sending QUIT"));
+		SMTP::client.println("QUIT");
+		SMTP::bWaitForResponse=true;
+		return;
+	}
+
+	if (nEmailStage==7)
+	{
+		SMTP::client.stop();
+		SMTP::nEmailStage=-1;
+		LogLn(F("disconnected"));
+		return;
+	}
+
+#endif
+}
+
+//return False and inc stage if we get a response - true if we are waiting
+boolean SMTP::WaitForReplyLine()
+{
+	if(client.connected() && client.available())
+	{
+		byte thisByte = client.read();
+		//Log(thisByte);
+		if (thisByte == '\n')
 		{
-			Log(F("CS Fail :( "));
-			//LogHex(msgbuf,msgbufLen);
-			Log(F("Dev:"));LogLn(idDev);
-			return;
-		}
-		//LogLn(F(""));
-
-		lastByte=-1; //good message - so waiting again for next zero
-
-		{//Send Email if alarm lights come on
-			bool bIsPanelWarning = (msgbuf[1] & 0x04) != 0;
-			if (bIsPanelWarning == true && RKPClass::mbIsPanelWarning == false)
-				SMTP::QueueEmail();
-			RKPClass::mbIsPanelWarning = bIsPanelWarning;
-
-			bool bIsPanelAlarm = (msgbuf[1] & 0x02) != 0;
-			if (bIsPanelAlarm == true && RKPClass::mbIsPanelAlarm == false)
-				SMTP::QueueEmail();
-			RKPClass::mbIsPanelAlarm = bIsPanelAlarm;
-		}
-
-		//for us?
-		if (idDev==RKP_ID)
-		{
-			DisplayScreen(msgbuf, msgbufLen); //try display what device 0 sees
-			bool bAck = (msgbuf[0] & 0x04) != 0;	//required for good comms
-			SendToPanel(RKP_ID, bAck);
-			LogLn("-OK-");
-		}
-		else
-		{
-			//LogLn("-Not for us-");
+			SMTP::nEmailStage++;
+			SMTP::bWaitForResponse = false;
+			return false;	//Good!
 		}
 	}
-
+	return true;
 }
-
-void RKPClass::DisplayScreen( byte* msgbuf, int msgbufLen )
-{
-	byte bufix=0;
-	//Force Screen clear each time
-	//for(int m=0;m<DISP_BUF_LEN;m++)
-	//	dispBuffer[m]='!';
-
-	//Checksum so can see if changes and need update client
-	static int previousCS =-1;
-
-	int ixMsgbuf=2;//skip 2 header bytes
-	msgbufLen-=2; //remove checksum and zero terminator
-
-	while(ixMsgbuf<msgbufLen)
-	{
-		byte rx = msgbuf[ixMsgbuf++];
-		if (rx>=0 && rx < 0x0f)
-		{//Switch language - not implemented - ignore this command
-		}
-		else if (rx == 0x13)
-		{//means will be no more text (but can be commands) - so do nothing?
-		}
-		else if (rx == 0x1b)
-		{// 0x1b=Next character is a Non-Eng characters - not implemented - ignore this command
-		}
-		else if (rx>= 0x20 && rx <= 0x7F)
-		{//Normal ASCII
-			if (bufix < DISP_BUF_LEN)
-				dispBuffer[bufix++]=(char)rx;
-		}
-		else if (rx>= 0x80 && rx <= 0x8F)
-		{//Date in encoded format
-			int b0=rx;
-			int b1=msgbuf[ixMsgbuf++];
-			int b2=msgbuf[ixMsgbuf++];
-			int b3=msgbuf[ixMsgbuf++];
-
-			byte nMonth= (b0 & 0x0f)-1;
-			byte day = (b1 & (128+64+32))>> 5;
-			byte date = (b1 & (31));
-			byte h1=(b2 & 0xf0)>>4; if(h1==0x0A) h1=0;
-			byte h2=(b2 & 0x0f); if(h2==0x0A) h2=0;
-			byte m1=(b3 & 0xf0)>>4; if(m1==0x0A) m1=0;
-			byte m2=(b3 & 0x0f); if(m2==0x0A) m2=0;
-
-			memcpy_P(dispBuffer+0,alldays+(day*3),3);
-			dispBuffer[3]=' ';
-			dispBuffer[4]=('0'+(int)(date/10));
-			dispBuffer[5]=('0'+(date%10));
-			dispBuffer[6]=' ';
-
-			memcpy_P(dispBuffer+7,allmonths+(nMonth*3),3);
-			dispBuffer[10]=' ';
-			dispBuffer[11]='0'+h1;
-			dispBuffer[12]='0'+h2;
-			//if (dateFlash)
-			dispBuffer[13]= ':';
-			//else
-			//	buffer[13]= F(' ');
-			//dateFlash=!dateFlash;
-			//buffer[13]= ((millis()/500)&1) ==0? ':':' ';
-			dispBuffer[14]='0'+m1;
-			dispBuffer[15]='0'+m2;
-			bufix=0;
-		}
-		else if (rx == 0x90)
-		{//CLS
-			bufix=0;
-			for(int m=0;m<DISP_BUF_LEN;m++)
-				dispBuffer[m]=' ';
-		}
-		else if (rx == 0x91)
-		{//HOME Maybe??
-			bufix=0;
-		}
-		else if (rx >= 0xA0 && rx <= 0xAf)
-		{//MOVE cursor to position x
-			bufix = (rx & 0x0f); //-1 gives us 2 *'s  but without -1 we go off screen at Login ***
-		}
-		else if (rx >= 0xB0 && rx <= 0xBF)
-		{//{BLINK_N}"	Bxh Blink x chars starting at current cursor position
-			//int nChars = (rx & 0x0f)-1;
-			//if (dateFlash)
-			//	buffer[i]= ':';
-			//else
-			//	buffer[i]= ' ';
-			//dateFlash=!dateFlash;
-		}
-		else if (rx >= 0xC0 && rx <= 0xCf)
-		{// Set position to x and clear all chars to right
-			int i = (rx & 0x0f);
-			if (i < DISP_BUF_LEN)
-				bufix = i;
-			for(int n=bufix;n<DISP_BUF_LEN;n++)
-				dispBuffer[bufix++]=' ';
-		}
-		else if (rx>= 0xE0 && rx <= 0xFF)
-		{// Special Characters Arrows and foreign chars
-			int i = (rx & 0x0f);
-
-			char c=0;
-			if (i==4)	c= '*';
-			else if (i==5)	c= '#';
-			else if (i==7)	c= '>';
-
-			if (c>0)
-				if (bufix < DISP_BUF_LEN)
-					dispBuffer[bufix++]=c;
-		}
-		else
-		{//unknown command
-			Log(F("{"));LogHex(rx);Log(F("}"));
-		}
-
-		//TODO: there are quite a few codes in Engineer menu to deal with flashing cursors and characters - cannot do easily in html
-		//might look at later.
-	}
-
-	dispBuffer[16]='|';	//this may overwrite a char sometimes...
-	dispBuffer[17]=(RKPClass::mbIsPanelAlarm)?'A':' ';
-	dispBuffer[18]=(RKPClass::mbIsPanelWarning)?'W':' ';
-
-	int cs=0;
-	for(int n=0;n<DISP_BUF_LEN;n++)
-		cs+=(char)dispBuffer[n];
-
-	if (cs != previousCS)
-	{
-		////Display as hex
-		LogHex(msgbuf, msgbufLen);
-		////Display as characters
-		for(int n=0;n<DISP_BUF_LEN;n++)	Log((char)dispBuffer[n]); LogLn(".");
-
-		previousCS=cs;
-		SendDisplayToBrowser();
-	}
-
-}
-
-char RKPClass::NextKeyPress()
-{
-	if (RKPClass::msKeyToSend.length() == 0)
-		return -1; //no keys
-	char next = RKPClass::msKeyToSend[0];
-	return next;
-}
-
-char RKPClass::PopKeyPress()
-{
-	char next = NextKeyPress();
-	if (next!=0xFF)//RKPClass::mnKeyToSend=0xff;
-		RKPClass::msKeyToSend = RKPClass::msKeyToSend.substring(1);
-	return next;
-}
-
-void RKPClass::PushKey( char key )
-{
-	if (RKPClass::msKeyToSend.length()<10)
-		RKPClass::msKeyToSend += key;
-}
-
-void RKPClass::SendToPanel( int id, bool bAck )
-{
-	//Log(F("Send: "));
-	#define H1_LIDTAMP 1
-	#define H1_BASE 2 //always set
-	#define H1_CD3008 0 //keypad with buzzer
-	#define H1_CD9038 4 //Keypad with 4 zones
-	#define H1_CD9041 8 //Glassbreak Expander with no keypad - works on cd34 but not cd72
-	static byte nH2Previous=-1;
-
-	byte h1 = H1_BASE + H1_CD3008 + (id<<4); //kKKK (Capital K is an Extender enabled keypad)
-	byte h2 = 0;
-
-	if (bAck)
-	//if (true)	//TODO: put back
-	{
-		//LogLn("Ack");
-		char nKeyToSend = PopKeyPress();
-		if (nKeyToSend!=0xff)
-		{
-			//nKeyToSend &= 0x20; //tolower
-			int nNumb=0x0e;
-			if (nKeyToSend >='1' && nKeyToSend <= '9')
-			nNumb = (nKeyToSend-'0');
-			else if (nKeyToSend == '0')	nNumb = 0x0a;
-			else if (nKeyToSend == 'f'||nKeyToSend == '*')	nNumb = 0x0b;	//UP  (* for IPhone)
-			else if (nKeyToSend == 'v'||nKeyToSend == '#')	nNumb = 0x0c;	//DOWN (# for IPhone)
-			else if (nKeyToSend == 'p')	nNumb = 0x0d;	//UP + DOWN (Panic)
-			else if (nKeyToSend == 'x'||nKeyToSend == ';'||nKeyToSend == 'n'||nKeyToSend == 'N')	nNumb = 0x0e;	//UP + 0 or X(reject) (WAIT on IPhone numpad)
-			else if (nKeyToSend == 13||nKeyToSend == '+'||nKeyToSend == 'y'||nKeyToSend == 'Y')	nNumb = 0x0f;	//UP + 0 or *(accept) (+ on IPhone numpad)
-
-			Log(F("Sent: ")); LogHex(nNumb);LogLn(F("."));
-
-			h2 = nNumb<<4;
-		}
-		nH2Previous = h2;
-	}
-	else
-	{
-		Log(F("Resend: ")); LogHex(nH2Previous>>4);LogLn(F("!"));
-		h2 = nH2Previous;
-	}
-
-	byte h3=0; byte h4=(byte)(h1+h2+h3);
-
-	Serial1.write((byte)(h1));
-	Serial1.write((byte)(h2));
-	Serial1.write((byte)(h3));
-	Serial1.write((byte)(h4));
-	//LogHex(h1); LogHex(h2); LogHex(h3); LogHex(h4); LogLn(".");
-}
-
-void RKPClass::Init()
-{
-	Serial1.begin(nSerialBaudKP_RX, SERIAL_8N2);	//RKP Comms
-}
-
-void RKPClass::SendDisplayToBrowser()
-{
-	WebSocket::WebSocket_send((char*)dispBuffer,DISP_BUF_LEN);
-}


FIX: Coverity 59474

FIX: Coverity 59474

--- cvmfs/catalog_mgr_rw.cc
+++ cvmfs/catalog_mgr_rw.cc
@@ -101,19 +101,18 @@
   string root_path = "";

   // Create the database schema and the inital root entry
-  CatalogDatabase *new_catalog_db = CatalogDatabase::Create(file_path);
-  if (NULL == new_catalog_db ||
-      ! new_catalog_db->InsertInitialValues(root_path,
-                                            volatile_content,
-                                            root_entry))
   {
-    LogCvmfs(kLogCatalog, kLogStderr, "creation of catalog '%s' failed",
-             file_path.c_str());
-    return NULL;
-  }
-
-  // closing the newly created catalog again
-  delete new_catalog_db;
+    UniquePtr<CatalogDatabase> new_clg_db(CatalogDatabase::Create(file_path));
+    if (! new_clg_db.IsValid() ||
+        ! new_clg_db->InsertInitialValues(root_path,
+                                          volatile_content,
+                                          root_entry))
+    {
+      LogCvmfs(kLogCatalog, kLogStderr, "creation of catalog '%s' failed",
+               file_path.c_str());
+      return NULL;
+    }
+  }

   // Compress root catalog;
   int64_t catalog_size = GetFileSize(file_path);


Fix cov 32841 (deref null return value)

Fix cov 32841 (deref null return value)

git-svn-id: acec3fd5b7ea1eb9e79d6329d318e8118ee2e14f@43270 27541ba8-7e3a-0410-8455-c3a389f83636

--- tree/tree/src/TTreeSQL.cxx
+++ tree/tree/src/TTreeSQL.cxx
@@ -749,7 +749,7 @@
    }

    Bool_t reset = false;
-   while ( fCurrentEntry < entry ) {
+   while ( fResult && fCurrentEntry < entry ) {
       ++fCurrentEntry;
       delete fRow;
       fRow = fResult->Next();


cosemtic

cosemtic

--- Library/Sources/Stroika/Foundation/Database/SQL/ODBC.cpp
+++ Library/Sources/Stroika/Foundation/Database/SQL/ODBC.cpp
@@ -36,15 +36,14 @@
     }
 }

-
 /*
  ********************************************************************************
  *************************** ODBC::Connection::Rep_ *****************************
  ********************************************************************************
  */
 struct Connection::Rep_ final : IRep {
-    SQLHDBC      fConnectionHandle{nullptr};
-    SQLHENV      fODBCEnvironmentHandle{nullptr};
+    SQLHDBC fConnectionHandle{nullptr};
+    SQLHENV fODBCEnvironmentHandle{nullptr};

     Rep_ (const Options& options)
     {
@@ -126,14 +125,14 @@
         struct MyEngineProperties_ final : EngineProperties {
             virtual String GetEngineName () const override
             {
-                return L"ODBC"sv;   // must indirect to connection to get more info (from dns at least? not clear)
+                return L"ODBC"sv; // must indirect to connection to get more info (from dns at least? not clear)
             }
             virtual bool SupportsNestedTransactions () const override
             {
                 return false;
             }
         };
-        return make_shared<const MyEngineProperties_> ();   // dynamic info based on connection/dsn
+        return make_shared<const MyEngineProperties_> (); // dynamic info based on connection/dsn
     }
     virtual SQL::Statement mkStatement (const String& sql) override
     {
@@ -150,9 +149,6 @@
         AssertNotImplemented ();
     }
 };
-
-
-

 /*
  ********************************************************************************
@@ -304,8 +300,6 @@
     : inherited{make_unique<MyRep_> (db)}
 {
 }
-
-

 /*
  ********************************************************************************


Ensure we make progress.

Ensure we make progress.

git-svn-id: 83c4c97093aeea62ac982fbfd516bf9db27f5c99@2278 c36c8488-0289-0348-9b64-b301f74bd9a7

--- Renderer/SBVRGeogen3D.cpp
+++ Renderer/SBVRGeogen3D.cpp
@@ -259,6 +259,7 @@

   float fDepth = m_fMaxZ;
   float fLayerDistance = GetLayerDistance();
+  assert(fLayerDistance > 0);

   // I hit this every time I fiddle with the integration of an
   // application.  If an app doesn't set brick metadata properly, we'll


I am slowly working my way down the coverage tests.  I noted that there was a branch that was missed and it was associated with receiving the message data in multiple chunks, so I set up a test for that, and found a couple of errors associated with it, which I have now fixed.

--- appendhandler.cpp
+++ appendhandler.cpp
@@ -183,7 +183,7 @@
 	size_t len = MIN(m_parseBuffer->literalLength(), input.dataLen);
 	if (m_parseBuffer->literalLength() > input.dataLen) {
 	    result = IMAP_IN_LITERAL;
-	    residue = input.dataLen - m_parseBuffer->literalLength();
+	    residue = m_parseBuffer->literalLength() - input.dataLen;
 	}
 	else {
 	    residue = 0;
@@ -192,8 +192,6 @@
 	std::string mailbox(m_parseBuffer->arguments());
 	switch (m_store->appendDataToMessage(mailbox, m_appendingUid, input.data, len)) {
 	case MailStore::SUCCESS:
-	    result = IMAP_MBOX_ERROR;
-
 	    if (0 == m_parseBuffer->literalLength()) {
 		m_parseStage = 4;
 		switch(m_store->doneAppendingDataToMessage(mailbox, m_appendingUid)) {


implement LUT based dumping logic after splitting pixels into clusters with double calculations

--- example/GvmClusterMain.cpp
+++ example/GvmClusterMain.cpp
@@ -13,82 +13,223 @@

 #include <iostream>

+#include <unordered_map>
+
 #import "Gvm.hpp"

 using namespace std;
 using namespace Gvm;

+// Load points from a file
+
+vector<vector<double> > loadPointsFromBGR(string filename)
+{
+  vector<vector<double> > allPoints;
+
+  FILE *fp = fopen(filename.c_str(), "rb");
+
+  fseek(fp, 0, SEEK_END);
+
+  int numBytes = (int) ftell(fp);
+
+  if (numBytes == 0) {
+    cerr << "empty input YUV file contains zero BGRA pixels" << endl;
+    exit(1);
+  }
+
+  if ((numBytes % sizeof(uint32_t)) != 0) {
+    cerr << "input YUV must be a file with a whole number of BGRA pixels" << endl;
+    exit(1);
+  }
+
+  fseek(fp, 0, SEEK_SET);
+
+  // In DEBUG mode, use unordered_map to check for duplicate pixels in the input
+
+#if defined(DEBUG)
+  unordered_map<uint32_t, uint32_t> uniquePixelMap;
+#endif // DEBUG
+
+  for (; numBytes > 0 ; numBytes -= 4) {
+    uint32_t pixel;
+
+    int numRead = (int)fread(&pixel, sizeof(pixel), 1, fp);
+    if (numRead != 1) {
+      cerr << "could not read whole pixel from YUV input at offset " << ftell(fp) << endl;
+      exit(1);
+    }
+
+    uint32_t B = pixel & 0xFF;
+    uint32_t G = (pixel >> 8) & 0xFF;
+    uint32_t R = (pixel >> 16) & 0xFF;
+
+#if defined(DEBUG)
+    uint32_t pixelNoAlpha = (R << 16) | (G << 8) | B;
+
+    if (uniquePixelMap.count(pixelNoAlpha) > 0) {
+      cerr << "input contains duplicate BGR pixel" << endl;
+      exit(1);
+    }
+#endif // DEBUG
+
+    double x = B;
+    double y = G;
+    double z = R;
+
+    vector<double> coords;
+
+    coords.push_back(x);
+    coords.push_back(y);
+    coords.push_back(z);
+
+    allPoints.push_back(coords);
+  }
+
+  fclose(fp);
+
+  return allPoints;
+}
+
 int main(int argc, char **argv) {
-//  fprintf(stdout, "hello world\n");
-
-  // The cluster "key" is a list of int values that correspond
-  // to a certain coordinate.
-
-  typedef void ClusterKey;
+
+  string filename = "/Users/modejong/Development/ImageCompression/GVMCluster/Lenna_int_order.yuv";
+
+  vector<vector<double> > allPoints = loadPointsFromBGR(filename);
+
+  cout << "read " << allPoints.size() << " pixels from " << filename << endl;
+
+  typedef vector<vector<double> > ClusterKey;

   GvmVectorSpace<double> vspace(3);

-  const int numClusters = 2;
+  const int numClusters = 2048;

   GvmClusters<GvmVectorSpace<double>, ClusterKey, double> clusters(vspace, numClusters);

-  // Generate list of 3D points
-
-  double p1[] = { 0.0, 0.0, 0.0 };
-  double p2[] = { 10.0, 10.0, 10.0 };
-  double p3[] = { 1.0, 1.0, 1.0 };
-
-  vector<vector<double> > listOfPoints;
-
-  vector<double> points;
-
-  points.clear();
-  points.push_back(p1[0]);
-  points.push_back(p1[1]);
-  points.push_back(p1[2]);
-  listOfPoints.push_back(points);
-
-  points.clear();
-  points.push_back(p2[0]);
-  points.push_back(p2[1]);
-  points.push_back(p2[2]);
-  listOfPoints.push_back(points);
-
-  points.clear();
-  points.push_back(p3[0]);
-  points.push_back(p3[1]);
-  points.push_back(p3[2]);
-  listOfPoints.push_back(points);
-
-  for ( vector<double> & pt : listOfPoints ) {
+  GvmListKeyer<GvmVectorSpace<double>, ClusterKey, double> intListKeyer;
+
+  // Install key combiner for list of points, caller must manage ptr lifetime
+
+  clusters.setKeyer(&intListKeyer);
+
+  // Insert each point into clusters. Each point is
+  // associated with a list of points called a "key".
+  // This key object lifetime must be managed by the caller
+  // for performance reasons.
+
+  vector<ClusterKey> allKeys;
+  allKeys.reserve(allPoints.size());
+
+  for ( vector<double> & pt : allPoints ) {
     // Key is a list of (list of points)
-    cout << "clustering point " << pt[0] << " " << pt[1] << " " << pt[2] << endl;
-    clusters.add(1, pt, nullptr);
+    if (false) {
+    assert(pt.size() == 3);
+    cout << "clustering point (B G R) (" << pt[0] << " " << pt[1] << " " << pt[2] << ")" << endl;
+    }
+
+    allKeys.push_back(ClusterKey ());
+    ClusterKey *key = &allKeys[allKeys.size() - 1];
+    key->push_back(pt);
+
+    clusters.add(1, pt, key);
   }

   cout << "generated " << clusters.clusters.size() << " clusters" << endl;

+  // Emit clustered results as YUV data padded out to 256 with zeros
+
   // vector<GvmResult>

   int clusteri = 0;

-  for ( auto & result : clusters.results() ) {
+  vector<GvmResult<GvmVectorSpace<double>, ClusterKey, double>> results = clusters.results();
+
+  for ( auto & result : results ) {
     cout << "cluster[" << clusteri << "]: " << result.toString() << endl;
     clusteri++;
   }

-  // Reduce down to 1 cluster
-
-  cout << "reduce " << endl;
-
-  clusters.reduce(-1.0, 1);
-
-  clusteri = 0;
-
-  for ( auto & result : clusters.results() ) {
-    cout << "cluster[" << clusteri << "]: " << result.toString() << endl;
-    clusteri++;
-  }
+  // Write clustered pixels as YUV output
+
+  int totalPixelsWritten = 0;
+
+  string outYuvFilename = "out.yuv";
+
+  FILE *outFP = fopen(outYuvFilename.c_str(), "wb");
+
+  for (int i = 0; i < results.size(); i++) {
+    int clusterID = i; // keep to byte range
+
+    ClusterKey *allKeys = results[i].getKey();
+
+    cout << "cluster " << clusterID << " contains " << allKeys->size() << " pixels" << endl;
+
+    int pixelsWritten = 0;
+
+    for ( vector<double> &coord : *allKeys ) {
+      uint32_t x = coord[0];
+      uint32_t y = coord[1];
+      uint32_t z = coord[2];
+
+      if (x < 0 || x > 255) {
+        assert(0);
+      }
+      if (y < 0 || y > 255) {
+        assert(0);
+      }
+      if (z < 0 || z > 255) {
+        assert(0);
+      }
+
+      uint32_t B = int(x);
+      uint32_t G = int(y);
+      uint32_t R = int(z);
+
+      uint32_t pixel = (R << 16) | (G << 8) | B;
+
+      int numWritten = (int)fwrite(&pixel, sizeof(uint32_t), 1, outFP);
+      assert(numWritten == 1);
+      pixelsWritten++;
+    }
+
+    totalPixelsWritten += pixelsWritten;
+
+    if (true) {
+      // Pad each cluster out to 256
+
+      int numPointsInCluster = pixelsWritten;
+
+      int over = numPointsInCluster % 256;
+      int under = 0;
+
+      if (over == 0) {
+        // Cluster of exactly 256 pixels, emit 256 zeros to indicate this case.
+        under = 256;
+      } else {
+        under = 256 - over;
+      }
+
+      for (int j = 0; j < under; j++) {
+        uint32_t pixel = 0;
+        int numWritten = (int)fwrite(&pixel, sizeof(uint32_t), 1, outFP);
+        assert(numWritten == 1);
+        totalPixelsWritten++;
+      }
+    }
+  }
+
+  fclose(outFP);
+
+  cout << "wrote " << totalPixelsWritten << " total pixels to " << outYuvFilename << endl;
+
+  int totalRowsOf256 = totalPixelsWritten/256;
+  if ((totalPixelsWritten % 256) != 0) {
+    assert(0);
+  }
+
+  cout << "wrote 256 x " << totalRowsOf256 << endl;
+
+  cout << "as " << results.size() << " number of clusters" << endl;

   return 0;
 }


INTEGRATION: CWS chart2mst3 (1.6.4); FILE MERGED 2007/05/15 11:49:00 bm 1.6.4.16: #i73604# RESYNC: additional changes for ItemId cleanup 2007/03/26 17:25:31 iha 1.6.4.15: #i75655# crash when sourcefomat was disabled withoutt changing the format itself 2007/03/26 13:51:17 iha 1.6.4.14: #i75655# crash when sourcefomat was disabled withoutt changing the format itself 2007/03/19 15:05:48 iha 1.6.4.13: #i73605#, #i75389# use correct numberformat for scale tabpage and numbers tabpage 2006/10/18 17:05:46 bm 1.6.4.12: RESYNC: (1.7-1.8); FILE MERGED 2006/09/24 09:12:53 iha 1.6.4.11: #i61970# correct implementation of axis at 2006/04/10 15:03:32 iha 1.6.4.10: api restructure axis, grids, scales and increments 2006/04/10 12:25:06 iha 1.6.4.9: api restructure axis, grids, scales and increments 2006/02/20 14:46:43 iha 1.6.4.8: move SchItemPool from controller to view lib -> ChartItemPool 2005/10/24 11:06:39 iha 1.6.4.7: coordinate system restructure 2005/10/13 17:38:46 iha 1.6.4.6: renamed BoundedCoordinateSystem to CoordinateSystem 2005/10/07 11:31:04 bm 1.6.4.5: RESYNC: (1.6-1.7); FILE MERGED 2005/07/21 08:20:25 bm 1.6.4.4: handle source number format (corresponds to a void property NumberFormat at the axis) 2005/07/12 12:57:01 bm 1.6.4.3: use named properties for gradients etc. in chart model 2005/06/08 11:28:13 iha 1.6.4.2: use number format key at API instead of string 2004/05/07 09:14:19 bm 1.6.4.1: enabling member-ids for all items

--- chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx
+++ chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: AxisItemConverter.cxx,v $
  *
- *  $Revision: 1.8 $
- *
- *  last change: $Author: obo $ $Date: 2006-09-17 13:01:19 $
+ *  $Revision: 1.9 $
+ *
+ *  last change: $Author: vg $ $Date: 2007-05-22 18:00:06 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -39,19 +39,20 @@
 #include "ItemPropertyMap.hxx"
 #include "CharacterPropertyItemConverter.hxx"
 #include "GraphicPropertyItemConverter.hxx"
-#include "SchSfxItemIds.hxx"
+#include "chartview/ChartSfxItemIds.hxx"
+#include "chartview/ExplicitValueProvider.hxx"
 #include "SchWhichPairs.hxx"
 #include "macros.hxx"
 #include "Scaling.hxx"
+#include "ChartModelHelper.hxx"
+#include "AxisHelper.hxx"
+#include "CommonConverters.hxx"

 #ifndef _COM_SUN_STAR_LANG_XSERVICENAME_HPP_
 #include <com/sun/star/lang/XServiceName.hpp>
 #endif
 #ifndef _COM_SUN_STAR_CHART2_XAXIS_HPP_
 #include <com/sun/star/chart2/XAxis.hpp>
-#endif
-#ifndef _COM_SUN_STAR_CHART2_XBOUNDEDCOORDINATESYSTEM_HPP_
-#include <com/sun/star/chart2/XBoundedCoordinateSystem.hpp>
 #endif

 // #ifndef _COMPHELPER_PROCESSFACTORY_HXX_
@@ -63,7 +64,6 @@
 #endif
 // for SvxDoubleItem
 #ifndef _SVX_CHRTITEM_HXX
-#define ITEMID_DOUBLE 0
 #include <svx/chrtitem.hxx>
 #endif
 // for SfxInt32Item
@@ -77,6 +77,8 @@
 #include <algorithm>

 using namespace ::com::sun::star;
+using namespace ::com::sun::star::chart2;
+using ::com::sun::star::uno::Reference;

 namespace
 {
@@ -84,13 +86,13 @@
 {
     static ::comphelper::ItemPropertyMapType aAxisPropertyMap(
         ::comphelper::MakeItemPropertyMap
-        ( SCHATTR_AXIS_SHOWDESCR, C2U( "DisplayLabels" ))
-        ( SCHATTR_AXIS_TICKS,     C2U( "MajorTickmarks" ))
-        ( SCHATTR_AXIS_HELPTICKS, C2U( "MinorTickmarks" ))
-        ( SCHATTR_TEXT_ORDER,     C2U( "ArrangeOrder" ))
-        ( SCHATTR_TEXT_STACKED,   C2U( "StackCharacters" ))
-        ( SCHATTR_TEXTBREAK,      C2U( "TextBreak" ))
-        ( SCHATTR_TEXT_OVERLAP,   C2U( "TextOverlap" ))
+        IPM_MAP_ENTRY( SCHATTR_AXIS_SHOWDESCR, "DisplayLabels",    0 )
+        IPM_MAP_ENTRY( SCHATTR_AXIS_TICKS,     "MajorTickmarks",   0 )
+        IPM_MAP_ENTRY( SCHATTR_AXIS_HELPTICKS, "MinorTickmarks",   0 )
+        IPM_MAP_ENTRY( SCHATTR_TEXT_ORDER,     "ArrangeOrder",     0 )
+        IPM_MAP_ENTRY( SCHATTR_TEXT_STACKED,   "StackCharacters",  0 )
+        IPM_MAP_ENTRY( SCHATTR_TEXTBREAK,      "TextBreak",        0 )
+        IPM_MAP_ENTRY( SCHATTR_TEXT_OVERLAP,   "TextOverlap",      0 )
         );

     return aAxisPropertyMap;
@@ -103,56 +105,40 @@
 {

 AxisItemConverter::AxisItemConverter(
-    const uno::Reference< beans::XPropertySet > & rPropertySet,
+    const Reference< beans::XPropertySet > & rPropertySet,
     SfxItemPool& rItemPool,
     SdrModel& rDrawModel,
-    NumberFormatterWrapper * pNumFormatter,
+    const Reference< chart2::XChartDocument > & xChartDoc,
     chart2::ExplicitScaleData * pScale /* = NULL */,
     chart2::ExplicitIncrementData * pIncrement /* = NULL */,
-    double * pExplicitOrigin /* = NULL */,
     ::std::auto_ptr< awt::Size > pRefSize /* = NULL */ ) :
         ItemConverter( rPropertySet, rItemPool ),
-        m_pNumberFormatterWrapper( pNumFormatter ),
+        m_xChartDoc( xChartDoc ),
         m_pExplicitScale( NULL ),
-        m_pExplicitIncrement( NULL ),
-        m_pExplicitOrigin( NULL )
-{
+        m_pExplicitIncrement( NULL )
+{
+    Reference< lang::XMultiServiceFactory > xNamedPropertyContainerFactory( xChartDoc, uno::UNO_QUERY );
+
     if( pScale )
         m_pExplicitScale = new chart2::ExplicitScaleData( *pScale );
     if( pIncrement )
         m_pExplicitIncrement = new chart2::ExplicitIncrementData( *pIncrement );
-    if( pExplicitOrigin )
-        m_pExplicitOrigin = new double( *pExplicitOrigin );

     m_aConverters.push_back( new GraphicPropertyItemConverter(
                                  rPropertySet, rItemPool, rDrawModel,
+                                 xNamedPropertyContainerFactory,
                                  GraphicPropertyItemConverter::LINE_PROPERTIES ));
     m_aConverters.push_back( new CharacterPropertyItemConverter( rPropertySet, rItemPool, pRefSize,
                                                                  C2U( "ReferenceDiagramSize" ) ));

-    uno::Reference< chart2::XAxis > xAxis( rPropertySet, uno::UNO_QUERY );
-    OSL_ASSERT( xAxis.is());
-    if( xAxis.is())
-    {
-        m_xAxis = xAxis;
-
-        m_xCoordinateSystem.set( xAxis->getCoordinateSystem());
-        if( m_xCoordinateSystem.is())
-        {
-            m_nDimension = xAxis->getRepresentedDimension();
-        }
-        else
-        {
-            OSL_ENSURE( false, "No coordinate system found at axis!" );
-        }
-    }
+    m_xAxis.set( Reference< chart2::XAxis >( rPropertySet, uno::UNO_QUERY ) );
+    OSL_ASSERT( m_xAxis.is());
 }

 AxisItemConverter::~AxisItemConverter()
 {
     delete m_pExplicitScale;
     delete m_pExplicitIncrement;
-    delete m_pExplicitOrigin;

     ::std::for_each( m_aConverters.begin(), m_aConverters.end(),
                      ::comphelper::DeleteItemConverterPtr() );
@@ -184,19 +170,15 @@
     return nAxisWhichPairs;
 }

-bool AxisItemConverter::GetItemPropertyName( USHORT nWhichId, ::rtl::OUString & rOutName ) const
+bool AxisItemConverter::GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const
 {
     ::comphelper::ItemPropertyMapType & rMap( lcl_GetAxisPropertyMap());
     ::comphelper::ItemPropertyMapType::const_iterator aIt( rMap.find( nWhichId ));

-//     OSL_TRACE( "Which-Id: %d", nWhichId );
-
     if( aIt == rMap.end())
         return false;

-    rOutName =(*aIt).second;
-//     OSL_TRACE( "Which-Id: %d, Entry found in map: %s.", nWhichId,
-//                ::rtl::OUStringToOString( rOutName, RTL_TEXTENCODING_ASCII_US ).getStr());
+    rOutProperty =(*aIt).second;

     return true;
 }
@@ -204,21 +186,12 @@
 void AxisItemConverter::FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemSet ) const
     throw( uno::Exception )
 {
-    if( ! m_xAxis.is() ||
-        ! m_xCoordinateSystem.is() )
+    if( ! m_xAxis.is() )
         return;

-    uno::Reference< chart2::XScale > xScale( m_xCoordinateSystem->getScaleByDimension( m_nDimension ));
-    OSL_ASSERT( xScale.is());
-    uno::Reference< chart2::XIncrement > xIncrement( m_xAxis->getIncrement() );
-    OSL_ASSERT( xIncrement.is());
-    if( ! xScale.is() ||
-        ! xIncrement.is() )
-        return;
-
-    const chart2::ScaleData     aScale( xScale->getScaleData() );
-    const chart2::IncrementData aInc( xIncrement->getIncrementData() );
-    const uno::Sequence< chart2::SubIncrement > aSubIncs( xIncrement->getSubIncrements() );
+    const chart2::ScaleData     aScale( m_xAxis->getScaleData() );
+    const chart2::IncrementData aInc( aScale.IncrementData );
+    const uno::Sequence< chart2::SubIncrement > aSubIncs( aScale.IncrementData.SubIncrements );

     switch( nWhichId )
     {
@@ -268,7 +241,7 @@

         case SCHATTR_AXIS_LOGARITHM:
         {
-            uno::Reference< lang::XServiceName > xServiceName( aScale.Scaling, uno::UNO_QUERY );
+            Reference< lang::XServiceName > xServiceName( aScale.Scaling, uno::UNO_QUERY );
             BOOL bValue =
                 // if the following is true, we have logarithmic scaling,
                 // otherwise not (per definition)
@@ -341,33 +314,20 @@

         case SCHATTR_AXIS_AUTO_ORIGIN:
         {
-            uno::Sequence< uno::Any > aCoord( m_xCoordinateSystem->getOrigin() );
-            OSL_ASSERT( m_nDimension <= aCoord.getLength());
-            rOutItemSet.Put(
-                SfxBoolItem(
-                    nWhichId,
-                    ! ( aCoord.getLength() > m_nDimension &&
-                        aCoord[ m_nDimension ].hasValue() ) ));
+            // if the any has no double value => auto is on
+            rOutItemSet.Put( SfxBoolItem( nWhichId, ( !hasDoubleValue(aScale.Origin) )));
         }
         break;

         case SCHATTR_AXIS_ORIGIN:
         {
-            bool bIsAuto = true;
-            uno::Sequence< uno::Any > aCoord( m_xCoordinateSystem->getOrigin() );
-            if( aCoord.getLength() > m_nDimension &&
-                aCoord[ m_nDimension ].hasValue() )
-            {
-                OSL_ASSERT( aCoord[ m_nDimension ].getValueTypeClass() == uno::TypeClass_DOUBLE );
-                rOutItemSet.Put(
-                    SvxDoubleItem(
-                        *reinterpret_cast< const double * >(aCoord[ m_nDimension ].getValue()),
-                        nWhichId ));
-                bIsAuto = false;
-            }
-
-            if( bIsAuto && m_pExplicitOrigin )
-                rOutItemSet.Put( SvxDoubleItem( *m_pExplicitOrigin, nWhichId ));
+            double fOrigin = 0.0;
+            if( !(aScale.Origin >>= fOrigin) )
+            {
+                if( m_pExplicitScale )
+                    fOrigin = m_pExplicitScale->Origin;
+            }
+            rOutItemSet.Put( SvxDoubleItem( fOrigin, nWhichId ));
         }
         break;

@@ -387,57 +347,38 @@
         case SID_ATTR_NUMBERFORMAT_VALUE:
 //         case SCHATTR_AXIS_NUMFMT:
         {
-            if( m_pNumberFormatterWrapper )
-            {
-                chart2::NumberFormat aNumFmt;
-                if( GetPropertySet()->getPropertyValue( C2U( "NumberFormat" )) >>= aNumFmt )
-                {
-                    sal_Int32 nKey = m_pNumberFormatterWrapper->getKeyForNumberFormat( aNumFmt );
-
-                    OSL_TRACE( "NumberFormat: ""%s"", Locale: %s_%s@%s, Key: %d",
-                               U2C( aNumFmt.aFormat ),
-                               U2C( aNumFmt.aLocale.Language ),
-                               U2C( aNumFmt.aLocale.Country ),
-                               U2C( aNumFmt.aLocale.Variant ),
-                               nKey );
-                    rOutItemSet.Put( SfxUInt32Item( nWhichId, nKey ));
-                }
-            }
-            else
-            {
-                OSL_ENSURE( false, "No NumberFormatterWrapper !" );
-            }
-        }
-        break;
-
-//         case SID_ATTR_NUMBERFORMAT_SOURCE:
+            if( m_pExplicitScale )
+            {
+                Reference< chart2::XCoordinateSystem > xCooSys(
+                        AxisHelper::getCoordinateSystemOfAxis(
+                              m_xAxis, ChartModelHelper::findDiagram( m_xChartDoc ) ) );
+
+                sal_Int32 nFormatKey = ExplicitValueProvider::getExplicitNumberFormatKeyForAxis(
+                    m_xAxis, xCooSys, Reference< util::XNumberFormatsSupplier >( m_xChartDoc, uno::UNO_QUERY ) );
+
+                rOutItemSet.Put( SfxUInt32Item( nWhichId, nFormatKey ));
+            }
+        }
+        break;
+
+        case SID_ATTR_NUMBERFORMAT_SOURCE:
+        {
+            bool bNumberFormatIsSet = ( GetPropertySet()->getPropertyValue( C2U( "NumberFormat" )).hasValue());
+            rOutItemSet.Put( SfxBoolItem( nWhichId, ! bNumberFormatIsSet ));
+        }
+        break;
     }
 }

 bool AxisItemConverter::ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet )
     throw( uno::Exception )
 {
-    if( ! ( m_xAxis.is() &&
-            m_xCoordinateSystem.is()))
+    if( !m_xAxis.is() )
         return false;

-    uno::Reference< chart2::XScale > xScale( m_xCoordinateSystem->getScaleByDimension( m_nDimension ));
-    OSL_ASSERT( xScale.is());
-    uno::Reference< chart2::XIncrement > xIncrement( m_xAxis->getIncrement() );
-    OSL_ASSERT( xIncrement.is());
-    if( ! xScale.is() ||
-        ! xIncrement.is() )
-        return false;
-
-    chart2::ScaleData     aScale( xScale->getScaleData() );
-    chart2::IncrementData aInc( xIncrement->getIncrementData() );
-    uno::Sequence< chart2::SubIncrement > aSubIncs( xIncrement->getSubIncrements() );
-    uno::Sequence< uno::Any > aOrigin( m_xCoordinateSystem->getOrigin());
-
-    bool bSetScale         = false;
-    bool bSetIncrement     = false;
-    bool bSetSubIncrement  = false;
-    bool bSetOrigin   = false;
+    chart2::ScaleData     aScale( m_xAxis->getScaleData() );
+
+    bool bSetScale    = false;
     bool bChangedOtherwise = false;

     uno::Any aValue;
@@ -496,7 +437,7 @@

         case SCHATTR_AXIS_LOGARITHM:
         {
-            uno::Reference< lang::XServiceName > xServiceName( aScale.Scaling, uno::UNO_QUERY );
+            Reference< lang::XServiceName > xServiceName( aScale.Scaling, uno::UNO_QUERY );
             bool bWasLogarithm =
                 // if the following is true, we have logarithmic scaling,
                 // otherwise not (per definition)
@@ -531,8 +472,8 @@
             if( (reinterpret_cast< const SfxBoolItem & >(
                      rItemSet.Get( nWhichId )).GetValue() ))
             {
-                aInc.Distance.clear();
-                bSetIncrement = true;
+                aScale.IncrementData.Distance.clear();
+                bSetScale = true;
             }
             // else SCHATTR_AXIS_STEP_MAIN must have some value
             break;
@@ -544,10 +485,10 @@
             {
                 rItemSet.Get( nWhichId ).QueryValue( aValue );

-                if( aInc.Distance != aValue )
-                {
-                    aInc.Distance = aValue;
-                    bSetIncrement = true;
+                if( aScale.IncrementData.Distance != aValue )
+                {
+                    aScale.IncrementData.Distance = aValue;
+                    bSetScale = true;
                 }
             }
             break;
@@ -556,11 +497,11 @@
         case SCHATTR_AXIS_AUTO_STEP_HELP:
             if( (reinterpret_cast< const SfxBoolItem & >(
                      rItemSet.Get( nWhichId )).GetValue() ) &&
-                aSubIncs.getLength() > 0 &&
-                aSubIncs[0].IntervalCount.hasValue() )
-            {
-                    aSubIncs[0].IntervalCount.clear();
-                    bSetSubIncrement = true;
+                aScale.IncrementData.SubIncrements.getLength() > 0 &&
+                aScale.IncrementData.SubIncrements[0].IntervalCount.hasValue() )
+            {
+                    aScale.IncrementData.SubIncrements[0].IntervalCount.clear();
+                    bSetScale = true;
             }
             // else SCHATTR_AXIS_STEP_MAIN must have some value
             break;
@@ -569,16 +510,16 @@
             // only if auto if false
             if( ! (reinterpret_cast< const SfxBoolItem & >(
                        rItemSet.Get( SCHATTR_AXIS_AUTO_STEP_HELP )).GetValue() ) &&
-                aSubIncs.getLength() > 0 )
+                aScale.IncrementData.SubIncrements.getLength() > 0 )
             {
                 rItemSet.Get( nWhichId ).QueryValue( aValue );

-                if( ! aSubIncs[0].IntervalCount.hasValue() ||
-                    aSubIncs[0].IntervalCount != aValue )
+                if( ! aScale.IncrementData.SubIncrements[0].IntervalCount.hasValue() ||
+                    aScale.IncrementData.SubIncrements[0].IntervalCount != aValue )
                 {
                     OSL_ASSERT( aValue.getValueTypeClass() == uno::TypeClass_LONG );
-                    aSubIncs[0].IntervalCount = aValue;
-                    bSetSubIncrement = true;
+                    aScale.IncrementData.SubIncrements[0].IntervalCount = aValue;
+                    bSetScale = true;
                 }
             }
             break;
@@ -586,29 +527,26 @@
         case SCHATTR_AXIS_AUTO_ORIGIN:
         {
             if( (reinterpret_cast< const SfxBoolItem & >(
-                     rItemSet.Get( nWhichId )).GetValue() ) &&
-                ( aOrigin.getLength() > m_nDimension &&
-                  aOrigin[ m_nDimension ].hasValue() ))
-            {
-                aOrigin[ m_nDimension ].clear();
-                bSetOrigin = true;
+                     rItemSet.Get( nWhichId )).GetValue() ))
+            {
+                aScale.Origin.clear();
+                bSetScale = true;
             }
         }
         break;

         case SCHATTR_AXIS_ORIGIN:
         {
+            // only if auto is false
             if( ! (reinterpret_cast< const SfxBoolItem & >(
                        rItemSet.Get( SCHATTR_AXIS_AUTO_ORIGIN )).GetValue() ))
             {
-                if( aOrigin.getLength() > m_nDimension )
-                {
-                    rItemSet.Get( nWhichId ).QueryValue( aValue );
-                    if( aValue != aOrigin[ m_nDimension ] )
-                    {
-                        aOrigin[ m_nDimension ] = aValue;
-                        bSetOrigin = true;
-                    }
+                rItemSet.Get( nWhichId ).QueryValue( aValue );
+
+                if( aScale.Origin != aValue )
+                {
+                    aScale.Origin = aValue;
+                    bSetScale = true;
                 }
             }
         }
@@ -636,44 +574,74 @@
         case SID_ATTR_NUMBERFORMAT_VALUE:
 //         case SCHATTR_AXIS_NUMFMT:
         {
-            if( m_pNumberFormatterWrapper )
-            {
-                sal_Int32 nFmt = static_cast< sal_Int32 >(
-                    reinterpret_cast< const SfxUInt32Item & >(
-                        rItemSet.Get( nWhichId )).GetValue());
-
-                aValue = uno::makeAny(
-                    m_pNumberFormatterWrapper->getNumberFormatForKey( nFmt ));
-                if( GetPropertySet()->getPropertyValue( C2U( "NumberFormat" )) != aValue )
-                {
-                    GetPropertySet()->setPropertyValue( C2U( "NumberFormat" ), aValue );
-                    bChangedOtherwise = true;
-                }
-            }
-            else
-            {
-                OSL_ENSURE( false, "No NumberFormatterWrapper !" );
-            }
-        }
-        break;
-
-//         case SID_ATTR_NUMBERFORMAT_SOURCE:
+            if( m_pExplicitScale )
+            {
+                bool bUseSourceFormat =
+                    (reinterpret_cast< const SfxBoolItem & >(
+                        rItemSet.Get( SID_ATTR_NUMBERFORMAT_SOURCE )).GetValue() );
+
+                if( ! bUseSourceFormat )
+                {
+                    sal_Int32 nFmt = static_cast< sal_Int32 >(
+                        reinterpret_cast< const SfxUInt32Item & >(
+                            rItemSet.Get( nWhichId )).GetValue());
+
+                    aValue = uno::makeAny(nFmt);
+                    if( GetPropertySet()->getPropertyValue( C2U( "NumberFormat" )) != aValue )
+                    {
+                        GetPropertySet()->setPropertyValue( C2U( "NumberFormat" ), aValue );
+                        bChangedOtherwise = true;
+                    }
+                }
+            }
+        }
+        break;
+
+        case SID_ATTR_NUMBERFORMAT_SOURCE:
+        {
+            bool bUseSourceFormat =
+                (reinterpret_cast< const SfxBoolItem & >(
+                    rItemSet.Get( nWhichId )).GetValue() );
+            bool bNumberFormatIsSet = ( GetPropertySet()->getPropertyValue( C2U( "NumberFormat" )).hasValue());
+
+            bChangedOtherwise = (bUseSourceFormat == bNumberFormatIsSet);
+            if( bChangedOtherwise )
+            {
+                if( ! bUseSourceFormat )
+                {
+                    sal_Int32 nTest = 0;
+
+                    SfxItemState aState = rItemSet.GetItemState( SID_ATTR_NUMBERFORMAT_VALUE );
+                    if( aState == SFX_ITEM_SET )
+                    {
+                        sal_Int32 nFormatKey = static_cast< sal_Int32 >(
+                        reinterpret_cast< const SfxUInt32Item & >(
+                            rItemSet.Get( SID_ATTR_NUMBERFORMAT_VALUE )).GetValue());
+                        aValue <<= nFormatKey;
+                    }
+                    else
+                    {
+                        Reference< chart2::XCoordinateSystem > xCooSys(
+                        AxisHelper::getCoordinateSystemOfAxis(
+                              m_xAxis, ChartModelHelper::findDiagram( m_xChartDoc ) ) );
+
+                        sal_Int32 nFormatKey = ExplicitValueProvider::getExplicitNumberFormatKeyForAxis(
+                            m_xAxis, xCooSys, Reference< util::XNumberFormatsSupplier >( m_xChartDoc, uno::UNO_QUERY ) );
+
+                        aValue <<= nFormatKey;
+                    }
+                }
+                // else set a void Any
+                GetPropertySet()->setPropertyValue( C2U( "NumberFormat" ), aValue );
+            }
+        }
+        break;
     }

-    if( bSetScale &&
-        xScale.is() )
-        xScale->setScaleData( aScale );
-    if( bSetIncrement &&
-        xIncrement.is() )
-        xIncrement->setIncrementData( aInc );
-    if( bSetSubIncrement &&
-        xIncrement.is() )
-        xIncrement->setSubIncrements( aSubIncs );
-    if( bSetOrigin )
-        m_xCoordinateSystem->setOrigin( aOrigin );
-
-    return (bSetScale || bSetIncrement || bSetSubIncrement ||
-            bSetOrigin || bChangedOtherwise);
+    if( bSetScale )
+        m_xAxis->setScaleData( aScale );
+
+    return (bSetScale || bChangedOtherwise);
 }

 } //  namespace wrapper


INTEGRATION: CWS xmlfilter04 (1.2.12); FILE MERGED 2008/03/13 13:30:53 dr 1.2.12.1: make darwingml::TextBodyContext independent from drawingml::Shape, add various chart contexts

--- oox/inc/oox/drawingml/textliststyle.hxx
+++ oox/inc/oox/drawingml/textliststyle.hxx
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: textliststyle.hxx,v $
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -31,15 +31,12 @@
 #ifndef OOX_DRAWINGML_TEXTLISTSTYLE_HXX
 #define OOX_DRAWINGML_TEXTLISTSTYLE_HXX

+#include "oox/helper/containerhelper.hxx"
 #include "oox/drawingml/textparagraphproperties.hxx"
-#include <boost/shared_ptr.hpp>
-#include <vector>

 namespace oox { namespace drawingml {

-class TextListStyle;
-
-typedef boost::shared_ptr< TextListStyle > TextListStylePtr;
+typedef RefVector< TextParagraphProperties > TextParagraphPropertiesVector;

 class TextListStyle
 {
@@ -48,16 +45,21 @@
     TextListStyle();
     ~TextListStyle();

-    void apply( const oox::drawingml::TextListStylePtr& rTextListStylePtr );
+    void apply( const TextListStyle& rTextListStyle );

-    std::vector< ::oox::drawingml::TextParagraphPropertiesPtr >& getListStyle() { return maListStyle; };
-    std::vector< ::oox::drawingml::TextParagraphPropertiesPtr >& getAggregationListStyle() { return maAggregationListStyle; };
+    inline const TextParagraphPropertiesVector& getListStyle() const { return maListStyle; };
+    inline TextParagraphPropertiesVector&       getListStyle() { return maListStyle; };
+
+    inline const TextParagraphPropertiesVector& getAggregationListStyle() const { return maAggregationListStyle; };
+    inline TextParagraphPropertiesVector&       getAggregationListStyle() { return maAggregationListStyle; };

 protected:

-    std::vector< ::oox::drawingml::TextParagraphPropertiesPtr > maListStyle;
-    std::vector< ::oox::drawingml::TextParagraphPropertiesPtr > maAggregationListStyle;
+    TextParagraphPropertiesVector maListStyle;
+    TextParagraphPropertiesVector maAggregationListStyle;
 };
+
+typedef boost::shared_ptr< TextListStyle > TextListStylePtr;

 } }


Revert change 3272 for bug 444. Though we technically don't apply gamma but rather exposure, the original behavior is desired. This restores working gamma correction.

--- OgreMain/src/OgreImage.cpp
+++ OgreMain/src/OgreImage.cpp
@@ -543,23 +543,30 @@

 		for( size_t i = 0, j = size / stride; i < j; i++, buffer += stride )
 		{
-			Real r, g, b;
-
-			const Real rangeMult = 255.0f;
-			const Real rangeMultInv = 1.0f / rangeMult;
-			const Real gammaValue = 1.0f / gamma;
-
-			r = rangeMultInv * buffer[0];
-			g = rangeMultInv * buffer[1];
-			b = rangeMultInv * buffer[2];
-
-			Math::Pow(r, gammaValue);
-			Math::Pow(g, gammaValue);
-			Math::Pow(b, gammaValue);
-
-			buffer[0] = (uchar)(r * rangeMult);
-			buffer[1] = (uchar)(g * rangeMult);
-			buffer[2] = (uchar)(b * rangeMult);
+			float r, g, b;
+
+			r = (float)buffer[0];
+			g = (float)buffer[1];
+			b = (float)buffer[2];
+
+			r = r * gamma;
+			g = g * gamma;
+			b = b * gamma;
+
+			float scale = 1.0f, tmp;
+
+			if( r > 255.0f && (tmp=(255.0f/r)) < scale )
+				scale = tmp;
+			if( g > 255.0f && (tmp=(255.0f/g)) < scale )
+				scale = tmp;
+			if( b > 255.0f && (tmp=(255.0f/b)) < scale )
+				scale = tmp;
+
+			r *= scale; g *= scale; b *= scale;
+
+			buffer[0] = (uchar)r;
+			buffer[1] = (uchar)g;
+			buffer[2] = (uchar)b;
 		}
 	}
 	//-----------------------------------------------------------------------------


Corrects TXY and TYX; kudos to PatrickvL for the spot!

--- Processors/65816/Implementation/65816Implementation.hpp
+++ Processors/65816/Implementation/65816Implementation.hpp
@@ -344,11 +344,11 @@
 					break;

 					case TXY:
+						LD(y_, x_.full, x_masks_);
+					break;
+
+					case TYX:
 						LD(x_, y_.full, x_masks_);
-					break;
-
-					case TYX:
-						LD(y_, x_.full, x_masks_);
 					break;

 					case TAX:


automatically disabling exposure/v4l on Mac

git-svn-id: a4b26c34c00ddc9206f2ebf811dcbf46daf0547e@17 2439b94c-f860-40a2-9219-eeaa48156016

--- example/apriltags_demo.cpp
+++ example/apriltags_demo.cpp
@@ -45,8 +45,9 @@
     "\n";

-
+#ifndef __APPLE__
 #define EXPOSURE_CONTROL // only works in Linux
+#endif

 #ifdef EXPOSURE_CONTROL
 #include <libv4l2.h>
@@ -198,12 +199,24 @@
         m_px = m_width/2;
         break;
       case 'E':
+#ifndef EXPOSURE_CONTROL
+        cout << "Error: Exposure option (-E) not available" << endl;
+        exit(1);
+#endif
         m_exposure = atoi(optarg);
         break;
       case 'G':
+#ifndef EXPOSURE_CONTROL
+        cout << "Error: Gain option (-G) not available" << endl;
+        exit(1);
+#endif
         m_gain = atoi(optarg);
         break;
       case 'B':
+#ifndef EXPOSURE_CONTROL
+        cout << "Error: Brightness option (-B) not available" << endl;
+        exit(1);
+#endif
         m_brightness = atoi(optarg);
         break;
       case ':': // unknown option, from getopt


Coverity: check file_util::ReadFileToString return.

CID=6217
TEST=none
BUG=none

Review URL: http://codereview.chromium.org/257039

git-svn-id: dd90618784b6a4b323ea0c23a071cb1c9e6f2ac7@28476 4ff67af0-8c30-449e-8e8b-ad334ec8d88c

--- chrome/browser/search_engines/template_url_parser_unittest.cc
+++ chrome/browser/search_engines/template_url_parser_unittest.cc
@@ -43,7 +43,7 @@
     ASSERT_TRUE(file_util::PathExists(full_path));

     std::string contents;
-    file_util::ReadFileToString(full_path, &contents);
+    ASSERT_TRUE(file_util::ReadFileToString(full_path, &contents));
     parse_result_ = TemplateURLParser::Parse(
         reinterpret_cast<const unsigned char*>(contents.c_str()),
         contents.length(), filter, &template_url_);


Unnecessary reinterpret_cast

Unnecessary reinterpret_cast

reinterpret_cast in conjunction with derived types can be pretty
dangerous

--- virvo/tools/vserver/vvresourcemanager.cpp
+++ virvo/tools/vserver/vvresourcemanager.cpp
@@ -51,7 +51,7 @@

   void * localServerLoop(void *param)
   {
-    vvSimpleServer *sserver = reinterpret_cast<vvSimpleServer*>(param);
+    vvSimpleServer *sserver = static_cast<vvSimpleServer*>(param);
     sserver->run(0, NULL);

     pthread_exit(NULL);
@@ -410,7 +410,7 @@
   {
   vvDebugMsg::msg(3, "vvResourceManager::updateResources() Enter");

-  vvResourceManager *rm = reinterpret_cast<vvResourceManager*>(param);
+  vvResourceManager *rm = static_cast<vvResourceManager*>(param);

   std::vector<vvBonjourEntry> entries = rm->_browser->getBonjourEntries();


Replace NULL by nullprt

Replace NULL by nullprt

--- opencog/atoms/execution/Instantiator.cc
+++ opencog/atoms/execution/Instantiator.cc
@@ -252,7 +252,7 @@
 	// some time by doing it just once, right here, in one big batch.
 	// A null pointer means that we hit
 	Handle gnd = walk_tree(expr);
-	if (NULL != gnd)
+	if (nullptr != gnd)
 		return _as->add_atom(gnd);
 	return gnd;
 }


In StopDoneImpl check for the current state. If it is not running return right away.

BUG=99867
TEST=

Review URL: http://codereview.chromium.org/8216029

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

--- chrome/browser/sync/glue/non_frontend_data_type_controller.cc
+++ chrome/browser/sync/glue/non_frontend_data_type_controller.cc
@@ -153,6 +153,13 @@
     DataTypeController::State new_state,
     const SyncError& error) {
   DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+  if (state_ == NOT_RUNNING) {
+    // During stop it is possible startdoneimpl can be called twice. Once from
+    // the |StartDone| method and once from the |Stop| method.
+    DCHECK(!start_callback_.get());
+    return;
+  }
   state_ = new_state;
   if (state_ != RUNNING) {
     // Start failed.


[search] Match houses with index

[search] Match houses with index

--- search/house_detector.cpp
+++ search/house_detector.cpp
@@ -1066,11 +1066,21 @@
   void CountScore()
   {
     sort(houses.begin(), houses.end(), HouseProjection::LessDistance());
-    size_t const s = min(houses.size(), size_t(3));
+    size_t const size = houses.size();
     score = 0;
-    for (size_t i = 0; i < s; ++i)
-      score += houses[i]->m_distance;
-    score /= s;
+    size_t const scoreNumber = 3;
+    for (size_t i = 0; i < scoreNumber; ++i)
+      score += i < size ? houses[i]->m_distance : houses.back()->m_distance;
+    score /= scoreNumber;
+  }
+
+  bool IsIntersecting(HouseChain const & chain) const
+  {
+    if (minHouseNumber >= chain.maxHouseNumber)
+      return false;
+    if (chain.minHouseNumber >= maxHouseNumber)
+      return false;
+    return true;
   }

   bool operator<(HouseChain const & p) const
@@ -1079,21 +1089,29 @@
   }
 };

-pair <int, int> GetBestHouseFromChains(vector<HouseChain> & houseChains, string const & houseNumber, vector<HouseProjection const *> const & st, ResultAccumulator & acc)
+void GetBestHouseFromChains(vector<HouseChain> & houseChains, ResultAccumulator & acc)
 {
   for (size_t i = 0; i < houseChains.size(); ++i)
     houseChains[i].CountScore();
   sort(houseChains.begin(), houseChains.end());

+  ParsedNumber number(acc.GetFullNumber());
+
   for (size_t i = 0; i < houseChains.size(); ++i)
   {
-    for (size_t j = 0; j < houseChains[i].houses.size(); ++j)
-    {
-      if (houseNumber == houseChains[i].houses[j]->m_house->GetNumber())
-        return make_pair(i, j);
-    }
-  }
-  return make_pair(-1, -1);
+    if (i == 0 || !houseChains[0].IsIntersecting(houseChains[i]))
+    {
+      for (size_t j = 0; j < houseChains[i].houses.size(); ++j)
+      {
+        if (houseChains[i].houses[j]->m_house->GetMatch(number) != -1)
+        {
+          for (size_t k = 0; k < houseChains[i].houses.size(); ++k)
+            acc.MatchCandidate(*houseChains[i].houses[k], true);
+          break;
+        }
+      }
+    }
+  }
 }

@@ -1201,9 +1219,7 @@
       }
     }
   }
-  pair <int, int> ind = GetBestHouseFromChains(houseChains, houseNumber, st, acc);
-  if (ind.first != -1)
-    acc.MatchCandidate(*houseChains[ind.first].houses[ind.second], false);
+  GetBestHouseFromChains(houseChains, acc);
 }

 void GetBestHouseWithNumber(MergedStreet const & st, double offsetMeters, ResultAccumulator & acc)
@@ -1325,13 +1341,13 @@

     resultIndex = 1;

-    GetClosestHouse(m_streets[i], acc[resultIndex]); //0.880247
+    GetClosestHouse(m_streets[i], acc[resultIndex]); //0.880716

     resultIndex = 2;

     for (size_t j = 0; j < ARRAY_SIZE(arrOffsets) && arrOffsets[j] <= m_houseOffsetM; ++j)
     {
-       GetBestHouseWithNumber(m_streets[i], arrOffsets[j], acc[resultIndex]); //0.88403
+       GetBestHouseWithNumber(m_streets[i], arrOffsets[j], acc[resultIndex]); //0.88668
        if (acc[resultIndex].HasBestMatch())
          break;
     }


[dom-ui settings] Prevent extensions handler from updating the list of extensions when there is no renderer (ie: the settings tab is closing).  This prevents what would be wasted work from being done, and it also should stop valgrind from incorrectly reporting a memory leak.

BUG=96342
TEST=Verify absense of leak on valgrind bot runs.
Review URL: http://codereview.chromium.org/7891066

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

--- chrome/browser/ui/webui/options/extension_settings_handler.cc
+++ chrome/browser/ui/webui/options/extension_settings_handler.cc
@@ -4,6 +4,7 @@

 #include "chrome/browser/ui/webui/options/extension_settings_handler.h"

+#include "base/auto_reset.h"
 #include "base/base64.h"
 #include "base/file_util.h"
 #include "base/string_number_conversions.h"
@@ -411,10 +412,9 @@
   // notification for this case.
   //
   // Bug: http://crbug.com/41384
-  ignore_notifications_ = true;
+  AutoReset<bool> auto_reset_ignore_notifications(&ignore_notifications_, true);
   extension_service_->SetIsIncognitoEnabled(extension->id(),
                                             enable_str == "true");
-  ignore_notifications_ = false;
 }

 void ExtensionSettingsHandler::HandleAllowFileAccessMessage(
@@ -711,7 +711,8 @@
 }

 void ExtensionSettingsHandler::MaybeUpdateAfterNotification() {
-  if (!ignore_notifications_ && web_ui_->tab_contents())
+  TabContents* contents = web_ui_->tab_contents();
+  if (!ignore_notifications_ && contents && contents->render_view_host())
     HandleRequestExtensionsData(NULL);
   deleting_rvh_ = NULL;
 }


Optimized the regex.

Optimized the regex.

--- dart/utils/UriUtils.cpp
+++ dart/utils/UriUtils.cpp
@@ -228,7 +228,7 @@
   // This is regex is from Appendix B of RFC 3986.
   static regex uriRegex(
     R"END(^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?)END",
-    regex::extended);
+    regex::extended | regex::optimize);
   static const size_t schemeIndex = 2;
   static const size_t authorityIndex = 4;
   static const size_t pathIndex = 5;


Remove unused profiled_methods_file option

Summary: Not used anymore, let's remove it.

Reviewed By: thezhangwei

Differential Revision: D37522447

fbshipit-source-id: cfa8d62351cade5bf3e8b7a7a8d333280a2b1ed3

--- libredex/GlobalConfig.cpp
+++ libredex/GlobalConfig.cpp
@@ -146,9 +146,6 @@
   bind("lower_with_cfg", {}, bool_param);
   bind("no_optimizations_annotations", {}, string_vector_param);
   bind("no_optimizations_blocklist", {}, string_vector_param);
-  // TODO: Remove unused profiled_methods_file option and all build system
-  // references
-  bind("profiled_methods_file", "", string_param);
   bind("proguard_map", "", string_param);
   bind("prune_unexported_components", {}, string_vector_param);
   bind("pure_methods", {}, string_vector_param);


Disable gouraud shading.

Disable gouraud shading.

git-svn-id: 28d9401aa571d5108e51b194aae6f24ca5964c06@3919 8cc4aa7f-3514-0410-904f-f2cc9021211c

--- libs/csengine/terrain.cpp
+++ libs/csengine/terrain.cpp
@@ -264,14 +264,14 @@
 		g3dmesh.morph_factor = 0;
 		g3dmesh.num_vertices_pool = 1;
 		g3dmesh.num_textures = 1;
-		g3dmesh.use_vertex_color = true;
+		g3dmesh.use_vertex_color = false;
 		g3dmesh.do_clip = true;	// DEBUG THIS LATER
 		g3dmesh.do_mirror = rview.IsMirrored ();
 		g3dmesh.do_morph_texels = false;
 		g3dmesh.do_morph_colors = false;
 		g3dmesh.vertex_fog = NULL;
 		g3dmesh.vertex_mode = G3DTriangleMesh::VM_WORLDSPACE;
-		g3dmesh.fxmode = CS_FX_GOURAUD;
+		g3dmesh.fxmode = 0;//CS_FX_GOURAUD;
 		init = true;
 	}
     g3dmesh.num_vertices = vbuf->num();	  // number of shared vertices for all triangles


Added comment about nocp option to config menu.

--- gui/control.cc
+++ gui/control.cc
@@ -1,10 +1,10 @@
 /////////////////////////////////////////////////////////////////////////
-// $Id: control.cc,v 1.47 2002/04/18 00:22:19 bdenney Exp $
+// $Id: control.cc,v 1.48 2002/06/20 15:43:09 yakovlev Exp $
 /////////////////////////////////////////////////////////////////////////
 //
 /*
  * gui/control.cc
- * $Id: control.cc,v 1.47 2002/04/18 00:22:19 bdenney Exp $
+ * $Id: control.cc,v 1.48 2002/06/20 15:43:09 yakovlev Exp $
  *
  * This is code for a text-mode control panel.  Note that this file
  * does NOT include bochs.h.  Instead, it does all of its contact with
@@ -275,6 +275,8 @@
 "then immediately start the simulation.  A quick way to do this is to\n"
 "press return three times to accept the default choices (shown in\n"
 "square brackets).\n"
+"\n"
+"You can also start bochs with the -nocp option to skip these menus.\n";
 "\n"
 "1. Read options from...\n"
 "2. Edit options\n"


4digitdisplay.cxx: add Interesting tag and remove pointless array

Signed-off-by: Brendan Le Foll <3e0e8c4069934e8b47d99704927a85c66c0ceb33@intel.com>

--- examples/4digitdisplay.cxx
+++ examples/4digitdisplay.cxx
@@ -29,10 +29,10 @@
 int
 main(int argc, char **argv)
 {
-    uint8_t data[] = { 0xaa, 0xff, 0xff, 0xff };
-
+    //! [Interesting]
     upm::TM1637 *display = new upm::TM1637(8, 9); // di - 8, dcki - 9
-    display->write ("1981");
+    display->write ("1337");
+    //! [Interesting]

     std::cout << "exiting application" << std::endl;


more auto

more auto

git-svn-id: e171abefef93db0a74257c7d87d5b6400fe00c1f@4478 f22100f3-aa73-48fe-a4fb-fd497bb32605

--- trunk/extension/src/vi.cpp
+++ trunk/extension/src/vi.cpp
@@ -1080,8 +1080,8 @@
   {
     const wxString oper = filtered_address.BeforeFirst('\'');

-    int pos = filtered_address.Find('\'');
-    int size = 2;
+    auto pos = filtered_address.Find('\'');
+    auto size = 2;

     auto it =
       m_Markers.find(filtered_address.AfterFirst('\'').GetChar(0));


vulkan worker: force RGBA color type for PNG output (#366)

Many PNG decoders will ignore the alpha channel unless the color type is RGBA.

Fix #364 for our legacy vulkan worker.

--- vulkan-worker/src/common/vulkan_worker.cc
+++ vulkan-worker/src/common/vulkan_worker.cc
@@ -1542,7 +1542,13 @@
   // Convert to PNG
   std::vector<unsigned char> png;
   log("PNGENCODE START");
-  unsigned int png_encode_error = lodepng::encode(png, rgba_blob, width_, height_);
+  lodepng::State state;
+  state.encoder.auto_convert = 0;
+  state.info_raw.colortype = LodePNGColorType::LCT_RGBA;
+  state.info_raw.bitdepth = 8;
+  state.info_png.color.colortype = LodePNGColorType::LCT_RGBA;
+  state.info_png.color.bitdepth = 8;
+  unsigned int png_encode_error = lodepng::encode(png, rgba_blob, width_, height_, state);
   log("PNGENCODE END");
   assert(!png_encode_error);
   log("PNGSAVEFILE START");


infinite orange alert sound (#20723)

infinite orange alert sound (#20723)

--- selfdrive/ui/qt/sound.hpp
+++ selfdrive/ui/qt/sound.hpp
@@ -12,7 +12,7 @@
   {AudibleAlert::CHIME_ENGAGE, {"../assets/sounds/engaged.wav", 0}},
   {AudibleAlert::CHIME_WARNING1, {"../assets/sounds/warning_1.wav", 0}},
   {AudibleAlert::CHIME_WARNING2, {"../assets/sounds/warning_2.wav", 0}},
-  {AudibleAlert::CHIME_WARNING2_REPEAT, {"../assets/sounds/warning_2.wav", 3}},
+  {AudibleAlert::CHIME_WARNING2_REPEAT, {"../assets/sounds/warning_2.wav", -1}},
   {AudibleAlert::CHIME_WARNING_REPEAT, {"../assets/sounds/warning_repeat.wav", -1}},
   {AudibleAlert::CHIME_ERROR, {"../assets/sounds/error.wav", 0}},
   {AudibleAlert::CHIME_PROMPT, {"../assets/sounds/error.wav", 0}}


Monitor shows harc follows

Monitor shows harc follows

--- sense/camera/src/main.cpp
+++ sense/camera/src/main.cpp
@@ -16,6 +16,8 @@
 #include <sys/mman.h>
 #include <sys/ioctl.h>

+#include <SDL/SDL.h>
+
 #include <asm/types.h>          /* for videodev2.h */

 #include <linux/videodev2.h>
@@ -328,11 +330,38 @@
     }
 }

+
+int sdl_filter(const SDL_Event * event)
+{
+    return event->type == SDL_QUIT;
+}
+
+#define mask32(BYTE) (*(uint32_t *)(uint8_t [4]){ [BYTE] = 0xff })
+
+
 int main(int argc, char *argv[]) {
 	Sense sense("localhost", 7878);

 	Node cam_f, cam_l;
 	sense.makeHarcs(320 * 240, cam_f, cam_l);
+
+	atexit(SDL_Quit);
+    if (SDL_Init(SDL_INIT_VIDEO) < 0)
+        return 1;
+
+    SDL_WM_SetCaption("Dharc Sense Camera", NULL);
+
+	uint8_t *buffer_sdl;
+	SDL_Surface *data_sf;
+    buffer_sdl = (uint8_t*)malloc(width*height*3);
+
+    SDL_SetVideoMode(width, height, 24, SDL_HWSURFACE);
+
+    data_sf = SDL_CreateRGBSurfaceFrom(buffer_sdl, width, height,
+                                       24, width * 3,
+                                       mask32(0), mask32(1), mask32(2), 0);
+
+    SDL_SetEventFilter(sdl_filter);

 	open_device();
 	init_device();
@@ -372,9 +401,16 @@
 		read_frame();
 		for (auto i = 0U; i < data.size(); ++i) {
 			unsigned char y = *((char*)buffers[0].start + (2*i));
+			buffer_sdl[i*3] = y;
+			buffer_sdl[(i*3)+1] = y;
+			buffer_sdl[(i*3)+2] = y;
 			data[i] = 1.0f / (255.0f - static_cast<float>(y));
 		}
 		sense.activate(cam_f, cam_l, data);
+
+		SDL_Surface *screen = SDL_GetVideoSurface();
+		if (SDL_BlitSurface(data_sf, NULL, screen, NULL) == 0)
+		    SDL_UpdateRect(screen, 0, 0, 0, 0);
 	}

 	stop_capturing();


ENH: prevent multiple apparition of one unique application in the availble applciation

--- Code/ApplicationEngine/otbWrapperApplicationRegistry.cxx
+++ Code/ApplicationEngine/otbWrapperApplicationRegistry.cxx
@@ -129,6 +129,13 @@
     {
     availableApp.push_back((*k)->GetName());
     }
+  // If the ITK_AUTOLOAD_PATH contains
+  // several times the same path, application will appears several
+  // times in the list.To be cleaner, we erase multiple
+  std::vector<std::string>::iterator it;
+  it = std::unique(availableApp.begin(), availableApp.end());
+  availableApp.resize( it - availableApp.begin() );
+
   return availableApp;
 }


* Bug-fix for mesh size file usage with OpenCascade geometry

--- libsrc/occ/occgenmesh.cpp
+++ libsrc/occ/occgenmesh.cpp
@@ -1113,19 +1113,6 @@

          mesh->SetLocalH (bb.PMin(), bb.PMax(), 0.5);

-         // Philippose - 09/03/2009
-         // Added the capability to load the mesh size from a
-         // file also for OpenCascade Geometry
-         // Note:
-         // ** If the "uselocalh" option is ticked in
-         // the "mesh options...insider" menu, the mesh
-         // size will be further modified by the topology
-         // analysis routines.
-         // ** To use the mesh size file as the sole source
-         // for defining the mesh size, uncheck the "uselocalh"
-         // option.
-         mesh->LoadLocalMeshSize (mparam.meshsizefilename);
-
          if (mparam.uselocalh)
          {

@@ -1382,6 +1369,19 @@
             multithread.task = savetask;

          }
+
+         // Philippose - 09/03/2009
+         // Added the capability to load the mesh size from a
+         // file also for OpenCascade Geometry
+         // Note:
+         // ** If the "uselocalh" option is ticked in
+         // the "mesh options...insider" menu, the mesh
+         // size will be further modified by the topology
+         // analysis routines.
+         // ** To use the mesh size file as the sole source
+         // for defining the mesh size, uncheck the "uselocalh"
+         // option.
+         mesh->LoadLocalMeshSize (mparam.meshsizefilename);
       }

       if (multithread.terminate || perfstepsend <= MESHCONST_ANALYSE)


Update Color package.

Update Color package.

--- libtbag/graphic/Color.hpp
+++ libtbag/graphic/Color.hpp
@@ -154,8 +154,8 @@
     Rgb24(Rgb24 const & obj) TBAG_NOEXCEPT : r(obj.r), g(obj.g), b(obj.b)
     { /* EMPTY. */ }

-    Rgb24(Rgb24 && obj) TBAG_NOEXCEPT : r(), g(), b()
-    { *this = std::move(obj); }
+    Rgb24(Rgb24 && obj) TBAG_NOEXCEPT : r(obj.r), g(obj.g), b(obj.b)
+    { /* EMPTY. */ }

     Rgb24 & operator =(Rgb24 const & obj) TBAG_NOEXCEPT
     {
@@ -169,7 +169,11 @@

     Rgb24 & operator =(Rgb24 && obj) TBAG_NOEXCEPT
     {
-        swap(obj);
+        if (this != &obj) {
+            r = obj.r;
+            g = obj.g;
+            b = obj.b;
+        }
         return *this;
     }

@@ -267,8 +271,8 @@
     Rgb32(Rgb32 const & obj) TBAG_NOEXCEPT : r(obj.r), g(obj.g), b(obj.b), a(obj.a)
     { /* EMPTY. */ }

-    Rgb32(Rgb32 && obj) TBAG_NOEXCEPT : r(), g(), b(), a()
-    { *this = std::move(obj); }
+    Rgb32(Rgb32 && obj) TBAG_NOEXCEPT : r(obj.r), g(obj.g), b(obj.b), a(obj.a)
+    { /* EMPTY. */ }

     Rgb32 & operator =(Rgb32 const & obj) TBAG_NOEXCEPT
     {
@@ -283,7 +287,12 @@

     Rgb32 & operator =(Rgb32 && obj) TBAG_NOEXCEPT
     {
-        swap(obj);
+        if (this != &obj) {
+            r = obj.r;
+            g = obj.g;
+            b = obj.b;
+            a = obj.a;
+        }
         return *this;
     }


Indent

Indent

--- ha_mroonga.cpp
+++ ha_mroonga.cpp
@@ -89,18 +89,18 @@
 #define MRN_LONG_TEXT_SIZE  (1 << 31) //  2Gbytes

 #if MYSQL_VERSION_ID >= 50500
-#ifdef DBUG_OFF
-#ifndef _WIN32
+#  ifdef DBUG_OFF
+#    ifndef _WIN32
 extern mysql_mutex_t LOCK_open;
-#endif
-#endif
+#    endif
+#  endif
 mysql_mutex_t *mrn_LOCK_open;
 #  define mrn_open_mutex_lock() mysql_mutex_lock(mrn_LOCK_open)
 #  define mrn_open_mutex_unlock() mysql_mutex_unlock(mrn_LOCK_open)
 #else
-#ifndef _WIN32
+#  ifndef _WIN32
 extern pthread_mutex_t LOCK_open;
-#endif
+#  endif
 pthread_mutex_t *mrn_LOCK_open;
 #  define mrn_open_mutex_lock()
 #  define mrn_open_mutex_unlock()


fix syntax errors

fix syntax errors

--- examples/perf/testperf.cpp
+++ examples/perf/testperf.cpp
@@ -164,7 +164,7 @@
 int main(int argc, const char **argv)
 {
   unsigned int srcGen = 0;
-
+  unsigned repeatCount = 0;

   fprintf(stderr, "%s %s\n", __DATE__, __TIME__);

@@ -211,6 +211,7 @@

       dotest(numWords, repeatCount);
     }
+  }

   device->getStateDbg();
   fprintf(stderr, "Main::exiting\n");


Missed a usage of TestShellRequestContext.  This one is allowed to behave as
before.

TBR=tony

Review URL: http://codereview.chromium.org/11338

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

--- webkit/tools/test_shell/node_leak_test.cc
+++ webkit/tools/test_shell/node_leak_test.cc
@@ -59,7 +59,7 @@
         parsed_command_line.HasSwitch(test_shell::kPlaybackMode) ?
         net::HttpCache::PLAYBACK : net::HttpCache::NORMAL;
     SimpleResourceLoaderBridge::Init(
-        new TestShellRequestContext(cache_path, mode));
+        new TestShellRequestContext(cache_path, mode, false));

     TestShellTest::SetUp();
   }


Fix gcc7 warning about multiplication in boolean context (#101)

see https://github.com/aws/aws-sdk-cpp/issues/524 for details

--- aws-cpp-sdk-core/source/http/curl/CurlHttpClient.cpp
+++ aws-cpp-sdk-core/source/http/curl/CurlHttpClient.cpp
@@ -564,9 +564,9 @@
     HttpRequest* request = context->m_request;
     std::shared_ptr<Aws::IOStream> ioStream = request->GetContentBody();

-    if (ioStream != nullptr && size * nmemb)
-    {
-        size_t amountToRead = size * nmemb;
+    const size_t amountToRead = size * nmemb;
+    if (ioStream != nullptr && amountToRead > 0)
+    {
         ioStream->read(ptr, amountToRead);
         size_t amountRead = static_cast<size_t>(ioStream->gcount());
         auto& sentHandler = request->GetDataSentEventHandler();


Allow test_shell to open relative paths, like "test_shell ."

Review URL: http://codereview.chromium.org/11555

git-svn-id: dd90618784b6a4b323ea0c23a071cb1c9e6f2ac7@5813 4ff67af0-8c30-449e-8e8b-ad334ec8d88c

--- webkit/tools/test_shell/test_shell_gtk.cc
+++ webkit/tools/test_shell/test_shell_gtk.cc
@@ -461,11 +461,12 @@
   LOG(INFO) << "Loading " << WideToUTF8(url) << " in frame '"
           << WideToUTF8(frame_string) << "'";

+  std::wstring path(url);
   GURL gurl;
   // PathExists will reject any string with no leading '/'
   // as well as empty strings.
-  if (file_util::PathExists(url))
-    gurl = net::FilePathToFileURL(url);
+  if (file_util::AbsolutePath(&path))
+    gurl = net::FilePathToFileURL(path);
   else
     gurl = GURL(WideToUTF8(url));


examples/seq: add 16 sequencers

examples/seq: add 16 sequencers

--- examples/sequencer/seq.cpp
+++ examples/sequencer/seq.cpp
@@ -2,6 +2,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <signal.h>
+#include <string.h>

 #include <iostream>
 #include <cstdlib>
@@ -15,11 +16,13 @@
 static volatile uint32_t done;
 static struct ctlra_dev_t* dev;

-static Sequencer *sequencer;
+static Sequencer *sequencers[16];

 #define MODE_GROUP   0
 #define MODE_PADS    1
 #define MODE_PATTERN 2
+
+void *midi_out_void;

 struct col_t
 {
@@ -73,6 +76,7 @@

 	/* Pads */
 	uint8_t pads_pressed[16];
+	uint8_t pads_seq_play[16];

 	/* Pattern */
 	uint8_t pattern_pad_id; /* the pad that this pattern is playing */
@@ -83,6 +87,8 @@
 	/* group, pads, sequencer modes */
 	struct mm_t *mm = &mm_static;
 	const struct col_t *col = &grp_col[mm->grp_id];
+	struct Sequencer *sequencer = sequencers[mm->pattern_pad_id];
+
 	switch(mm->mode) {
 	case MODE_PATTERN: {
 		for(int i = 0; i < 16; i++) {
@@ -94,6 +100,10 @@
 		int on = sequencer_get_step(sequencer, step % 16);
 		ctlra_dev_light_set(dev, NI_MASCHINE_MIKRO_MK2_LED_PAD_1 + step,
 				    on ?  0x007f7f7f : 0x000f0f0f );
+		if(mm->shift_pressed) {
+		ctlra_dev_light_set(dev, NI_MASCHINE_MIKRO_MK2_LED_PAD_1 +
+				    mm->pattern_pad_id, 0x00ffffff);
+		}
 		break;
 		}
 	case MODE_GROUP:
@@ -104,10 +114,16 @@
 		}
 		break;
 	case MODE_PADS:
+		/* pressed pads (manually - hence overrides */
 		for(int i = 0; i < 16; i++) {
 			ctlra_dev_light_set(dev, NI_MASCHINE_MIKRO_MK2_LED_PAD_1 + i,
 					    col_dim(&grp_col[mm->grp_id],
 						    mm->pads_pressed[i] ? 1.0 : 0.02));
+		}
+		/* sequencer playbacks */
+		for(int i = 0; i < 16; i++) {
+			if(mm->pads_seq_play[i])
+				ctlra_dev_light_set(dev, NI_MASCHINE_MIKRO_MK2_LED_PAD_1 + i, 0xffffffff);
 		}
 		break;
 	}
@@ -135,6 +151,7 @@
 	/* See below, a RtMidiOut instance is passed as the device's
 	 * userdata pointer when registering the event_func */
 	RtMidiOut *midiout = (RtMidiOut *)userdata;
+	struct Sequencer *sequencer = sequencers[mm->pattern_pad_id];

 	std::vector<unsigned char> message(3);

@@ -184,10 +201,18 @@
 				}
 			}
 			if(mm->mode == MODE_PATTERN && pr) {
-				if(mm->shift_pressed)
+				if(mm->shift_pressed) {
 					mm->pattern_pad_id = e->grid.pos;
+					//printf("new pattern pad id %d\n", mm->pattern_pad_id);
+				}
 				else
 					sequencer_toggle_step(sequencer, e->grid.pos);
+			}
+			if(mm->mode == MODE_PADS && pr) {
+				message[0] = 0x90;
+				message[1] = 36 + 16 - e->grid.pos;
+				message[2] = int(e->grid.pressed * 107.f);
+				midiout->sendMessage( &message );
 			}
 			mm->pads_pressed[e->grid.pos] = e->grid.pressed;
 			break;
@@ -241,12 +266,23 @@
 	}
 	*userdata_for_event_func = midiout;

+	midi_out_void = midiout;
+
 	return 1;
 }

 void seqEventCb(int frame, int note, int velocity, void* user_data )
 {
 	printf("%s: %d, %d : %d\n", __func__, frame, note, velocity);
+	memset(mm_static.pads_seq_play, 0, sizeof(mm_static.pads_seq_play));
+	mm_static.pads_seq_play[note] = velocity;
+
+	RtMidiOut *midiout = (RtMidiOut *)midi_out_void;
+	std::vector<unsigned char> message(3);
+	message[0] = 0x90;
+	message[1] = 36 + note;
+	message[2] = velocity;
+	midiout->sendMessage( &message );
 }

 #define SR 48000
@@ -255,14 +291,14 @@
 {
 	signal(SIGINT, sighndlr);

-	sequencer = sequencer_new(SR);
-	sequencer_set_callback(sequencer, seqEventCb, 0x0);
-	sequencer_set_length(sequencer, SR * 1.2);
-	sequencer_set_num_steps(sequencer, 16);
-	sequencer_toggle_step(sequencer, 0);
-	sequencer_toggle_step(sequencer, 4);
-	sequencer_toggle_step(sequencer, 10);
-	sequencer_toggle_step(sequencer, 12);
+	for(int i = 0; i < 16; i++) {
+		struct Sequencer *sequencer = sequencer_new(SR);
+		sequencer_set_callback(sequencer, seqEventCb, 0x0);
+		sequencer_set_length(sequencer, SR * 1.2);
+		sequencer_set_num_steps(sequencer, 16);
+		sequencer_set_note(sequencer, i);
+		sequencers[i] = sequencer;
+	}

 	mm_static.mode = MODE_PATTERN;

@@ -273,7 +309,10 @@

 	while(!done) {
 		ctlra_idle_iter(ctlra);
-		sequencer_process( sequencer, 128 );
+		for(int i = 0; i < 16; i++) {
+			struct Sequencer *sequencer = sequencers[i];
+			sequencer_process( sequencer, 128 );
+		}
 		usleep(1000 * 1000 / sleep);
 	}


[LIB-49] Clean up testWarp/main.cpp

[LIB-49] Clean up testWarp/main.cpp

--- examples/testWarp/main.cpp
+++ examples/testWarp/main.cpp
@@ -92,45 +92,11 @@
 int main(int argc, char *argv[])
 {
     QCoreApplication a(argc, argv);
-
-//    Matrix<double,6,3> sLm;
-//    sLm <<  1,1,1,
-//            2,1,1,
-//            3,1,1,
-//            1,2,1,
-//            2,2,1,
-//            3,2,1;
-//    std::cout << "Here is the matrix sLm:" << std::endl << sLm << std::endl;
-
-//    Matrix<double,6,3> dLm;
-//    dLm <<  1,1,2,
-//            2,1,3,
-//            3,1,2,
-//            1,2,2,
-//            2,2,3,
-//            3,2,2;
-
-//    Matrix<double,16,3> sVert;
-//    sVert <<1.0,0.5,1,
-//            1.5,0.5,1,
-//            2.0,0.5,1,
-//            2.3,0.5,1,
-//            2.7,0.5,1,
-//            3.0,0.5,1,
-//            3.5,0.5,1,
-//            4.0,0.5,1,
-//            1.0,1,1,
-//            1.5,1,1,
-//            2.0,1,1,
-//            2.3,1,1,
-//            2.7,1,1,
-//            3.0,1,1,
-//            3.5,1,1,
-//            4.0,1,1;;
-
-    //
+    //
+    // Destination Landmarks:
+    //
+
     // Read Electrode Positions from fiff raw
-    //
 //    QFile t_fileRaw("./MNE-sample-data/MEG/sample/sample_audvis_raw.fif");
 //    FiffRawData raw(t_fileRaw);
 //    QList<FiffChInfo> ChannelInfo= raw.info.chs;
@@ -157,12 +123,11 @@
 //        ElecPos(i,2)=tempElecInfo[i][2];
 //    }

-    //
-    // Read Electrode Positions from fiff (digitizer points)
-    //
-
-    QFile t_fileElec("./MNE-sample-data/warping/AVG4-0Years_GSN128.fif");
-//    QList<FiffDigPoint> dig = FiffDigPoint::read(t_fileElec);
+    //Read Electrode Positions from fiff (digitizer points)
+//    QFile t_fileElec("./MNE-sample-data/warping/AVG4-0Years_GSN128.fif");
+    QFile t_fileElec("D:/Studium/Master/Masterarbeit/Daten/4889503/ID_4889503_act/bem/4889503-5120-5120-5120-bem.fif");
+
+
     FiffDigPointSet digset(t_fileElec);

@@ -191,50 +156,29 @@
 //    std::cout << "Here is the matrix ElecPos:" << std::endl << ElecPos << std::endl;

     //
-    // read electrode positions from Database
-    //
-//    QString electrodeFileName= "./MNE-sample-data/MriDatabase/FirstYear/Sources/Electrodes/AVG3-0Months_10-5_Electrodes.txt";
+    // source Landmarks:
+    //
+
+    // read average electrode positions from Database
+    //    QString electrodeFileName= "./MNE-sample-data/MriDatabase/FirstYear/Sources/Electrodes/AVG3-0Months_10-5_Electrodes.txt";
 //    Matrix<double, Dynamic ,3> ElecPos = test.readsLm(electrodeFileName);
 //    std::cout << "Here is the matrix ElecPos:" << std::endl << ElecPos << std::endl;

     //
-    //Read BEM from fiff
-    //
+    // Source Bem:
+    //
+
+    // Read BEM from fiff
 //    QFile t_fileBem("./MNE-sample-data/subjects/sample/bem/sample-5120-5120-5120-bem.fif");
 //    MNELIB::MNEBem t_Bem (t_fileBem) ;

     //
-    // Read Transformation
+    // Read and apply Transformation of source landmarks (source)
     //

     QFile t_fileTrans("./MNE-sample-data/warping/AVG4-0Years_GSN128-trans.fif");
     FiffCoordTrans t_Trans (t_fileTrans);
     ElecPos=t_Trans.apply_trans(ElecPos);
-
-//    //
-//    // prepare warp
-//    //
-//    MatrixXd sLm=ElecPos;
-//    MatrixXd random(ElecPos.rows(),3);
-//    srand(time(NULL));
-//    for (int i=0;i<ElecPos.rows();i++)
-//    {
-
-//        for (int j=0; j<3;j++)
-//        {
-//            random(i,j)=rand();
-//            random(i,j)/=RAND_MAX;
-//            random(i,j)*=0.06;
-//            random(i,j)-=0.03;
-//            //            random(i,j)=0.005*(rand()/RAND_MAX);
-//        }
-//    }
-////    std::cout << "Here are the first row of the matrix random:" << std::endl << random.topRows(9) << std::endl;
-//    MatrixXd dLm=sLm+random;
-//    MNELIB::MNEBemSurface skin=t_Bem[0];
-//    MatrixXd sVert=skin.rr.cast<double>();
-
-//    std::cout << "Here are the first row of the matrix skin.rr bevor warp:" << std::endl << skin.rr.topRows(9) << std::endl;

 //    //
@@ -264,5 +208,3 @@
 //    MNELIB::MNEBemSurface skinWarped=t_BemWarpedB[0];
     return a.exec();
 }
-
-


raft: modify_config: support voting state change

Handle requests to change voting for servers already present in the
current configuration.

Signed-off-by: Alejo Sanchez <004be06a28e38b437b038f9b5c0b9f5758b792e9@scylladb.com>

--- raft/server.cc
+++ raft/server.cc
@@ -490,10 +490,19 @@
         // Wait for a new slot to become available
         auto cfg = get_configuration().current;
         for (auto& addr : add) {
-            logger.trace("[{}] adding server {}", id(), addr.id);
-            auto [it, inserted] = cfg.insert(addr);
-            if (!inserted) {
-                logger.warn("[{}] the server {} already exists in configuration", id(), addr.id);
+            logger.trace("[{}] adding server {} as {}", id(), addr.id,
+                    addr.can_vote? "voter" : "non-voter");
+            auto it = cfg.find(addr);
+            if (it == cfg.end()) {
+                cfg.insert(addr);
+            } else if (it->can_vote != addr.can_vote) {
+                cfg.erase(addr);
+                cfg.insert(addr);
+                logger.trace("[{}] server {} already in configuration now {}",
+                        id(), addr.id, addr.can_vote? "voter" : "non-voter");
+            } else {
+                logger.warn("[{}] the server {} already exists in configuration as {}",
+                        id(), addr.id, addr.can_vote? "voter" : "non-voter");
             }
         }
         for (auto& to_remove: del) {