本文整理汇总了C++中SkPixmap::writable_addr方法的典型用法代码示例。如果您正苦于以下问题:C++ SkPixmap::writable_addr方法的具体用法?C++ SkPixmap::writable_addr怎么用?C++ SkPixmap::writable_addr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkPixmap
的用法示例。
在下文中一共展示了SkPixmap::writable_addr方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: blitH
void SkRasterPipelineBlitter::blitH(int x, int y, int w) {
fDstPtr = fDst.writable_addr(0,y);
if (fCanMemsetInBlitH) {
switch (fDst.shiftPerPixel()) {
case 0: memset ((uint8_t *)fDstPtr + x, fMemsetColor, w); return;
case 1: sk_memset16((uint16_t*)fDstPtr + x, fMemsetColor, w); return;
case 2: sk_memset32((uint32_t*)fDstPtr + x, fMemsetColor, w); return;
case 3: sk_memset64((uint64_t*)fDstPtr + x, fMemsetColor, w); return;
default: break;
}
}
if (!fBlitH) {
SkRasterPipeline p(fAlloc);
p.extend(fColorPipeline);
if (fBlend == SkBlendMode::kSrcOver
&& fDst.info().colorType() == kRGBA_8888_SkColorType
&& !fDst.colorSpace()
&& fDst.info().alphaType() != kUnpremul_SkAlphaType
&& fDitherRate == 0.0f) {
p.append(SkRasterPipeline::srcover_rgba_8888, &fDstPtr);
} else {
if (fBlend != SkBlendMode::kSrc) {
this->append_load_d(&p);
this->append_blend(&p);
this->maybe_clamp(&p);
}
this->append_store(&p);
}
fBlitH = p.compile();
}
this->maybe_shade(x,y,w);
fBlitH(x,y,w);
}
示例2: onGetROPixels
bool onGetROPixels(SkBitmap* dst) const override {
const auto desc = SkBitmapCacheDesc::Make(this->uniqueID(), this->width(), this->height());
if (SkBitmapCache::Find(desc, dst)) {
SkASSERT(dst->getGenerationID() == this->uniqueID());
SkASSERT(dst->isImmutable());
SkASSERT(dst->getPixels());
return true;
}
SkPixmap pmap;
SkImageInfo info = SkImageInfo::MakeN32(this->width(), this->height(),
this->alphaType(), fColorSpace);
auto rec = SkBitmapCache::Alloc(desc, info, &pmap);
if (!rec) {
return false;
}
sk_sp<SkColorSpace> colorSpace;
if (GrPixelConfigIsSRGB(fTextureProxy->config())) {
colorSpace = SkColorSpace::MakeSRGB();
}
sk_sp<GrSurfaceContext> sContext = fContext->contextPriv().makeWrappedSurfaceContext(
fTextureProxy, std::move(colorSpace));
if (!sContext) {
return false;
}
if (!sContext->readPixels(info, pmap.writable_addr(), pmap.rowBytes(), 0, 0)) {
return false;
}
SkBitmapCache::Add(std::move(rec), dst);
fAddedRasterVersionToCache.store(true);
return true;
}
示例3: blitAntiH
void SkRasterPipelineBlitter::blitAntiH(int x, int y, const SkAlpha aa[], const int16_t runs[]) {
if (!fBlitAntiH) {
SkRasterPipeline p(fAlloc);
p.extend(fColorPipeline);
if (fBlend == SkBlendMode::kSrcOver) {
p.append(SkRasterPipeline::scale_1_float, &fCurrentCoverage);
this->append_load_d(&p);
this->append_blend(&p);
} else {
this->append_load_d(&p);
this->append_blend(&p);
p.append(SkRasterPipeline::lerp_1_float, &fCurrentCoverage);
}
this->maybe_clamp(&p);
this->append_store(&p);
fBlitAntiH = p.compile();
}
fDstPtr = fDst.writable_addr(0,y);
for (int16_t run = *runs; run > 0; run = *runs) {
switch (*aa) {
case 0x00: break;
case 0xff: this->blitH(x,y,run); break;
default:
this->maybe_shade(x,y,run);
fCurrentCoverage = *aa * (1/255.0f);
fBlitAntiH(x,y,run);
}
x += run;
runs += run;
aa += run;
}
}
示例4: blitMask
void SkRasterPipelineBlitter::blitMask(const SkMask& mask, const SkIRect& clip) {
if (mask.fFormat == SkMask::kBW_Format) {
// TODO: native BW masks?
return INHERITED::blitMask(mask, clip);
}
int x = clip.left();
for (int y = clip.top(); y < clip.bottom(); y++) {
auto dst = fDst.writable_addr(0,y);
SkRasterPipeline p;
p.extend(fShader);
p.extend(fColorFilter);
this->append_load_d(&p, dst);
p.extend(fXfermode);
switch (mask.fFormat) {
case SkMask::kA8_Format:
p.append<lerp_a8, lerp_a8_1>(mask.getAddr8(x,y)-x);
break;
case SkMask::kLCD16_Format:
p.append<lerp_lcd16, lerp_lcd16_1>(mask.getAddrLCD16(x,y)-x);
break;
default: break;
}
this->append_store(&p, dst);
p.run(x, clip.width());
}
}
示例5: scalePixels
bool SkPixmap::scalePixels(const SkPixmap& dst, SkFilterQuality quality) const {
// Can't do anthing with empty src or dst
if (this->width() <= 0 || this->height() <= 0 || dst.width() <= 0 || dst.height() <= 0) {
return false;
}
// no scaling involved?
if (dst.width() == this->width() && dst.height() == this->height()) {
return this->readPixels(dst);
}
SkBitmap bitmap;
if (!bitmap.installPixels(*this)) {
return false;
}
bitmap.setIsVolatile(true); // so we don't try to cache it
SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterDirect(dst.info(), dst.writable_addr(),
dst.rowBytes()));
if (!surface) {
return false;
}
SkPaint paint;
paint.setFilterQuality(quality);
paint.setXfermodeMode(SkXfermode::kSrc_Mode);
surface->getCanvas()->drawBitmapRect(bitmap, SkRect::MakeIWH(dst.width(), dst.height()),
&paint);
return true;
}
示例6: Resize
bool SkBitmapScaler::Resize(const SkPixmap& result, const SkPixmap& source, ResizeMethod method) {
if (!valid_for_resize(source, result.width(), result.height())) {
return false;
}
if (!result.addr() || result.colorType() != source.colorType()) {
return false;
}
SkConvolutionProcs convolveProcs= { 0, nullptr, nullptr, nullptr, nullptr };
PlatformConvolutionProcs(&convolveProcs);
SkRect destSubset = SkRect::MakeIWH(result.width(), result.height());
SkResizeFilter filter(method, source.width(), source.height(),
result.width(), result.height(), destSubset, convolveProcs);
// Get a subset encompassing this touched area. We construct the
// offsets and row strides such that it looks like a new bitmap, while
// referring to the old data.
const uint8_t* sourceSubset = reinterpret_cast<const uint8_t*>(source.addr());
return BGRAConvolve2D(sourceSubset, static_cast<int>(source.rowBytes()),
!source.isOpaque(), filter.xFilter(), filter.yFilter(),
static_cast<int>(result.rowBytes()),
static_cast<unsigned char*>(result.writable_addr()),
convolveProcs, true);
}
示例7: blitH
void SkRasterPipelineBlitter::blitH(int x, int y, int w) {
fDstPtr = fDst.writable_addr(0,y);
fCurrentY = y;
if (fCanMemsetInBlitH) {
switch (fDst.shiftPerPixel()) {
case 0: memset ((uint8_t *)fDstPtr + x, fMemsetColor, w); return;
case 1: sk_memset16((uint16_t*)fDstPtr + x, fMemsetColor, w); return;
case 2: sk_memset32((uint32_t*)fDstPtr + x, fMemsetColor, w); return;
case 3: sk_memset64((uint64_t*)fDstPtr + x, fMemsetColor, w); return;
default: break;
}
}
auto& p = fBlitH;
if (p.empty()) {
p.extend(fShader);
if (fBlend != SkBlendMode::kSrc) {
this->append_load_d(&p);
this->append_blend(&p);
this->maybe_clamp(&p);
}
this->append_store(&p);
}
p.run(x,w);
}
示例8: MakeSkiaImageInfo
uint8_t*
SourceSurfaceSkia::GetData()
{
#ifdef USE_SKIA_GPU
if (mImage->isTextureBacked()) {
sk_sp<SkImage> raster;
if (sk_sp<SkData> data = MakeSkData(nullptr, mSize, mStride)) {
SkImageInfo info = MakeSkiaImageInfo(mSize, mFormat);
if (mImage->readPixels(info, data->writable_data(), mStride, 0, 0, SkImage::kDisallow_CachingHint)) {
raster = SkImage::MakeRasterData(info, data, mStride);
}
}
if (raster) {
mImage = raster;
} else {
gfxCriticalError() << "Failed making Skia raster image for GPU surface";
}
}
#endif
SkPixmap pixmap;
if (!mImage->peekPixels(&pixmap)) {
gfxCriticalError() << "Failed accessing pixels for Skia raster image";
}
return reinterpret_cast<uint8_t*>(pixmap.writable_addr());
}
示例9: INHERITED
SkSpecialImage_Raster(const SkIRect& subset,
const SkPixmap& pixmap,
RasterReleaseProc releaseProc,
ReleaseContext context,
const SkSurfaceProps* props)
: INHERITED(subset, kNeedNewImageUniqueID_SpecialImage, props) {
fBitmap.installPixels(pixmap.info(), pixmap.writable_addr(),
pixmap.rowBytes(), pixmap.ctable(),
releaseProc, context);
}
示例10: blitMask
void SkRasterPipelineBlitter::blitMask(const SkMask& mask, const SkIRect& clip) {
if (mask.fFormat == SkMask::kBW_Format) {
// TODO: native BW masks?
return INHERITED::blitMask(mask, clip);
}
if (mask.fFormat == SkMask::kA8_Format && !fBlitMaskA8) {
SkRasterPipeline p(fAlloc);
p.extend(fColorPipeline);
if (fBlend == SkBlendMode::kSrcOver) {
p.append(SkRasterPipeline::scale_u8, &fMaskPtr);
this->append_load_d(&p);
this->append_blend(&p);
} else {
this->append_load_d(&p);
this->append_blend(&p);
p.append(SkRasterPipeline::lerp_u8, &fMaskPtr);
}
this->maybe_clamp(&p);
this->append_store(&p);
fBlitMaskA8 = p.compile();
}
if (mask.fFormat == SkMask::kLCD16_Format && !fBlitMaskLCD16) {
SkRasterPipeline p(fAlloc);
p.extend(fColorPipeline);
this->append_load_d(&p);
this->append_blend(&p);
p.append(SkRasterPipeline::lerp_565, &fMaskPtr);
this->maybe_clamp(&p);
this->append_store(&p);
fBlitMaskLCD16 = p.compile();
}
int x = clip.left();
for (int y = clip.top(); y < clip.bottom(); y++) {
fDstPtr = fDst.writable_addr(0,y);
this->maybe_shade(x,y,clip.width());
switch (mask.fFormat) {
case SkMask::kA8_Format:
fMaskPtr = mask.getAddr8(x,y)-x;
fBlitMaskA8(x,y,clip.width());
break;
case SkMask::kLCD16_Format:
fMaskPtr = mask.getAddrLCD16(x,y)-x;
fBlitMaskLCD16(x,y,clip.width());
break;
default:
// TODO
break;
}
}
}
示例11: blitH
void SkRasterPipelineBlitter::blitH(int x, int y, int w) {
auto dst = fDst.writable_addr(0,y);
SkRasterPipeline p;
p.extend(fShader);
p.extend(fColorFilter);
this->append_load_d(&p, dst);
p.extend(fXfermode);
this->append_store(&p, dst);
p.run(x, w);
}
示例12: getROPixels
bool SkImage_Gpu::getROPixels(SkBitmap* dst, SkColorSpace* dstColorSpace, CachingHint chint) const {
const auto desc = SkBitmapCacheDesc::Make(this);
if (SkBitmapCache::Find(desc, dst)) {
SkASSERT(dst->getGenerationID() == this->uniqueID());
SkASSERT(dst->isImmutable());
SkASSERT(dst->getPixels());
return true;
}
SkImageInfo ii = make_info(this->width(), this->height(), this->alphaType(),
sk_ref_sp(dstColorSpace));
SkBitmapCache::RecPtr rec = nullptr;
SkPixmap pmap;
if (kAllow_CachingHint == chint) {
rec = SkBitmapCache::Alloc(desc, ii, &pmap);
if (!rec) {
return false;
}
} else {
if (!dst->tryAllocPixels(ii)) {
return false;
}
}
sk_sp<GrSurfaceContext> sContext = fContext->contextPriv().makeWrappedSurfaceContext(
fProxy,
fColorSpace);
if (!sContext) {
return false;
}
if (!sContext->readPixels(pmap.info(), pmap.writable_addr(), pmap.rowBytes(), 0, 0)) {
return false;
}
if (rec) {
SkBitmapCache::Add(std::move(rec), dst);
fAddedRasterVersionToCache.store(true);
}
return true;
}
示例13: blitAntiH
void SkRasterPipelineBlitter::blitAntiH(int x, int y, const SkAlpha aa[], const int16_t runs[]) {
auto dst = fDst.writable_addr(0,y);
float coverage;
SkRasterPipeline p;
p.extend(fShader);
p.extend(fColorFilter);
this->append_load_d(&p, dst);
p.extend(fXfermode);
p.append<lerp_constant_float>(&coverage);
this->append_store(&p, dst);
for (int16_t run = *runs; run > 0; run = *runs) {
coverage = *aa * (1/255.0f);
p.run(x, run);
x += run;
runs += run;
aa += run;
}
}
示例14: CaptureCanvasState
SkCanvasState* SkCanvasStateUtils::CaptureCanvasState(SkCanvas* canvas) {
SkASSERT(canvas);
// Check the clip can be decomposed into rectangles (i.e. no soft clips).
ClipValidator validator;
canvas->replayClips(&validator);
if (validator.failed()) {
SkErrorInternals::SetError(kInvalidOperation_SkError,
"CaptureCanvasState does not support canvases with antialiased clips.\n");
return nullptr;
}
SkAutoTDelete<SkCanvasState_v1> canvasState(new SkCanvasState_v1(canvas));
// decompose the total matrix and clip
setup_MC_state(&canvasState->mcState, canvas->getTotalMatrix(),
canvas->internal_private_getTotalClip());
/*
* decompose the layers
*
* storage is allocated on the stack for the first 3 layers. It is common in
* some view systems (e.g. Android) that a few non-clipped layers are present
* and we will not need to malloc any additional memory in those cases.
*/
SkSWriter32<3*sizeof(SkCanvasLayerState)> layerWriter;
int layerCount = 0;
for (SkCanvas::LayerIter layer(canvas); !layer.done(); layer.next()) {
// we currently only work for bitmap backed devices
SkPixmap pmap;
if (!layer.device()->accessPixels(&pmap) || 0 == pmap.width() || 0 == pmap.height()) {
return nullptr;
}
SkCanvasLayerState* layerState =
(SkCanvasLayerState*) layerWriter.reserve(sizeof(SkCanvasLayerState));
layerState->type = kRaster_CanvasBackend;
layerState->x = layer.x();
layerState->y = layer.y();
layerState->width = pmap.width();
layerState->height = pmap.height();
switch (pmap.colorType()) {
case kN32_SkColorType:
layerState->raster.config = kARGB_8888_RasterConfig;
break;
case kRGB_565_SkColorType:
layerState->raster.config = kRGB_565_RasterConfig;
break;
default:
return nullptr;
}
layerState->raster.rowBytes = pmap.rowBytes();
layerState->raster.pixels = pmap.writable_addr();
setup_MC_state(&layerState->mcState, layer.matrix(), layer.clip().bwRgn());
layerCount++;
}
// allocate memory for the layers and then and copy them to the struct
SkASSERT(layerWriter.bytesWritten() == layerCount * sizeof(SkCanvasLayerState));
canvasState->layerCount = layerCount;
canvasState->layers = (SkCanvasLayerState*) sk_malloc_throw(layerWriter.bytesWritten());
layerWriter.flatten(canvasState->layers);
return canvasState.release();
}
示例15: readPixels
bool SkImage::readPixels(const SkPixmap& pmap, int srcX, int srcY) const {
return this->readPixels(pmap.info(), pmap.writable_addr(), pmap.rowBytes(), srcX, srcY);
}