Refactoring Rendering context
This commit is contained in:
parent
f8e6288b63
commit
b79e23b468
6 changed files with 197 additions and 118 deletions
|
@ -30,9 +30,6 @@ IconDrawInfo::IconDrawInfo()
|
|||
{
|
||||
}
|
||||
|
||||
RenderingContext::RenderingContext()
|
||||
{
|
||||
}
|
||||
|
||||
RenderingContext::~RenderingContext()
|
||||
{
|
||||
|
@ -48,14 +45,6 @@ bool RenderingContext::interrupted()
|
|||
|
||||
|
||||
|
||||
float getDensityValue(RenderingContext* rc, float val)
|
||||
{
|
||||
if (rc->highResMode && rc->density > 1)
|
||||
return val * rc->density * rc->mapTextSize;
|
||||
else
|
||||
return val * rc->mapTextSize;
|
||||
}
|
||||
|
||||
ElapsedTimer::ElapsedTimer()
|
||||
: elapsedTime(0)
|
||||
, enableFlag(true)
|
||||
|
@ -168,9 +157,6 @@ double checkLatitude(double latitude) {
|
|||
return latitude;
|
||||
}
|
||||
|
||||
inline double toRadians(double angdeg) {
|
||||
return angdeg / 180 * M_PI;
|
||||
}
|
||||
|
||||
int get31TileNumberX(double longitude){
|
||||
longitude = checkLongitude(longitude);
|
||||
|
|
|
@ -91,6 +91,9 @@ using namespace std;
|
|||
|
||||
struct RenderingContext;
|
||||
|
||||
inline double toRadians(double angdeg) {
|
||||
return angdeg / 180 * M_PI;
|
||||
}
|
||||
|
||||
class ElapsedTimer
|
||||
{
|
||||
|
@ -150,18 +153,9 @@ struct IconDrawInfo
|
|||
|
||||
struct RenderingContext
|
||||
{
|
||||
RenderingContext();
|
||||
virtual ~RenderingContext();
|
||||
|
||||
virtual bool interrupted();
|
||||
virtual SkBitmap* getCachedBitmap(const std::string& bitmapResource);
|
||||
virtual std::string getTranslatedString(const std::string& src);
|
||||
private :
|
||||
// parameters
|
||||
bool useEnglishNames;
|
||||
|
||||
std::vector<TextDrawInfo*> textToDraw;
|
||||
std::vector<IconDrawInfo> iconsToDraw;
|
||||
bool highResMode;
|
||||
float mapTextSize;
|
||||
float density;
|
||||
|
||||
float leftX;
|
||||
|
@ -171,8 +165,13 @@ struct RenderingContext
|
|||
|
||||
int zoom;
|
||||
float rotate;
|
||||
float tileDivisor;
|
||||
// int shadowRenderingMode = 0; // no shadow (minumum CPU)
|
||||
// int shadowRenderingMode = 1; // classic shadow (the implementaton in master)
|
||||
// int shadowRenderingMode = 2; // blur shadow (most CPU, but still reasonable)
|
||||
// int shadowRenderingMode = 3; solid border (CPU use like classic version or even smaller)
|
||||
int shadowRenderingMode;
|
||||
|
||||
public:
|
||||
// debug purpose
|
||||
int pointCount;
|
||||
int pointInsideCount;
|
||||
|
@ -182,22 +181,102 @@ struct RenderingContext
|
|||
class ElapsedTimer textRendering;
|
||||
class ElapsedTimer nativeOperations;
|
||||
|
||||
// use to calculate points
|
||||
float calcX;
|
||||
float calcY;
|
||||
// because they used in 3rd party functions
|
||||
public :
|
||||
static const int TILE_SIZE = 256;
|
||||
|
||||
|
||||
// calculated
|
||||
float tileDivisor;
|
||||
float cosRotateTileSize;
|
||||
float sinRotateTileSize;
|
||||
|
||||
int shadowRenderingMode;
|
||||
std::vector<TextDrawInfo*> textToDraw;
|
||||
std::vector<IconDrawInfo> iconsToDraw;
|
||||
// use to calculate points
|
||||
float calcX;
|
||||
float calcY;
|
||||
|
||||
// not expect any shadow
|
||||
int shadowLevelMin;
|
||||
int shadowLevelMax;
|
||||
|
||||
};
|
||||
public:
|
||||
RenderingContext() : shadowLevelMax(0), shadowLevelMin(256), density(true), useEnglishNames(false){
|
||||
setRotate(0);
|
||||
setZoom(15);
|
||||
}
|
||||
virtual ~RenderingContext();
|
||||
|
||||
float getDensityValue(RenderingContext* rc, float val);
|
||||
virtual bool interrupted();
|
||||
virtual SkBitmap* getCachedBitmap(const std::string& bitmapResource);
|
||||
virtual std::string getTranslatedString(const std::string& src);
|
||||
|
||||
void setZoom(int z) {
|
||||
this->zoom = z;
|
||||
this->tileDivisor = (1 << (31 - z));
|
||||
}
|
||||
void setRotate(float rot) {
|
||||
this->rotate = rot;
|
||||
this->cosRotateTileSize = cos(toRadians(rot)) * TILE_SIZE;
|
||||
this->sinRotateTileSize = sin(toRadians(rot)) * TILE_SIZE;
|
||||
}
|
||||
|
||||
void setLocation(double leftX, double topY) {
|
||||
this->leftX = leftX;
|
||||
this->topY = topY;
|
||||
}
|
||||
|
||||
void setDimension(int width, int height) {
|
||||
this->width = width;
|
||||
this->height = height;
|
||||
}
|
||||
|
||||
inline int getShadowRenderingMode(){
|
||||
return shadowRenderingMode;
|
||||
}
|
||||
|
||||
inline int getWidth(){
|
||||
return width;
|
||||
}
|
||||
|
||||
inline int getHeight(){
|
||||
return height;
|
||||
}
|
||||
|
||||
inline int getZoom() {
|
||||
return zoom;
|
||||
}
|
||||
|
||||
inline float getLeft() {
|
||||
return leftX;
|
||||
}
|
||||
|
||||
inline float getTop() {
|
||||
return topY;
|
||||
}
|
||||
|
||||
void setShadowRenderingMode(int mode){
|
||||
this->shadowRenderingMode = mode;
|
||||
}
|
||||
|
||||
void setDensityScale(float val) {
|
||||
density = val;
|
||||
}
|
||||
|
||||
float getDensityValue(float val) {
|
||||
return val * density;
|
||||
}
|
||||
|
||||
void setUseEnglishNames(bool b){
|
||||
this->useEnglishNames = b;
|
||||
}
|
||||
|
||||
bool isUsingEnglishNames(){
|
||||
return this->useEnglishNames;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
SkBitmap* getCachedBitmap(RenderingContext* rc, const std::string& bitmapResource);
|
||||
|
||||
|
|
|
@ -32,8 +32,6 @@ extern "C" JNIEXPORT void JNICALL Java_net_osmand_plus_render_NativeOsmandLibrar
|
|||
jobject obj, jint searchResult) {
|
||||
ResultPublisher* result = (ResultPublisher*) searchResult;
|
||||
if(result != NULL){
|
||||
// destructor will delete result
|
||||
// deleteObjects(result->result);
|
||||
delete result;
|
||||
}
|
||||
}
|
||||
|
@ -177,7 +175,7 @@ extern "C" JNIEXPORT jobject JNICALL Java_net_osmand_plus_render_NativeOsmandLib
|
|||
RenderingRuleSearchRequest* req = initSearchRequest(ienv, renderingRuleSearchRequest);
|
||||
JNIRenderingContext rc;
|
||||
pullFromJavaRenderingContext(ienv, renderingContext, &rc);
|
||||
rc.useEnglishNames = useEnglishNames;
|
||||
rc.setUseEnglishNames(useEnglishNames);
|
||||
ResultPublisher* result = ((ResultPublisher*) searchResult);
|
||||
// std::vector <BaseMapDataObject* > mapDataObjects = marshalObjects(binaryMapDataObjects);
|
||||
|
||||
|
@ -263,7 +261,7 @@ extern "C" JNIEXPORT jobject JNICALL Java_net_osmand_plus_render_NativeOsmandLib
|
|||
RenderingRuleSearchRequest* req = initSearchRequest(ienv, renderingRuleSearchRequest);
|
||||
JNIRenderingContext rc;
|
||||
pullFromJavaRenderingContext(ienv, renderingContext, &rc);
|
||||
rc.useEnglishNames = useEnglishNames;
|
||||
rc.setUseEnglishNames(useEnglishNames);
|
||||
ResultPublisher* result = ((ResultPublisher*) searchResult);
|
||||
// std::vector <BaseMapDataObject* > mapDataObjects = marshalObjects(binaryMapDataObjects);
|
||||
|
||||
|
@ -329,8 +327,6 @@ jfieldID jfield_RenderingContext_density = NULL;
|
|||
jfieldID jfield_RenderingContext_highResMode = NULL;
|
||||
jfieldID jfield_RenderingContext_mapTextSize = NULL;
|
||||
jfieldID jfield_RenderingContext_shadowRenderingMode = NULL;
|
||||
jfieldID jfield_RenderingContext_shadowLevelMin = NULL;
|
||||
jfieldID jfield_RenderingContext_shadowLevelMax = NULL;
|
||||
jfieldID jfield_RenderingContext_ctx = NULL;
|
||||
jfieldID jfield_RenderingContext_textRenderingTime = NULL;
|
||||
jfieldID jfield_RenderingContext_lastRenderedKey = NULL;
|
||||
|
@ -356,8 +352,6 @@ void loadJniRenderingContext(JNIEnv* env)
|
|||
jfield_RenderingContext_highResMode = getFid(env, jclass_RenderingContext, "highResMode", "Z" );
|
||||
jfield_RenderingContext_mapTextSize = getFid(env, jclass_RenderingContext, "mapTextSize", "F" );
|
||||
jfield_RenderingContext_shadowRenderingMode = getFid(env, jclass_RenderingContext, "shadowRenderingMode", "I" );
|
||||
jfield_RenderingContext_shadowLevelMin = getFid(env, jclass_RenderingContext, "shadowLevelMin", "I" );
|
||||
jfield_RenderingContext_shadowLevelMax = getFid(env, jclass_RenderingContext, "shadowLevelMax", "I" );
|
||||
jfield_RenderingContext_ctx = getFid(env, jclass_RenderingContext, "ctx", "Landroid/content/Context;" );
|
||||
jfield_RenderingContext_textRenderingTime = getFid(env, jclass_RenderingContext, "textRenderingTime", "I" );
|
||||
jfield_RenderingContext_lastRenderedKey = getFid(env, jclass_RenderingContext, "lastRenderedKey", "I" );
|
||||
|
@ -374,32 +368,22 @@ void loadJniRenderingContext(JNIEnv* env)
|
|||
void pullFromJavaRenderingContext(JNIEnv* env, jobject jrc, JNIRenderingContext* rc)
|
||||
{
|
||||
rc->env = env;
|
||||
rc->leftX = env->GetFloatField( jrc, jfield_RenderingContext_leftX );
|
||||
rc->topY = env->GetFloatField( jrc, jfield_RenderingContext_topY );
|
||||
rc->width = env->GetIntField( jrc, jfield_RenderingContext_width );
|
||||
rc->height = env->GetIntField( jrc, jfield_RenderingContext_height );
|
||||
rc->setLocation(env->GetFloatField( jrc, jfield_RenderingContext_leftX ), env->GetFloatField( jrc, jfield_RenderingContext_topY ));
|
||||
rc->setDimension(env->GetIntField( jrc, jfield_RenderingContext_width ), env->GetIntField( jrc, jfield_RenderingContext_height ));
|
||||
|
||||
rc->zoom = env->GetIntField( jrc, jfield_RenderingContext_zoom );
|
||||
rc->rotate = env->GetFloatField( jrc, jfield_RenderingContext_rotate );
|
||||
rc->tileDivisor = env->GetFloatField( jrc, jfield_RenderingContext_tileDivisor );
|
||||
rc->setZoom(env->GetIntField( jrc, jfield_RenderingContext_zoom ));
|
||||
rc->setRotate(env->GetFloatField( jrc, jfield_RenderingContext_rotate ));
|
||||
|
||||
rc->pointCount = env->GetIntField( jrc, jfield_RenderingContext_pointCount );
|
||||
rc->pointInsideCount = env->GetIntField( jrc, jfield_RenderingContext_pointInsideCount );
|
||||
rc->visible = env->GetIntField( jrc, jfield_RenderingContext_visible );
|
||||
rc->allObjects = env->GetIntField( jrc, jfield_RenderingContext_allObjects );
|
||||
|
||||
rc->cosRotateTileSize = env->GetFloatField( jrc, jfield_RenderingContext_cosRotateTileSize );
|
||||
rc->sinRotateTileSize = env->GetFloatField( jrc, jfield_RenderingContext_sinRotateTileSize );
|
||||
rc->density = env->GetFloatField( jrc, jfield_RenderingContext_density );
|
||||
rc->highResMode = env->GetBooleanField( jrc, jfield_RenderingContext_highResMode );
|
||||
rc->mapTextSize = env->GetFloatField( jrc, jfield_RenderingContext_mapTextSize );
|
||||
|
||||
rc->shadowRenderingMode = env->GetIntField( jrc, jfield_RenderingContext_shadowRenderingMode );
|
||||
rc->shadowLevelMin = env->GetIntField( jrc, jfield_RenderingContext_shadowLevelMin );
|
||||
rc->shadowLevelMax = env->GetIntField( jrc, jfield_RenderingContext_shadowLevelMax );
|
||||
float density = env->GetFloatField( jrc, jfield_RenderingContext_density );
|
||||
bool highResMode = env->GetBooleanField( jrc, jfield_RenderingContext_highResMode );
|
||||
float mapTextSize = env->GetFloatField( jrc, jfield_RenderingContext_mapTextSize );
|
||||
if (highResMode && density > 1) {
|
||||
rc->setDensityScale(density * mapTextSize);
|
||||
} else {
|
||||
rc->setDensityScale(mapTextSize);
|
||||
}
|
||||
rc->setShadowRenderingMode(env->GetIntField( jrc, jfield_RenderingContext_shadowRenderingMode ));
|
||||
rc->androidContext = env->GetObjectField(jrc, jfield_RenderingContext_ctx );
|
||||
rc->lastRenderedKey = 0;
|
||||
|
||||
rc->javaRenderingContext = jrc;
|
||||
}
|
||||
|
||||
|
@ -457,7 +441,7 @@ SkBitmap* JNIRenderingContext::getCachedBitmap(const std::string& bitmapResource
|
|||
}
|
||||
|
||||
std::string JNIRenderingContext::getTranslatedString(const std::string& name) {
|
||||
if (this->useEnglishNames) {
|
||||
if (this->isUsingEnglishNames()) {
|
||||
jstring n = this->env->NewStringUTF(name.c_str());
|
||||
std::string res = getString(this->env,
|
||||
(jstring) this->env->CallStaticObjectMethod(jclass_JUnidecode, jmethod_JUnidecode_unidecode, n));
|
||||
|
|
|
@ -123,6 +123,43 @@ void printFileInformation(const char* fileName, VerboseInfo* verbose) {
|
|||
}
|
||||
}
|
||||
|
||||
SkColor defaultMapColor = SK_ColorLTGRAY;
|
||||
void runSimpleRendering(int zoom, int left, int right, int top, int bottom, int rowBytes) {
|
||||
// TODO
|
||||
initBinaryMapFile("");
|
||||
// TODO not implemented (read storage from file)
|
||||
RenderingRulesStorage* st = NULL; //createRenderingRulesStorage(env, storage);
|
||||
RenderingRuleSearchRequest* req = new RenderingRuleSearchRequest(st);
|
||||
// TODO init rule search request
|
||||
// initRenderingRuleSearchRequest(env, res, renderingRuleSearchRequest);
|
||||
|
||||
SearchQuery q(left, right, top, bottom, req, new ResultPublisher());
|
||||
q.zoom = zoom;
|
||||
ResultPublisher* res = searchObjectsForRendering(&q, req, true, "Nothing found");
|
||||
|
||||
SkBitmap* bitmap = new SkBitmap();
|
||||
bitmap->setConfig(SkBitmap::kRGB_565_Config, 800, 800, rowBytes);
|
||||
// size_t bitmapDataSize = bitmap->getSize();
|
||||
// void* bitmapData bitmapData = malloc(bitmapDataSize);
|
||||
// bitmap->setPixels(bitmapData);
|
||||
|
||||
osmand_log_print(LOG_INFO, "Initializing rendering");
|
||||
ElapsedTimer initObjects;
|
||||
initObjects.start();
|
||||
|
||||
RenderingContext rc;
|
||||
osmand_log_print(LOG_INFO, "Rendering image");
|
||||
initObjects.pause();
|
||||
SkCanvas* canvas = new SkCanvas(*bitmap);
|
||||
canvas->drawColor(defaultMapColor);
|
||||
doRendering(res->result, canvas, req, &rc);
|
||||
|
||||
osmand_log_print(LOG_INFO, "End Rendering image");
|
||||
osmand_log_print(LOG_INFO, "Native ok (init %d, rendering %d) ", initObjects.getElapsedTime(),
|
||||
rc.nativeOperations.getElapsedTime());
|
||||
return;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
if (argc <= 1) {
|
||||
printUsage("");
|
||||
|
|
|
@ -34,12 +34,12 @@ void calcPoint(std::pair<int, int> c, RenderingContext* rc)
|
|||
float tx = c.first/ (rc->tileDivisor);
|
||||
float ty = c.second / (rc->tileDivisor);
|
||||
|
||||
float dTileX = tx - rc->leftX;
|
||||
float dTileY = ty - rc->topY;
|
||||
float dTileX = tx - rc->getLeft();
|
||||
float dTileY = ty - rc->getTop();
|
||||
rc->calcX = rc->cosRotateTileSize * dTileX - rc->sinRotateTileSize * dTileY;
|
||||
rc->calcY = rc->sinRotateTileSize * dTileX + rc->cosRotateTileSize * dTileY;
|
||||
|
||||
if (rc->calcX >= 0 && rc->calcX < rc->width && rc->calcY >= 0 && rc->calcY < rc->height)
|
||||
if (rc->calcX >= 0 && rc->calcX < rc->getWidth()&& rc->calcY >= 0 && rc->calcY < rc->getHeight())
|
||||
rc->pointInsideCount++;
|
||||
}
|
||||
|
||||
|
@ -167,7 +167,7 @@ int updatePaint(RenderingRuleSearchRequest* req, SkPaint* paint, int ind, int ar
|
|||
}
|
||||
|
||||
// do not check shadow color here
|
||||
if (rc->shadowRenderingMode == 1 && ind == 0)
|
||||
if (rc->getShadowRenderingMode() == 1 && ind == 0)
|
||||
{
|
||||
int shadowColor = req->getIntPropertyValue(req->props()->R_SHADOW_COLOR);
|
||||
int shadowLayer = req->getIntPropertyValue(req->props()->R_SHADOW_RADIUS);
|
||||
|
@ -187,7 +187,7 @@ void renderText(MapDataObject* obj, RenderingRuleSearchRequest* req, RenderingCo
|
|||
if (it->second.length() > 0) {
|
||||
std::string name = it->second;
|
||||
name =rc->getTranslatedString(name);
|
||||
req->setInitialTagValueZoom(tag, value, rc->zoom, obj);
|
||||
req->setInitialTagValueZoom(tag, value, rc->getZoom(), obj);
|
||||
req->setIntFilter(req->props()->R_TEXT_LENGTH, name.length());
|
||||
std::string tagName = it->first == "name" ? "" : it->first;
|
||||
req->setStringFilter(req->props()->R_NAME_TAG, tagName);
|
||||
|
@ -211,7 +211,7 @@ void renderText(MapDataObject* obj, RenderingRuleSearchRequest* req, RenderingCo
|
|||
void drawPolylineShadow(SkCanvas* cv, SkPaint* paint, RenderingContext* rc, SkPath* path, int shadowColor, int shadowRadius)
|
||||
{
|
||||
// blurred shadows
|
||||
if (rc->shadowRenderingMode == 2 && shadowRadius > 0) {
|
||||
if (rc->getShadowRenderingMode() == 2 && shadowRadius > 0) {
|
||||
// simply draw shadow? difference from option 3 ?
|
||||
// paint->setColor(0xffffffff);
|
||||
paint->setLooper(new SkBlurDrawLooper(shadowRadius, 0, 0, shadowColor))->unref();
|
||||
|
@ -219,7 +219,7 @@ void drawPolylineShadow(SkCanvas* cv, SkPaint* paint, RenderingContext* rc, SkPa
|
|||
}
|
||||
|
||||
// option shadow = 3 with solid border
|
||||
if (rc->shadowRenderingMode == 3 && shadowRadius > 0) {
|
||||
if (rc->getShadowRenderingMode() == 3 && shadowRadius > 0) {
|
||||
paint->setLooper(NULL);
|
||||
paint->setStrokeWidth(paint->getStrokeWidth() + shadowRadius * 2);
|
||||
// paint->setColor(0xffbababa);
|
||||
|
@ -281,14 +281,14 @@ void drawPolyline(MapDataObject* mObj, RenderingRuleSearchRequest* req, SkCanvas
|
|||
std::string tag = pair.first;
|
||||
std::string value = pair.second;
|
||||
|
||||
req->setInitialTagValueZoom(tag, value, rc->zoom, mObj);
|
||||
req->setInitialTagValueZoom(tag, value, rc->getZoom(), mObj);
|
||||
req->setIntFilter(req->props()->R_LAYER, layer);
|
||||
bool rendered = req->searchRule(2);
|
||||
if (!rendered || !updatePaint(req, paint, 0, 0, rc)) {
|
||||
return;
|
||||
}
|
||||
int oneway = 0;
|
||||
if (rc->zoom >= 16 && pair.first == "highway") {
|
||||
if (rc->getZoom() >= 16 && pair.first == "highway") {
|
||||
if (mObj->containsAdditional("oneway", "yes")) {
|
||||
oneway = 1;
|
||||
} else if (mObj->containsAdditional("oneway", "-1")) {
|
||||
|
@ -345,7 +345,7 @@ void drawPolygon(MapDataObject* mObj, RenderingRuleSearchRequest* req, SkCanvas*
|
|||
std::string tag = pair.first;
|
||||
std::string value = pair.second;
|
||||
|
||||
req->setInitialTagValueZoom(tag, value, rc->zoom, mObj);
|
||||
req->setInitialTagValueZoom(tag, value, rc->getZoom(), mObj);
|
||||
bool rendered = req->searchRule(3);
|
||||
|
||||
float xText = 0;
|
||||
|
@ -397,7 +397,7 @@ void drawPoint(MapDataObject* mObj, RenderingRuleSearchRequest* req, SkCanvas* c
|
|||
std::string tag = pair.first;
|
||||
std::string value = pair.second;
|
||||
|
||||
req->setInitialTagValueZoom(tag, value, rc->zoom, mObj);
|
||||
req->setInitialTagValueZoom(tag, value, rc->getZoom(), mObj);
|
||||
req->searchRule(1);
|
||||
std::string resId = req->getStringPropertyValue(req-> props()-> R_ICON);
|
||||
SkBitmap* bmp = getCachedBitmap(rc, resId);
|
||||
|
@ -452,9 +452,9 @@ void drawObject(RenderingContext* rc, MapDataObject* mObj, SkCanvas* cv, Renderi
|
|||
|
||||
void drawIconsOverCanvas(RenderingContext* rc, SkCanvas* canvas)
|
||||
{
|
||||
int skewConstant = (int) getDensityValue(rc, 16);
|
||||
int iconsW = rc -> width / skewConstant;
|
||||
int iconsH = rc -> height / skewConstant;
|
||||
int skewConstant = (int) rc->getDensityValue(16);
|
||||
int iconsW = rc -> getWidth() / skewConstant;
|
||||
int iconsH = rc -> getHeight() / skewConstant;
|
||||
int len = (iconsW * iconsH) / 32;
|
||||
int alreadyDrawnIcons[len];
|
||||
memset(alreadyDrawnIcons, 0, sizeof(int)*len);
|
||||
|
@ -464,8 +464,7 @@ void drawIconsOverCanvas(RenderingContext* rc, SkCanvas* canvas)
|
|||
for(;ji< rc->iconsToDraw.size(); ji++)
|
||||
{
|
||||
IconDrawInfo icon = rc->iconsToDraw.at(ji);
|
||||
if (icon.y >= 0 && icon.y < rc -> height && icon.x >= 0 && icon.x < rc -> width &&
|
||||
icon.bmp != NULL) {
|
||||
if (icon.y >= 0 && icon.y < rc->getHeight() && icon.x >= 0 && icon.x < rc->getWidth() && icon.bmp != NULL) {
|
||||
int z = (((int) icon.x / skewConstant) + ((int) icon.y / skewConstant) * iconsW);
|
||||
int i = z / 32;
|
||||
if (i >= len) {
|
||||
|
@ -477,14 +476,11 @@ void drawIconsOverCanvas(RenderingContext* rc, SkCanvas* canvas)
|
|||
if (((ind >> b) & 1) == 0) {
|
||||
alreadyDrawnIcons[i] = ind | (1 << b);
|
||||
SkBitmap* ico = icon.bmp;
|
||||
if(rc->highResMode) {
|
||||
float left = icon.x - getDensityValue(rc, ico->width() / 2);
|
||||
float top = icon.y - getDensityValue(rc, ico->height() / 2);
|
||||
SkRect r = SkRect::MakeXYWH(left, top, getDensityValue(rc, ico->width()), getDensityValue(rc, ico->height()));
|
||||
float left = icon.x - rc->getDensityValue(ico->width() / 2);
|
||||
float top = icon.y - rc->getDensityValue(ico->height() / 2);
|
||||
SkRect r = SkRect::MakeXYWH(left, top, rc->getDensityValue(ico->width()),
|
||||
rc->getDensityValue(ico->height()));
|
||||
PROFILE_NATIVE_OPERATION(rc, canvas->drawBitmapRect(*ico, (SkIRect*) NULL, r, &p));
|
||||
} else {
|
||||
PROFILE_NATIVE_OPERATION(rc, canvas->drawBitmap(*ico, icon.x - ico->width() / 2, icon.y - ico->height() / 2, &p));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (rc->interrupted()) {
|
||||
|
@ -508,7 +504,7 @@ HMAP::hash_map<int, std::vector<int> > sortObjectsByProperOrder(std::vector <Map
|
|||
for (; j < sizeTypes; j++) {
|
||||
int layer = mobj->getSimpleLayer();
|
||||
tag_value pair = mobj->types[j];
|
||||
req->setTagValueZoomLayer(pair.first, pair.second, rc->zoom, layer, mobj);
|
||||
req->setTagValueZoomLayer(pair.first, pair.second, rc->getZoom(), layer, mobj);
|
||||
req->setIntFilter(req->props()->R_AREA, mobj->area);
|
||||
req->setIntFilter(req->props()->R_POINT, mobj->points.size() == 1);
|
||||
req->setIntFilter(req->props()->R_CYCLE, mobj->cycle());
|
||||
|
@ -548,7 +544,7 @@ void doRendering(std::vector <MapDataObject* > mapDataObjects, SkCanvas* canvas,
|
|||
bool shadowDrawn = false;
|
||||
|
||||
for (std::set<int>::iterator ks = keys.begin(); ks != keys.end(); ks++) {
|
||||
if (!shadowDrawn && *ks >= rc->shadowLevelMin && *ks <= rc->shadowLevelMax && rc->shadowRenderingMode > 1) {
|
||||
if (!shadowDrawn && *ks >= rc->shadowLevelMin && *ks <= rc->shadowLevelMax && rc->getShadowRenderingMode() > 1) {
|
||||
for (std::set<int>::iterator ki = ks; ki != keys.end(); ki++) {
|
||||
if (*ki > rc->shadowLevelMax || rc->interrupted()) {
|
||||
break;
|
||||
|
|
|
@ -227,8 +227,8 @@ bool calculatePathToRotate(RenderingContext* rc, TextDrawInfo* p) {
|
|||
|
||||
float normalTextLen = 1.5 * textw;
|
||||
for (i = 0; i < len; i++) {
|
||||
bool inside = points[i].fX >= 0 && points[i].fX <= rc->width &&
|
||||
points[i].fY >= 0 && points[i].fY <= rc->height;
|
||||
bool inside = points[i].fX >= 0 && points[i].fX <= rc->getWidth() &&
|
||||
points[i].fY >= 0 && points[i].fY <= rc->getHeight();
|
||||
if (i > 0) {
|
||||
float d = sqrt(
|
||||
(points[i].fX - points[i - 1].fX) * (points[i].fX - points[i - 1].fX)
|
||||
|
@ -411,7 +411,7 @@ bool findTextIntersection(SkCanvas* cv, RenderingContext* rc, quad_tree<TextDraw
|
|||
SkPaint* paintText, SkPaint* paintIcon) {
|
||||
paintText->measureText(text->text.c_str(), text->text.length(), &text->bounds);
|
||||
// make wider
|
||||
text->bounds.inset(-getDensityValue(rc, 3), -getDensityValue(rc, 10));
|
||||
text->bounds.inset(-rc->getDensityValue( 3), -rc->getDensityValue(10));
|
||||
|
||||
bool display = calculatePathToRotate(rc, text);
|
||||
if (!display) {
|
||||
|
@ -437,7 +437,7 @@ bool findTextIntersection(SkCanvas* cv, RenderingContext* rc, quad_tree<TextDraw
|
|||
}
|
||||
if(text->minDistance > 0) {
|
||||
SkRect boundsSearch = text->bounds;
|
||||
boundsSearch.inset(-getDensityValue(rc, max(5.0f, text->minDistance)), -getDensityValue(rc, 15));
|
||||
boundsSearch.inset(-rc->getDensityValue(max(5.0f, text->minDistance)), -rc->getDensityValue(15));
|
||||
boundIntersections.query_in_box(boundsSearch, searchText);
|
||||
// drawTestBox(cv, &boundsSearch, text->pathRotate, paintIcon, text->text, paintText);
|
||||
for (uint i = 0; i < searchText.size(); i++) {
|
||||
|
@ -460,7 +460,7 @@ bool textOrder(TextDrawInfo* text1, TextDrawInfo* text2) {
|
|||
|
||||
SkTypeface* serif = SkTypeface::CreateFromName("Droid Serif", SkTypeface::kNormal);
|
||||
void drawTextOverCanvas(RenderingContext* rc, SkCanvas* cv) {
|
||||
SkRect r = SkRect::MakeLTRB(0, 0, rc->width, rc->height);
|
||||
SkRect r = SkRect::MakeLTRB(0, 0, rc->getWidth(), rc->getHeight());
|
||||
r.inset(-100, -100);
|
||||
quad_tree<TextDrawInfo*> boundsIntersect(r, 4, 0.6);
|
||||
|
||||
|
@ -484,7 +484,7 @@ void drawTextOverCanvas(RenderingContext* rc, SkCanvas* cv) {
|
|||
TextDrawInfo* text = rc->textToDraw.at(i);
|
||||
if (text->text.length() > 0) {
|
||||
// sest text size before finding intersection (it is used there)
|
||||
float textSize = getDensityValue(rc, text->textSize);
|
||||
float textSize = rc->getDensityValue(text->textSize);
|
||||
paintText.setTextSize(textSize);
|
||||
paintText.setFakeBoldText(text->bold);
|
||||
paintText.setColor(text->textColor);
|
||||
|
@ -520,15 +520,12 @@ void drawTextOverCanvas(RenderingContext* rc, SkCanvas* cv) {
|
|||
if (text->shieldRes.length() > 0) {
|
||||
SkBitmap* ico = getCachedBitmap(rc, text->shieldRes);
|
||||
if (ico != NULL) {
|
||||
if(rc->highResMode) {
|
||||
float left = text->centerX - getDensityValue(rc, ico->width() / 2) - 0.5f;
|
||||
float top =text->centerY - getDensityValue(rc, ico->height() / 2) - getDensityValue(rc, 4.5f);
|
||||
SkRect r = SkRect::MakeXYWH(left, top, getDensityValue(rc, ico->width()), getDensityValue(rc, ico->height()));
|
||||
float left = text->centerX - rc->getDensityValue(ico->width() / 2) - 0.5f;
|
||||
float top = text->centerY - rc->getDensityValue(ico->height() / 2)
|
||||
- rc->getDensityValue(4.5f);
|
||||
SkRect r = SkRect::MakeXYWH(left, top, rc->getDensityValue(ico->width()),
|
||||
rc->getDensityValue(ico->height()));
|
||||
PROFILE_NATIVE_OPERATION(rc, cv->drawBitmapRect(*ico, (SkIRect*) NULL, r, &paintIcon));
|
||||
} else {
|
||||
PROFILE_NATIVE_OPERATION(rc, cv->drawBitmap(*ico, text->centerX - ico->width() / 2 - 0.5f,
|
||||
text->centerY - ico->height() / 2 - getDensityValue(rc, 4.5f), &paintIcon));
|
||||
}
|
||||
}
|
||||
}
|
||||
drawWrappedText(rc, cv, text, textSize, paintText);
|
||||
|
|
Loading…
Reference in a new issue