bool GraphicsContext3DInternal::paintCompositedResultsToCanvas(CanvasRenderingContext* context) { LOGWEBGL("paintCompositedResultsToCanvas()"); ImageBuffer* imageBuffer = context->canvas()->buffer(); const SkBitmap& canvasBitmap = imageBuffer->context()->platformContext()->recordingCanvas()->getDevice()->accessBitmap(false); SkCanvas canvas(canvasBitmap); MutexLocker lock(m_fboMutex); FBO* fbo = m_frontFBO; if (!fbo) return false; SkBitmap bitmap; bitmap.setConfig(SkBitmap::kARGB_8888_Config, m_width, m_height, fbo->bytesPerRow()); unsigned char* bits = NULL; if (fbo->lockGraphicBuffer((void**)&bits)) { bitmap.setPixels(bits); SkRect dstRect; dstRect.iset(0, 0, imageBuffer->size().width(), imageBuffer->size().height()); canvas.save(); canvas.translate(0, SkIntToScalar(imageBuffer->size().height())); canvas.scale(SK_Scalar1, -SK_Scalar1); canvas.drawBitmapRect(bitmap, 0, dstRect); canvas.restore(); bitmap.setPixels(0); fbo->unlockGraphicBuffer(); } return true; }
void onDelayedSetup() override { fBitmap.allocPixels(); fBitmap.setAlphaType(kOpaque_SkAlphaType); fBitmap.eraseColor(SK_ColorBLACK); draw_into_bitmap(fBitmap); fSrcR.iset(0, 0, kWidth, kHeight); fDstR.iset(0, 0, kWidth, kHeight); if (fSlightMatrix) { // want fractional translate fDstR.offset(SK_Scalar1 / 3, SK_Scalar1 * 5 / 7); // want enough to create a scale matrix, but not enough to scare // off our sniffer which tries to see if the matrix is "effectively" // translate-only. fDstR.fRight += SK_Scalar1 / (kWidth * 60); } }
BitmapRectView2() { make_big_bitmap(&fBitmap); this->setBGColor(SK_ColorGRAY); this->resetBounce(); fLimitR.iset(0, 0, fBitmap.width(), fBitmap.height()); fDstR[0] = SkRect::MakeXYWH(20, 20, 600, 200); fDstR[1] = fDstR[0]; fDstR[1].offset(0, fDstR[0].height() * 5/4); }
void GrSoftwarePathRenderer::DrawAroundInvPath(GrDrawContext* drawContext, const GrPaint* paint, const GrUserStencilSettings* userStencilSettings, const GrClip& clip, GrColor color, const SkMatrix& viewMatrix, const SkIRect& devClipBounds, const SkIRect& devPathBounds) { SkMatrix invert; if (!viewMatrix.invert(&invert)) { return; } SkRect rect; if (devClipBounds.fTop < devPathBounds.fTop) { rect.iset(devClipBounds.fLeft, devClipBounds.fTop, devClipBounds.fRight, devPathBounds.fTop); DrawNonAARect(drawContext, paint, userStencilSettings, clip, color, SkMatrix::I(), rect, invert); } if (devClipBounds.fLeft < devPathBounds.fLeft) { rect.iset(devClipBounds.fLeft, devPathBounds.fTop, devPathBounds.fLeft, devPathBounds.fBottom); DrawNonAARect(drawContext, paint, userStencilSettings, clip, color, SkMatrix::I(), rect, invert); } if (devClipBounds.fRight > devPathBounds.fRight) { rect.iset(devPathBounds.fRight, devPathBounds.fTop, devClipBounds.fRight, devPathBounds.fBottom); DrawNonAARect(drawContext, paint, userStencilSettings, clip, color, SkMatrix::I(), rect, invert); } if (devClipBounds.fBottom > devPathBounds.fBottom) { rect.iset(devClipBounds.fLeft, devPathBounds.fBottom, devClipBounds.fRight, devClipBounds.fBottom); DrawNonAARect(drawContext, paint, userStencilSettings, clip, color, SkMatrix::I(), rect, invert); } }
void onOnceBeforeDraw() override { make_big_bitmap(&fBitmap); this->setBGColor(SK_ColorGRAY); this->resetBounce(); fLimitR.iset(0, 0, fBitmap.width(), fBitmap.height()); fDstR[0] = SkRect::MakeXYWH(20, 20, 600, 200); fDstR[1] = fDstR[0]; fDstR[1].offset(0, fDstR[0].height() * 5/4); }
void GraphicsContext3DInternal::paintRenderingResultsToCanvas(CanvasRenderingContext* context) { LOGWEBGL("paintRenderingResultsToCanvas()"); ImageBuffer* imageBuffer = context->canvas()->buffer(); const SkBitmap& canvasBitmap = imageBuffer->context()->platformContext()->recordingCanvas()->getDevice()->accessBitmap(false); SkCanvas canvas(canvasBitmap); SkBitmap bitmap; bitmap.setConfig(SkBitmap::kARGB_8888_Config, m_width, m_height); bitmap.allocPixels(); unsigned char *pixels = static_cast<unsigned char*>(bitmap.getPixels()); glReadPixels(0, 0, m_width, m_height, GL_RGBA, GL_UNSIGNED_BYTE, pixels); SkRect dstRect; dstRect.iset(0, 0, imageBuffer->size().width(), imageBuffer->size().height()); canvas.drawBitmapRect(bitmap, 0, dstRect); }
void resetBounce() { fSrcR.iset(0, 0, fBitmap.height() * 3, fBitmap.height()); fDX = SK_Scalar1; }