git-svn-id: svn://ultimatepp.org/upp/trunk@8801 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2015-08-09 06:58:28 +00:00
parent 59215a1315
commit 83f2d755bb
13 changed files with 427 additions and 1 deletions

10
uppdev/DPI/DPI.upp Normal file
View file

@ -0,0 +1,10 @@
uses
CtrlLib;
file
hq2.cpp,
main.cpp;
mainconfig
"" = "GUI";

192
uppdev/DPI/hq2.cpp Normal file
View file

@ -0,0 +1,192 @@
#include <Core/Core.h>
using namespace Upp;
enum {
diff_offset = (0x440 << 21) + (0x207 << 11) + 0x407,
diff_mask = (0x380 << 21) + (0x1f0 << 11) + 0x3f0,
};
uint32 yuvTable[32768];
uint8 rotate[256];
const uint8 hqTable[256] = {
4, 4, 6, 2, 4, 4, 6, 2, 5, 3, 15, 12, 5, 3, 17, 13,
4, 4, 6, 18, 4, 4, 6, 18, 5, 3, 12, 12, 5, 3, 1, 12,
4, 4, 6, 2, 4, 4, 6, 2, 5, 3, 17, 13, 5, 3, 16, 14,
4, 4, 6, 18, 4, 4, 6, 18, 5, 3, 16, 12, 5, 3, 1, 14,
4, 4, 6, 2, 4, 4, 6, 2, 5, 19, 12, 12, 5, 19, 16, 12,
4, 4, 6, 2, 4, 4, 6, 2, 5, 3, 16, 12, 5, 3, 16, 12,
4, 4, 6, 2, 4, 4, 6, 2, 5, 19, 1, 12, 5, 19, 1, 14,
4, 4, 6, 2, 4, 4, 6, 18, 5, 3, 16, 12, 5, 19, 1, 14,
4, 4, 6, 2, 4, 4, 6, 2, 5, 3, 15, 12, 5, 3, 17, 13,
4, 4, 6, 2, 4, 4, 6, 2, 5, 3, 16, 12, 5, 3, 16, 12,
4, 4, 6, 2, 4, 4, 6, 2, 5, 3, 17, 13, 5, 3, 16, 14,
4, 4, 6, 2, 4, 4, 6, 2, 5, 3, 16, 13, 5, 3, 1, 14,
4, 4, 6, 2, 4, 4, 6, 2, 5, 3, 16, 12, 5, 3, 16, 13,
4, 4, 6, 2, 4, 4, 6, 2, 5, 3, 16, 12, 5, 3, 1, 12,
4, 4, 6, 2, 4, 4, 6, 2, 5, 3, 16, 12, 5, 3, 1, 14,
4, 4, 6, 2, 4, 4, 6, 2, 5, 3, 1, 12, 5, 3, 1, 14,
};
static void initialize() {
static bool initialized = false;
if(initialized == true) return;
initialized = true;
for(unsigned i = 0; i < 32768; i++) {
uint8 R = (i >> 0) & 31;
uint8 G = (i >> 5) & 31;
uint8 B = (i >> 10) & 31;
//bgr555->bgr888
double r = (R << 3) | (R >> 2);
double g = (G << 3) | (G >> 2);
double b = (B << 3) | (B >> 2);
//bgr888->yuv888
double y = (r + g + b) * (0.25f * (63.5f / 48.0f));
double u = ((r - b) * 0.25f + 128.0f) * (7.5f / 7.0f);
double v = ((g * 2.0f - r - b) * 0.125f + 128.0f) * (7.5f / 6.0f);
yuvTable[i] = ((unsigned)y << 21) + ((unsigned)u << 11) + ((unsigned)v);
}
for(unsigned n = 0; n < 256; n++) {
rotate[n] = ((n >> 2) & 0x11) | ((n << 2) & 0x88)
| ((n & 0x01) << 5) | ((n & 0x08) << 3)
| ((n & 0x10) >> 3) | ((n & 0x80) >> 5);
}
}
static bool same(uint16 x, uint16 y) {
return !((yuvTable[x] - yuvTable[y] + diff_offset) & diff_mask);
}
static bool diff(uint32 x, uint16 y) {
return ((x - yuvTable[y]) & diff_mask);
}
static void grow(uint32 &n) { n |= n << 16; n &= 0x03e07c1f; }
static uint16 pack(uint32 n) { n &= 0x03e07c1f; return uint16(n | (n >> 16)); }
static uint16 blend1(uint32 A, uint32 B) {
grow(A); grow(B);
A = (A * 3 + B) >> 2;
return pack(A);
}
static uint16 blend2(uint32 A, uint32 B, uint32 C) {
grow(A); grow(B); grow(C);
return pack((A * 2 + B + C) >> 2);
}
static uint16 blend3(uint32 A, uint32 B, uint32 C) {
grow(A); grow(B); grow(C);
return pack((A * 5 + B * 2 + C) >> 3);
}
static uint16 blend4(uint32 A, uint32 B, uint32 C) {
grow(A); grow(B); grow(C);
return pack((A * 6 + B + C) >> 3);
}
static uint16 blend5(uint32 A, uint32 B, uint32 C) {
grow(A); grow(B); grow(C);
return pack((A * 2 + (B + C) * 3) >> 3);
}
static uint16 blend6(uint32 A, uint32 B, uint32 C) {
grow(A); grow(B); grow(C);
return pack((A * 14 + B + C) >> 4);
}
static uint16 blend(unsigned rule, uint16 E, uint16 A, uint16 B, uint16 D, uint16 F, uint16 H) {
switch(rule) { default:
case 0: return E;
case 1: return blend1(E, A);
case 2: return blend1(E, D);
case 3: return blend1(E, B);
case 4: return blend2(E, D, B);
case 5: return blend2(E, A, B);
case 6: return blend2(E, A, D);
case 7: return blend3(E, B, D);
case 8: return blend3(E, D, B);
case 9: return blend4(E, D, B);
case 10: return blend5(E, D, B);
case 11: return blend6(E, D, B);
case 12: return same(B, D) ? blend2(E, D, B) : E;
case 13: return same(B, D) ? blend5(E, D, B) : E;
case 14: return same(B, D) ? blend6(E, D, B) : E;
case 15: return same(B, D) ? blend2(E, D, B) : blend1(E, A);
case 16: return same(B, D) ? blend4(E, D, B) : blend1(E, A);
case 17: return same(B, D) ? blend5(E, D, B) : blend1(E, A);
case 18: return same(B, F) ? blend3(E, B, D) : blend1(E, D);
case 19: return same(D, H) ? blend3(E, D, B) : blend1(E, B);
}
}
void filter_size(unsigned &width, unsigned &height) {
initialize();
width *= 2;
height *= 2;
}
void filter_render(
uint32 *colortable, uint32 *output, unsigned outpitch,
const uint16 *input, unsigned pitch, unsigned width, unsigned height
) {
initialize();
pitch >>= 1;
outpitch >>= 2;
for(unsigned y = 0; y < height; y++) {
const uint16 *in = input + y * pitch;
uint32 *out0 = output + y * outpitch * 2;
uint32 *out1 = output + y * outpitch * 2 + outpitch;
int prevline = (y == 0 ? 0 : pitch);
int nextline = (y == height - 1 ? 0 : pitch);
in++;
*out0++ = 0; *out0++ = 0;
*out1++ = 0; *out1++ = 0;
for(unsigned x = 1; x < width - 1; x++) {
uint16 A = *(in - prevline - 1);
uint16 B = *(in - prevline + 0);
uint16 C = *(in - prevline + 1);
uint16 D = *(in - 1);
uint16 E = *(in + 0);
uint16 F = *(in + 1);
uint16 G = *(in + nextline - 1);
uint16 H = *(in + nextline + 0);
uint16 I = *(in + nextline + 1);
uint32 e = yuvTable[E] + diff_offset;
uint8 pattern;
pattern = diff(e, A) << 0;
pattern |= diff(e, B) << 1;
pattern |= diff(e, C) << 2;
pattern |= diff(e, D) << 3;
pattern |= diff(e, F) << 4;
pattern |= diff(e, G) << 5;
pattern |= diff(e, H) << 6;
pattern |= diff(e, I) << 7;
*(out0 + 0) = colortable[blend(hqTable[pattern], E, A, B, D, F, H)]; pattern = rotate[pattern];
*(out0 + 1) = colortable[blend(hqTable[pattern], E, C, F, B, H, D)]; pattern = rotate[pattern];
*(out1 + 1) = colortable[blend(hqTable[pattern], E, I, H, F, D, B)]; pattern = rotate[pattern];
*(out1 + 0) = colortable[blend(hqTable[pattern], E, G, D, H, B, F)];
in++;
out0 += 2;
out1 += 2;
}
in++;
*out0++ = 0; *out0++ = 0;
*out1++ = 0; *out1++ = 0;
}
}

4
uppdev/DPI/init Normal file
View file

@ -0,0 +1,4 @@
#ifndef _DPI_icpp_init_stub
#define _DPI_icpp_init_stub
#include "CtrlLib/init"
#endif

7
uppdev/DPI/main.cpp Normal file
View file

@ -0,0 +1,7 @@
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
GUI_APP_MAIN
{
}

View file

@ -4,6 +4,7 @@ uses
Painter;
file
C:\\upp\\out\\uppdev\\MSC9.Debug.Debug_Full.Gui\RichEditTest.log,
main.cpp,
todo.txt,
test.tpp,

View file

@ -35,6 +35,8 @@ GUI_APP_MAIN
// ChStdSkin();
// SetLanguage(LNG_('P','L','P','L'));
Ctrl::SetHiDPIEnabled();
// InstallCrashDump();
DUMP(GetStdFontCy());
DUMP(GUI_PopUpEffect());

View file

@ -23,12 +23,22 @@ void Test(const char *path)
Parser p;
// p.Do(in, base, 0, 0, GetFileTitle(path), callback(AddError), Vector<String>(), Vector<String>(), Index<String>());
<<<<<<< .mine
<<<<<<< .mine
RTIMESTOP("TEST");
p.Do(in, base, 0, 0, GetFileTitle(path), callback(AddError),
=======
p.Do(in, base, 0, FILE_C, GetFileTitle(path), callback(AddError),
=======
p.Do(in, base, 0, FILE_CPP, GetFileTitle(path), callback(AddError),
>>>>>>> .r8796
>>>>>>> .r8637
Vector<String>(), Vector<String>(), hh);
Qualify(base);
if(errs.GetCount())
DUMPC(errs);
Qualify(base);
String out;
for(int i = 0; i < base.GetCount(); i++) {
out << Nvl(base.GetKey(i), "<globals>") << " {\n";

View file

@ -1,2 +1,19 @@
<<<<<<< .mine
<<<<<<< .mine
using namespace Upp;struct testImg {
enum {I_Hahah,
};
static Image Hahah();
static Iml& Iml();static int Find(const UPP::String& s);static int Find(const char *s);static int GetCount();static String GetId(int i);static Image Get(int i);static Image Get(const char *s);static Image Get(const UPP::String& s);static void Set(int i, const UPP::Image& m);static void Set(const char *s, const UPP::Image& m);static void Reset();};
=======
void Foo::Foo() {
void Foo::Bar();
void Foo::Bar2() {
label:
int x = 10;>>>>>>> .r8637
=======
byte backpaint:2;//2
bool hasdhctrl:1;
>>>>>>> .r8796

View file

@ -7,4 +7,84 @@
using namespace Upp;
<<<<<<< .mine
void RemoveComments(String& l, bool& incomment);
const Index<String>& CppKeywordsIndex();
struct CppMacro : Moveable<CppMacro>, DeepCopyOption<CppMacro> {
String param;
String body;
String Define(const char *s);
String Expand(const Vector<String>& p) const;
String ToString() const;
};
enum PPItemType {
PP_DEFINE,
PP_INCLUDE,
PP_USING,
PP_NAMESPACE,
PP_NAMESPACE_END
};
struct PPItem : Moveable<PPItem> {
int type;
String id;
CppMacro macro;
};
struct PPFile { // contains "macro extract" of file, only info about macros defined and namespaces
FileTime filetime;
Array<PPItem> item;
Index<String> includes;
void Parse(Stream& in);
void Dump() const;
private:
void CheckEndNamespace(Vector<int>& namespace_block, int level);
};
const PPFile& GetPPFile(const char *path);
String GetIncludePath(const String& s, const String& filedir, const String& include_path);
bool IncludesFile(const String& parent_path, const String& header_path, const String& include_path);
struct Cpp {
bool incomment;
bool done;
String include_path;
VectorMap<String, CppMacro> macro;
String output;
Index<String> usedmacro;
Index<String> definedmacro;
Index<String> namespace_using;
Vector<String> namespace_stack;
void Define(const char *s);
static const char *SkipString(const char *s);
void ParamAdd(Vector<String>& param, const char *b, const char *e);
String Expand(const char *s, Index<String>& notmacro);
String Expand(const char *s);
void Do(const String& sourcefile, Stream& in, const String& currentfile,
Index<String>& visited, const Index<String> *get_macros);
bool Preprocess(const String& sourcefile, Stream& in, const String& currentfile,
const Index<String> *get_macros = NULL);
typedef Cpp CLASSNAME;
};
=======
>>>>>>> .r8434
#endif

View file

@ -1,3 +1,5 @@
<<<<<<< .mine
30214154=======
Gather files 0.375
Checking files 0.031
Removing files 0.000
@ -77,3 +79,4 @@ TIMING Preprocess : 1.58 s - 1.38 ms ( 1.58 s / 1146 ), min: 0.00 ns, m
TIMING GetIncludePath : 166.08 ms - 366.85 ns (184.00 ms / 452724 ), min: 0.00 ns, max: 1.00 ms, nesting: 1 - 452724
TIMING PP read : 315.95 ms - 275.46 us (316.00 ms / 1147 ), min: 0.00 ns, max: 11.00 ms, nesting: 1 - 1147
TIMING sCppFile make : 999.96 us - 999.96 us ( 1.00 ms / 1 ), min: 1.00 ms, max: 1.00 ms, nesting: 1 - 1
>>>>>>> .r8434

View file

@ -4,6 +4,13 @@ uses
file
cpp.h,
<<<<<<< .mine
util.cpp,
macro.cpp,
ppfile.cpp,
cpp.cpp,
=======
>>>>>>> .r8434
main.cpp,
test.h,
testfile,

View file

@ -22,12 +22,24 @@ void Test(const char *sourcefile, const char *currentfile)
{ RTIMING("Preprocess");
cpp.Preprocess(sourcefile, in, currentfile);
DUMP(cpp.namespace_stack);
<<<<<<< .mine
DUMP(cpp.output);
=======
>>>>>>> .r8434
DUMP(cpp.usedmacro);
<<<<<<< .mine
DUMP(cpp.definedmacro);
=======
DUMP(cpp.macro.GetCount());
>>>>>>> .r8434
}
LOG("=================================");
<<<<<<< .mine
/*
=======
LOG(cpp.output);
>>>>>>> .r8434
/*
{
Cpp cpp2;
@ -35,6 +47,7 @@ void Test(const char *sourcefile, const char *currentfile)
cpp2.Preprocess(sourcefile, NilStream(), currentfile, &cpp.usedmacro);
DUMP(cpp2.macro);
}
*/
for(int i = 0; i < 100; i++)
{
RTIMING("GetMacros");
@ -76,6 +89,41 @@ CONSOLE_APP_MAIN
Test("C:\\u\\upp.src\\uppsrc\\Core\\Format.h", "C:\\u\\upp.src\\uppsrc\\Core\\Format.cpp");
return;
<<<<<<< .mine
#endif
{
RTIMING("Pass1");
Test("C:\\u\\upp.src\\uppsrc\\Core\\Topt.h", "C:\\u\\upp.src\\uppsrc\\Core\\Format.cpp");
}
#ifndef _DEBUG
for(int i = 0; i < 100; i++) {
Test("C:\\u\\upp.src\\uppsrc\\Core\\Format.h", "C:\\u\\upp.src\\uppsrc\\Core\\Format.cpp");
}
#endif
#if 0
{
RTIMING("Pass1");
Index<String> visited;
// RecursePP("c:/u/upp.src/uppsrc/CtrlLib/EditField.cpp", include_path, visited);
}
DDUMP(IncludesFile("c:/u/upp.src/uppsrc/CtrlLib/EditField.cpp", "c:/u/upp.src/uppsrc/Core/Core.h", include_path));
DDUMP(IncludesFile("c:/u/upp.src/uppsrc/CtrlLib/EditField.cpp", "c:/u/upp.src/uppsrc/Core/Core2.h", include_path));
for(int i = 0; i < 1000; i++) {
RTIMING("IncludesFile true");
IncludesFile("c:/u/upp.src/uppsrc/CtrlLib/EditField.cpp", "c:/u/upp.src/uppsrc/Core/Core.h", include_path);
}
for(int i = 0; i < 1000; i++) {
RTIMING("IncludesFile false");
IncludesFile("c:/u/upp.src/uppsrc/CtrlLib/EditField.cpp", "c:/u/upp.src/uppsrc/Core/Core1.h", include_path);
}
#endif
// GetPPFile(GetDataFile("test.h")).Dump();
return;
=======
>>>>>>> .r8434
}
// TEST:a,b:|a|b|\n

45
uppdev/cpp2/util.cpp Normal file
View file

@ -0,0 +1,45 @@
#include "cpp.h"
void SetSpaces(String& l, int pos, int count)
{
StringBuffer s = l;
memset(~s + pos, ' ', count);
l = s;
}
void RemoveComments(String& l, bool& incomment)
{
int q = -1;
int w = -1;
int lim = l.Find("//");
if(incomment)
q = w = 0;
else {
q = l.Find("/*");
if(q >= 0 && q < lim)
w = q + 2;
}
while(q >= 0 && q < lim) {
int eq = l.Find("*/", w);
if(eq < 0) {
incomment = true;
SetSpaces(l, q, l.GetCount() - q);
return;
}
SetSpaces(l, q, eq + 2 - q);
incomment = false;
q = l.Find("/*");
w = q + 2;
}
}
const Index<String>& CppKeywordsIndex()
{
static Index<String> id;
ONCELOCK {
const char **cppk = CppKeyword();
for(int i = 0; cppk[i]; i++)
id.Add(cppk[i]);
}
return id;
}