static PassRefPtr<SkSurface> createSkSurface(GrContext* gr, const IntSize& size, int msaaSampleCount, OpacityMode opacityMode, bool* surfaceIsAccelerated) { if (gr) gr->resetContext(); SkAlphaType alphaType = (Opaque == opacityMode) ? kOpaque_SkAlphaType : kPremul_SkAlphaType; SkImageInfo info = SkImageInfo::MakeN32(size.width(), size.height(), alphaType); SkSurfaceProps disableLCDProps(0, kUnknown_SkPixelGeometry); RefPtr<SkSurface> surface; if (gr) { *surfaceIsAccelerated = true; surface = adoptRef(SkSurface::NewRenderTarget(gr, SkSurface::kNo_Budgeted, info, msaaSampleCount, Opaque == opacityMode ? 0 : &disableLCDProps)); } if (!surface) { *surfaceIsAccelerated = false; surface = adoptRef(SkSurface::NewRaster(info, Opaque == opacityMode ? 0 : &disableLCDProps)); } if (surface) { if (opacityMode == Opaque) { surface->getCanvas()->clear(SK_ColorBLACK); } else { surface->getCanvas()->clear(SK_ColorTRANSPARENT); } } return surface; }
static PassRefPtr<SkSurface> createSkSurface(GrContext* gr, const IntSize& size, int msaaSampleCount, OpacityMode opacityMode) { if (!gr) return nullptr; gr->resetContext(); SkImageInfo info = SkImageInfo::MakeN32Premul(size.width(), size.height()); SkSurfaceProps disableLCDProps(0, kUnknown_SkPixelGeometry); return adoptRef(SkSurface::NewRenderTarget(gr, info, msaaSampleCount, Opaque == opacityMode ? 0 : &disableLCDProps)); }
UnacceleratedImageBufferSurface::UnacceleratedImageBufferSurface(const IntSize& size, OpacityMode opacityMode, ImageInitializationMode initializationMode) : ImageBufferSurface(size, opacityMode) { SkAlphaType alphaType = (Opaque == opacityMode) ? kOpaque_SkAlphaType : kPremul_SkAlphaType; SkImageInfo info = SkImageInfo::MakeN32(size.width(), size.height(), alphaType); SkSurfaceProps disableLCDProps(0, kUnknown_SkPixelGeometry); m_surface = adoptRef(SkSurface::NewRaster(info, Opaque == opacityMode ? 0 : &disableLCDProps)); if (initializationMode == InitializeImagePixels) { if (m_surface) clear(); } }
static PassRefPtr<SkSurface> createSkSurface(GrContext* gr, const IntSize& size, int msaaSampleCount, OpacityMode opacityMode) { if (!gr) return nullptr; gr->resetContext(); SkImageInfo info = SkImageInfo::MakeN32Premul(size.width(), size.height()); SkSurfaceProps disableLCDProps(0, kUnknown_SkPixelGeometry); RefPtr<SkSurface> surface = adoptRef(SkSurface::NewRenderTarget(gr, SkSurface::kNo_Budgeted, info, msaaSampleCount, Opaque == opacityMode ? 0 : &disableLCDProps)); if (surface) { if (opacityMode == Opaque) { surface->getCanvas()->clear(SK_ColorBLACK); } else { surface->getCanvas()->clear(SK_ColorTRANSPARENT); } } return surface; }
AcceleratedImageBufferSurface::AcceleratedImageBufferSurface(const IntSize& size, OpacityMode opacityMode) : ImageBufferSurface(size, opacityMode) { m_contextProvider = adoptPtr(Platform::current()->createSharedOffscreenGraphicsContext3DProvider()); if (!m_contextProvider) return; GrContext* grContext = m_contextProvider->grContext(); if (!grContext) return; SkAlphaType alphaType = (Opaque == opacityMode) ? kOpaque_SkAlphaType : kPremul_SkAlphaType; SkImageInfo info = SkImageInfo::MakeN32(size.width(), size.height(), alphaType); SkSurfaceProps disableLCDProps(0, kUnknown_SkPixelGeometry); m_surface = adoptPtr(SkSurface::NewRenderTarget(grContext, SkSurface::kYes_Budgeted, info, 0 /* sampleCount */, Opaque == opacityMode ? nullptr : &disableLCDProps)); if (!m_surface.get()) return; clear(); }