本文整理汇总了C++中SkString::appendS32方法的典型用法代码示例。如果您正苦于以下问题:C++ SkString::appendS32方法的具体用法?C++ SkString::appendS32怎么用?C++ SkString::appendS32使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkString
的用法示例。
在下文中一共展示了SkString::appendS32方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onEndElement
bool SkDisplayXMLParser::onEndElement(const char elem[])
{
int parentIndex = fParents.count() - 1;
if (parentIndex >= 0) {
Parent& container = fParents[parentIndex];
SkDisplayable* displayable = container.fDisplayable;
fMaker.fEndDepth = parentIndex;
displayable->onEndElement(fMaker);
if (fMaker.fError.hasError())
return true;
if (parentIndex > 0) {
SkDisplayable* parent = fParents[parentIndex - 1].fDisplayable;
bool result = parent->add(fMaker, displayable);
if (fMaker.hasError())
return true;
if (result == false) {
int infoCount;
const SkMemberInfo* info =
SkDisplayType::GetMembers(&fMaker, fParents[parentIndex - 1].fType, &infoCount);
const SkMemberInfo* foundInfo;
if ((foundInfo = searchContainer(info, infoCount)) != NULL) {
parent->setReference(foundInfo, displayable);
// if (displayable->isHelper() == false)
fMaker.helperAdd(displayable);
} else {
fMaker.setErrorCode(SkDisplayXMLParserError::kElementTypeNotAllowedInParent);
return true;
}
}
if (parent->childrenNeedDisposing())
delete displayable;
}
fParents.remove(parentIndex);
}
fCurrDisplayable = NULL;
if (fInInclude == false && strcasecmp(elem, "screenplay") == 0) {
if (fMaker.fInMovie == false) {
fMaker.fEnableTime = fMaker.getAppTime();
#if defined SK_DEBUG && defined SK_DEBUG_ANIMATION_TIMING
if (fMaker.fDebugTimeBase == (SkMSec) -1)
fMaker.fDebugTimeBase = fMaker.fEnableTime;
SkString debugOut;
SkMSec time = fMaker.getAppTime();
debugOut.appendS32(time - fMaker.fDebugTimeBase);
debugOut.append(" onLoad enable=");
debugOut.appendS32(fMaker.fEnableTime - fMaker.fDebugTimeBase);
SkDebugf("%s\n", debugOut.c_str());
#endif
fMaker.fEvents.doEvent(fMaker, SkDisplayEvent::kOnload, NULL);
if (fMaker.fError.hasError())
return true;
fMaker.fEvents.removeEvent(SkDisplayEvent::kOnload, NULL);
}
fInSkia = false;
}
return false;
}
示例2: IRectToString
SkString* SkObjectParser::IRectToString(const SkIRect& rect) {
SkString* mRect = new SkString("SkIRect: ");
mRect->append("L: ");
mRect->appendS32(rect.left());
mRect->append(", T: ");
mRect->appendS32(rect.top());
mRect->append(", R: ");
mRect->appendS32(rect.right());
mRect->append(", B: ");
mRect->appendS32(rect.bottom());
return mRect;
}
示例3: draw_label
static void draw_label(SkCanvas* canvas, const SkRect& rect,
int start, int sweep) {
SkPaint paint;
paint.setAntiAlias(true);
paint.setTextAlign(SkPaint::kCenter_Align);
SkString str;
str.appendS32(start);
str.append(", ");
str.appendS32(sweep);
canvas->drawText(str.c_str(), str.size(), rect.centerX(),
rect.fBottom + paint.getTextSize() * 5/4, paint);
}
示例4: doDraw
static void doDraw(SkCanvas* canvas, SkPaint* paint, const int isrc[],
const int idst[], int count) {
SkMatrix matrix;
SkPoint src[4], dst[4];
for (int i = 0; i < count; i++) {
src[i].set(SkIntToScalar(isrc[2*i+0]), SkIntToScalar(isrc[2*i+1]));
dst[i].set(SkIntToScalar(idst[2*i+0]), SkIntToScalar(idst[2*i+1]));
}
canvas->save();
matrix.setPolyToPoly(src, dst, count);
canvas->concat(matrix);
paint->setColor(SK_ColorGRAY);
paint->setStyle(SkPaint::kStroke_Style);
const SkScalar D = SkIntToScalar(64);
canvas->drawRectCoords(0, 0, D, D, *paint);
canvas->drawLine(0, 0, D, D, *paint);
canvas->drawLine(0, D, D, 0, *paint);
SkPaint::FontMetrics fm;
paint->getFontMetrics(&fm);
paint->setColor(SK_ColorRED);
paint->setStyle(SkPaint::kFill_Style);
SkScalar x = D/2;
float y = D/2 - (fm.fAscent + fm.fDescent)/2;
SkString str;
str.appendS32(count);
canvas->drawText(str.c_str(), str.size(),
x, y,
*paint);
canvas->restore();
}
示例5: emitCode
void GrGLConvolutionEffect::emitCode(EmitArgs& args) {
const GrConvolutionEffect& ce = args.fFp.cast<GrConvolutionEffect>();
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
fImageIncrementUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
kVec2f_GrSLType, kDefault_GrSLPrecision,
"ImageIncrement");
if (ce.useBounds()) {
fBoundsUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
kVec2f_GrSLType, kDefault_GrSLPrecision,
"Bounds");
}
int width = Gr1DKernelEffect::WidthFromRadius(ce.radius());
fKernelUni = uniformHandler->addUniformArray(GrGLSLUniformHandler::kFragment_Visibility,
kFloat_GrSLType, kDefault_GrSLPrecision,
"Kernel", width);
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
SkString coords2D = fragBuilder->ensureFSCoords2D(args.fCoords, 0);
fragBuilder->codeAppendf("%s = vec4(0, 0, 0, 0);", args.fOutputColor);
const GrGLSLShaderVar& kernel = uniformHandler->getUniformVariable(fKernelUni);
const char* imgInc = uniformHandler->getUniformCStr(fImageIncrementUni);
fragBuilder->codeAppendf("vec2 coord = %s - %d.0 * %s;", coords2D.c_str(), ce.radius(), imgInc);
// Manually unroll loop because some drivers don't; yields 20-30% speedup.
for (int i = 0; i < width; i++) {
SkString index;
SkString kernelIndex;
index.appendS32(i);
kernel.appendArrayAccess(index.c_str(), &kernelIndex);
if (ce.useBounds()) {
// We used to compute a bool indicating whether we're in bounds or not, cast it to a
// float, and then mul weight*texture_sample by the float. However, the Adreno 430 seems
// to have a bug that caused corruption.
const char* bounds = uniformHandler->getUniformCStr(fBoundsUni);
const char* component = ce.direction() == Gr1DKernelEffect::kY_Direction ? "y" : "x";
fragBuilder->codeAppendf("if (coord.%s >= %s.x && coord.%s <= %s.y) {",
component, bounds, component, bounds);
}
fragBuilder->codeAppendf("\t\t%s += ", args.fOutputColor);
fragBuilder->appendTextureLookup(args.fSamplers[0], "coord");
fragBuilder->codeAppendf(" * %s;\n", kernelIndex.c_str());
if (ce.useBounds()) {
fragBuilder->codeAppend("}");
}
fragBuilder->codeAppendf("\t\tcoord += %s;\n", imgInc);
}
SkString modulate;
GrGLSLMulVarBy4f(&modulate, args.fOutputColor, args.fInputColor);
fragBuilder->codeAppend(modulate.c_str());
}
示例6: onDrawContent
virtual void onDrawContent(SkCanvas* canvas)
{
canvas->translate(SkIntToScalar(10), SkIntToScalar(50));
const SkScalar W = SkIntToScalar(fBitmaps[0].width() + 1);
const SkScalar H = SkIntToScalar(fBitmaps[0].height() + 1);
SkPaint paint;
const SkScalar scale = SkFloatToScalar(0.897917f);
canvas->scale(SK_Scalar1, scale);
for (int k = 0; k < 2; k++)
{
paint.setFilterBitmap(k == 1);
for (int j = 0; j < 2; j++)
{
paint.setDither(j == 1);
for (int i = 0; i < fBitmapCount; i++)
{
SkScalar x = (k * fBitmapCount + j) * W;
SkScalar y = i * H;
x = SkIntToScalar(SkScalarRound(x));
y = SkIntToScalar(SkScalarRound(y));
canvas->drawBitmap(fBitmaps[i], x, y, &paint);
if (i == 0)
{
SkPaint p;
p.setAntiAlias(true);
p.setTextAlign(SkPaint::kCenter_Align);
p.setTextSize(SkIntToScalar(18));
SkString s("dither=");
s.appendS32(paint.isDither());
s.append(" filter=");
s.appendS32(paint.isFilterBitmap());
canvas->drawText(s.c_str(), s.size(), x + W/2,
y - p.getTextSize(), p);
}
if (k+j == 2)
{
SkPaint p;
p.setAntiAlias(true);
p.setTextSize(SkIntToScalar(18));
SkString s;
s.append(" depth=");
s.appendS32(fBitmaps[i].config() == SkBitmap::kRGB_565_Config ? 16 : 32);
canvas->drawText(s.c_str(), s.size(), x + W + SkIntToScalar(4),
y + H/2, p);
}
}
}
}
}
示例7: ImageToString
SkString* SkObjectParser::ImageToString(const SkImage* image) {
SkString* str = new SkString("SkImage: ");
if (!image) {
return str;
}
str->append("W: ");
str->appendS32(image->width());
str->append(" H: ");
str->appendS32(image->height());
if (image->isOpaque()) {
str->append(" opaque");
} else {
str->append(" not-opaque");
}
str->append(" uniqueID: ");
str->appendS32(image->uniqueID());
return str;
}
示例8: BitmapToString
SkString* SkObjectParser::BitmapToString(const SkBitmap& bitmap) {
SkString* mBitmap = new SkString("SkBitmap: ");
mBitmap->append("W: ");
mBitmap->appendS32(bitmap.width());
mBitmap->append(" H: ");
mBitmap->appendS32(bitmap.height());
const char* gColorTypeStrings[] = {
"None", "A8", "565", "4444", "RGBA", "BGRA", "Index8", "G8", "RGBAf16"
};
static_assert(kLastEnum_SkColorType + 1 == SK_ARRAY_COUNT(gColorTypeStrings),
"colortype names do not match colortype enum");
mBitmap->append(" ColorType: ");
mBitmap->append(gColorTypeStrings[bitmap.colorType()]);
if (bitmap.isOpaque()) {
mBitmap->append(" opaque");
} else {
mBitmap->append(" not-opaque");
}
if (bitmap.isImmutable()) {
mBitmap->append(" immutable");
} else {
mBitmap->append(" not-immutable");
}
if (bitmap.isVolatile()) {
mBitmap->append(" volatile");
} else {
mBitmap->append(" not-volatile");
}
mBitmap->append(" genID: ");
mBitmap->appendS32(bitmap.getGenerationID());
return mBitmap;
}
示例9: emitCode
void GrGLConvolutionEffect::emitCode(GrGLFPBuilder* builder,
const GrFragmentProcessor&,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray& coords,
const TextureSamplerArray& samplers) {
fImageIncrementUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
kVec2f_GrSLType, kDefault_GrSLPrecision,
"ImageIncrement");
if (this->useBounds()) {
fBoundsUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
kVec2f_GrSLType, kDefault_GrSLPrecision,
"Bounds");
}
fKernelUni = builder->addUniformArray(GrGLProgramBuilder::kFragment_Visibility,
kFloat_GrSLType, kDefault_GrSLPrecision,
"Kernel", this->width());
GrGLFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
SkString coords2D = fsBuilder->ensureFSCoords2D(coords, 0);
fsBuilder->codeAppendf("\t\t%s = vec4(0, 0, 0, 0);\n", outputColor);
int width = this->width();
const GrGLShaderVar& kernel = builder->getUniformVariable(fKernelUni);
const char* imgInc = builder->getUniformCStr(fImageIncrementUni);
fsBuilder->codeAppendf("\t\tvec2 coord = %s - %d.0 * %s;\n", coords2D.c_str(), fRadius, imgInc);
// Manually unroll loop because some drivers don't; yields 20-30% speedup.
for (int i = 0; i < width; i++) {
SkString index;
SkString kernelIndex;
index.appendS32(i);
kernel.appendArrayAccess(index.c_str(), &kernelIndex);
fsBuilder->codeAppendf("\t\t%s += ", outputColor);
fsBuilder->appendTextureLookup(samplers[0], "coord");
if (this->useBounds()) {
const char* bounds = builder->getUniformCStr(fBoundsUni);
const char* component = this->direction() == Gr1DKernelEffect::kY_Direction ? "y" : "x";
fsBuilder->codeAppendf(" * float(coord.%s >= %s.x && coord.%s <= %s.y)",
component, bounds, component, bounds);
}
fsBuilder->codeAppendf(" * %s;\n", kernelIndex.c_str());
fsBuilder->codeAppendf("\t\tcoord += %s;\n", imgInc);
}
SkString modulate;
GrGLSLMulVarBy4f(&modulate, outputColor, inputColor);
fsBuilder->codeAppend(modulate.c_str());
}
示例10: BitmapToString
SkString* SkObjectParser::BitmapToString(const SkBitmap& bitmap) {
SkString* mBitmap = new SkString("SkBitmap: ");
mBitmap->append("W: ");
mBitmap->appendS32(bitmap.width());
mBitmap->append(" H: ");
mBitmap->appendS32(bitmap.height());
const char* gConfigStrings[] = {
"None", "A8", "Index8", "RGB565", "ARGB4444", "ARGB8888"
};
SkASSERT(SkBitmap::kConfigCount == SK_ARRAY_COUNT(gConfigStrings));
mBitmap->append(" Config: ");
mBitmap->append(gConfigStrings[bitmap.config()]);
if (bitmap.isOpaque()) {
mBitmap->append(" opaque");
} else {
mBitmap->append(" not-opaque");
}
if (bitmap.isImmutable()) {
mBitmap->append(" immutable");
} else {
mBitmap->append(" not-immutable");
}
if (bitmap.isVolatile()) {
mBitmap->append(" volatile");
} else {
mBitmap->append(" not-volatile");
}
mBitmap->append(" genID: ");
mBitmap->appendS32(bitmap.getGenerationID());
return mBitmap;
}
示例11: GetJMethod
JNIEXPORT void JNICALL Java_com_skia_SkiaSampleRenderer_init(JNIEnv* env,
jobject thiz, jobject jsampleActivity, jint msaaSampleCount)
{
// setup jni hooks to the java activity
gActivityGlue.m_env = env;
jclass clazz = env->FindClass("com/skia/SkiaSampleActivity");
gActivityGlue.m_obj = env->NewWeakGlobalRef(jsampleActivity);
gActivityGlue.m_setTitle = GetJMethod(env, clazz, "setTitle", "(Ljava/lang/CharSequence;)V");
gActivityGlue.m_setSlideList = GetJMethod(env, clazz, "setSlideList", "([Ljava/lang/String;)V");
gActivityGlue.m_addToDownloads = GetJMethod(env, clazz, "addToDownloads",
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
env->DeleteLocalRef(clazz);
// setup jni hooks to the java renderer
clazz = env->FindClass("com/skia/SkiaSampleRenderer");
gWindowGlue.m_obj = env->NewWeakGlobalRef(thiz);
gWindowGlue.m_inval = GetJMethod(env, clazz, "requestRender", "()V");
gWindowGlue.m_queueSkEvent = GetJMethod(env, clazz, "queueSkEvent", "()V");
gWindowGlue.m_startTimer = GetJMethod(env, clazz, "startTimer", "(I)V");
gWindowGlue.m_getMSAASampleCount = GetJMethod(env, clazz, "getMSAASampleCount", "()I");
env->DeleteLocalRef(clazz);
application_init();
SkTArray<const char*> args;
args.push_back("SampleApp");
// TODO: push ability to select skp dir into the UI
args.push_back("--pictureDir");
args.push_back("/sdcard/skiabot/skia_skp");
SkString msaaSampleCountString;
if (msaaSampleCount > 0) {
args.push_back("--msaa");
msaaSampleCountString.appendS32(static_cast<uint32_t>(msaaSampleCount));
args.push_back(msaaSampleCountString.c_str());
}
gWindow = new SampleWindow(NULL, args.count(), const_cast<char**>(args.begin()), NULL);
// send the list of slides up to the activity
const int slideCount = gWindow->sampleCount();
jobjectArray slideList = env->NewObjectArray(slideCount, env->FindClass("java/lang/String"), env->NewStringUTF(""));
for (int i = 0; i < slideCount; i++) {
jstring slideTitle = env->NewStringUTF(gWindow->getSampleTitle(i).c_str());
env->SetObjectArrayElement(slideList, i, slideTitle);
env->DeleteLocalRef(slideTitle);
}
env->CallVoidMethod(gActivityGlue.m_obj, gActivityGlue.m_setSlideList, slideList);
env->DeleteLocalRef(slideList);
}
示例12: setEnableTime
void SkAnimateMaker::setEnableTime(SkMSec appTime, SkMSec expectedTime) {
#if defined SK_DEBUG && defined SK_DEBUG_ANIMATION_TIMING
SkString debugOut;
SkMSec time = getAppTime();
debugOut.appendS32(time - fDebugTimeBase);
debugOut.append(" set enable old enable=");
debugOut.appendS32(fEnableTime - fDebugTimeBase);
debugOut.append(" old adjust=");
debugOut.appendS32(fAdjustedStart);
debugOut.append(" new enable=");
debugOut.appendS32(expectedTime - fDebugTimeBase);
debugOut.append(" new adjust=");
debugOut.appendS32(appTime - expectedTime);
SkDebugf("%s\n", debugOut.c_str());
#endif
fAdjustedStart = appTime - expectedTime;
fEnableTime = expectedTime;
SkDisplayable** firstMovie = fMovies.begin();
SkDisplayable** endMovie = fMovies.end();
for (SkDisplayable** ptr = firstMovie; ptr < endMovie; ptr++) {
SkDisplayMovie* movie = (SkDisplayMovie*) *ptr;
movie->fMovie.fMaker->setEnableTime(appTime, expectedTime);
}
}
示例13: start
void SkActive::start() {
int count = fState.count();
SkASSERT(count == fAnimators.count());
SkASSERT(count == fInterpolators.count());
for (int index = 0; index < count; index++) {
SkState& state = fState[index];
if (state.fStarted)
continue;
state.fStarted = true;
#if defined SK_DEBUG && defined SK_DEBUG_ANIMATION_TIMING
SkString debugOut;
SkMSec time = fMaker.getAppTime();
debugOut.appendS32(time - fMaker.fDebugTimeBase);
debugOut.append(" active start adjust delay id=");
debugOut.append(fApply._id);
debugOut.append("; ");
debugOut.append(fAnimators[index]->_id);
debugOut.append("=");
debugOut.appendS32(fAnimators[index]->fStart - fMaker.fDebugTimeBase);
debugOut.append(":");
debugOut.appendS32(state.fStartTime);
#endif
if (state.fStartTime > 0) {
SkMSec future = fAnimators[index]->fStart + state.fStartTime;
if (future > fMaker.fEnableTime)
fMaker.notifyInvalTime(future);
else
fMaker.notifyInval();
#if defined SK_DEBUG && defined SK_DEBUG_ANIMATION_TIMING
debugOut.append(":");
debugOut.appendS32(future - fMaker.fDebugTimeBase);
#endif
}
if (state.fStartTime >= fMaker.fAdjustedStart) {
state.fStartTime -= fMaker.fAdjustedStart;
#if defined SK_DEBUG && defined SK_DEBUG_ANIMATION_TIMING
debugOut.append(" (less adjust = ");
debugOut.appendS32(fMaker.fAdjustedStart);
#endif
}
state.fStartTime += fAnimators[index]->fStart;
#if defined SK_DEBUG && defined SK_DEBUG_ANIMATION_TIMING
debugOut.append(") new start = ");
debugOut.appendS32(state.fStartTime - fMaker.fDebugTimeBase);
SkDebugf("%s\n", debugOut.c_str());
// SkASSERT((int) (state.fStartTime - fMaker.fDebugTimeBase) >= 0);
#endif
}
SkASSERT(fAnimators.count() == fInterpolators.count());
}
示例14: onDrawContent
void onDrawContent(SkCanvas* canvas) override {
SkASSERT(fParent);
int numChoices = fMax - fMin + 1;
fSlider.offsetTo(fSliderRange * ( (*fOutput)/SkIntToScalar(numChoices)
+ 1.0f/(2.0f * numChoices) ),
fSlider.fTop);
SkString valueStr;
valueStr.appendS32(*fOutput);
this->drawLabel(canvas, valueStr);
SkPaint sliderPaint;
sliderPaint.setColor(0xFFF3F3F3);
canvas->drawRect(fSlider, sliderPaint);
SkPaint ctrlRegionPaint;
ctrlRegionPaint.setColor(0xFFFFFFFF);
ctrlRegionPaint.setStyle(SkPaint::kStroke_Style);
ctrlRegionPaint.setStrokeWidth(2.0f);
canvas->drawRect(fCtrlRegion, ctrlRegionPaint);
}
示例15: onEvent
bool SkAnimator::onEvent(const SkEvent& evt) {
#ifdef SK_DEBUG
SkAnimator* root = fMaker->getRoot();
if (root == NULL)
root = this;
if (root->isTrackingEvents())
root->eventDone(evt);
#endif
if (evt.isType(SK_EventType_OnEnd)) {
SkEventState eventState;
bool success = evt.findPtr("anim", (void**) &eventState.fDisplayable);
SkASSERT(success);
success = evt.findS32("time", (int32_t*) &fMaker->fEnableTime);
SkASSERT(success);
fMaker->fAdjustedStart = fMaker->getAppTime() - fMaker->fEnableTime;
fMaker->fEvents.doEvent(*fMaker, SkDisplayEvent::kOnEnd, &eventState);
fMaker->fAdjustedStart = 0;
goto inval;
}
if (evt.isType(SK_EventType_Delay)) {
fMaker->doDelayedEvent();
goto inval;
}
{
const char* id = evt.findString("id");
if (id == NULL)
return false;
SkDisplayable** firstMovie = fMaker->fMovies.begin();
SkDisplayable** endMovie = fMaker->fMovies.end();
for (SkDisplayable** ptr = firstMovie; ptr < endMovie; ptr++) {
SkDisplayMovie* movie = (SkDisplayMovie*) *ptr;
movie->doEvent(evt);
}
{
SkDisplayable* event;
if (fMaker->find(id, &event) == false)
return false;
#if defined SK_DEBUG && defined SK_DEBUG_ANIMATION_TIMING
SkString debugOut;
SkMSec realTime = fMaker->getAppTime();
debugOut.appendS32(realTime - fMaker->fDebugTimeBase);
debugOut.append(" onEvent id=");
debugOut.append(id);
#endif
SkMSec time = evt.getFast32();
if (time != 0) {
SkMSec app = fMaker->getAppTime();
fMaker->setEnableTime(app, time);
#if defined SK_DEBUG && defined SK_DEBUG_ANIMATION_TIMING
debugOut.append(" time=");
debugOut.appendS32(time - fMaker->fDebugTimeBase);
debugOut.append(" adjust=");
debugOut.appendS32(fMaker->fAdjustedStart);
#endif
}
#if defined SK_DEBUG && defined SK_DEBUG_ANIMATION_TIMING
SkDebugf("%s\n", debugOut.c_str());
#endif
SkASSERT(event->isEvent());
SkDisplayEvent* displayEvent = (SkDisplayEvent*) event;
displayEvent->populateInput(*fMaker, evt);
displayEvent->enableEvent(*fMaker);
}
}
inval:
fMaker->notifyInval();
return true;
}