本文整理汇总了C++中SkDevice::width方法的典型用法代码示例。如果您正苦于以下问题:C++ SkDevice::width方法的具体用法?C++ SkDevice::width怎么用?C++ SkDevice::width使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkDevice
的用法示例。
在下文中一共展示了SkDevice::width方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
static void
_canvas_device_region(SkCanvas *canvas, SkRegion *region) {
SkDevice *device;
int w, h;
device = canvas->getDevice();
w = device->width();
h = device->height();
region->setRect(0, 0, w, h);
}
示例2: getViewport
bool SkGpuCanvas::getViewport(SkIPoint* size) const {
if (size) {
SkDevice* device = this->getDevice();
if (device) {
size->set(device->width(), device->height());
} else {
size->set(0, 0);
}
}
return true;
}
示例3: toDataURL
String ImageBuffer::toDataURL(const String& mimeType, const double* quality) const
{
SkDevice* device = context()->platformContext()->canvas()->getDevice();
SkBitmap bitmap = device->accessBitmap(false);
// if we can't see the pixels directly, call readPixels() to get a copy.
// this could happen if the device is backed by a GPU.
bitmap.lockPixels(); // balanced by our destructor, or explicitly if getPixels() fails
if (!bitmap.getPixels()) {
bitmap.unlockPixels();
SkIRect bounds = SkIRect::MakeWH(device->width(), device->height());
if (!device->readPixels(bounds, &bitmap))
return "data:,";
}
return ImageToDataURL(bitmap, mimeType, quality);
}
示例4: updateMC
void updateMC(const SkMatrix& totalMatrix, const SkRegion& totalClip,
const SkClipStack& clipStack, SkRegion* updateClip) {
int x = fDevice->getOrigin().x();
int y = fDevice->getOrigin().y();
int width = fDevice->width();
int height = fDevice->height();
if ((x | y) == 0) {
fMatrix = &totalMatrix;
fClip = totalClip;
} else {
fMatrixStorage = totalMatrix;
fMatrixStorage.postTranslate(SkIntToScalar(-x),
SkIntToScalar(-y));
fMatrix = &fMatrixStorage;
totalClip.translate(-x, -y, &fClip);
}
fClip.op(0, 0, width, height, SkRegion::kIntersect_Op);
// intersect clip, but don't translate it (yet)
if (updateClip) {
updateClip->op(x, y, x + width, y + height,
SkRegion::kDifference_Op);
}
fDevice->setMatrixClip(*fMatrix, fClip, clipStack);
#ifdef SK_DEBUG
if (!fClip.isEmpty()) {
SkIRect deviceR;
deviceR.set(0, 0, width, height);
SkASSERT(deviceR.contains(fClip.getBounds()));
}
#endif
// default is to assume no external matrix
fMVMatrix = NULL;
fExtMatrix = NULL;
}
示例5: cgContext
CGContextRef BitLockerSkia::cgContext()
{
SkDevice* device = m_canvas->getDevice();
ASSERT(device);
if (!device)
return 0;
releaseIfNeeded();
const SkBitmap& bitmap = device->accessBitmap(true);
bitmap.lockPixels();
void* pixels = bitmap.getPixels();
m_cgContext = CGBitmapContextCreate(pixels, device->width(),
device->height(), 8, bitmap.rowBytes(), CGColorSpaceCreateDeviceRGB(),
kCGBitmapByteOrder32Host | kCGImageAlphaPremultipliedFirst);
// Apply device matrix.
CGAffineTransform contentsTransform = CGAffineTransformMakeScale(1, -1);
contentsTransform = CGAffineTransformTranslate(contentsTransform, 0, -device->height());
CGContextConcatCTM(m_cgContext, contentsTransform);
// Apply clip in device coordinates.
CGMutablePathRef clipPath = CGPathCreateMutable();
SkRegion::Iterator iter(m_canvas->getTotalClip());
for (; !iter.done(); iter.next()) {
IntRect rect = iter.rect();
CGPathAddRect(clipPath, 0, rect);
}
CGContextAddPath(m_cgContext, clipPath);
CGContextClip(m_cgContext);
CGPathRelease(clipPath);
// Apply content matrix.
const SkMatrix& skMatrix = m_canvas->getTotalMatrix();
CGAffineTransform affine = SkMatrixToCGAffineTransform(skMatrix);
CGContextConcatCTM(m_cgContext, affine);
return m_cgContext;
}