Remove some ancillary users of SkSurface::MakeRenderTargetDirect
calved off of: https://codereview.chromium.org/2176333002/ (Remove SkSurface::MakeRenderTargetDirect) GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2198433003 Review-Url: https://codereview.chromium.org/2198433003
This commit is contained in:
parent
f5b675efbe
commit
12e9662cf7
@ -38,8 +38,9 @@ void SkGLWidget::initializeGL() {
|
|||||||
if (fCurContext) {
|
if (fCurContext) {
|
||||||
fCurContext->abandonContext();
|
fCurContext->abandonContext();
|
||||||
}
|
}
|
||||||
fGpuDevice.reset(nullptr);
|
|
||||||
fCanvas.reset(nullptr);
|
fGpuSurface = nullptr;
|
||||||
|
fCanvas = nullptr;
|
||||||
|
|
||||||
fCurContext.reset(GrContext::Create(kOpenGL_GrBackend, (GrBackendContext) fCurIntf.get()));
|
fCurContext.reset(GrContext::Create(kOpenGL_GrBackend, (GrBackendContext) fCurIntf.get()));
|
||||||
}
|
}
|
||||||
@ -55,17 +56,11 @@ void SkGLWidget::createRenderTarget() {
|
|||||||
glClear(GL_STENCIL_BUFFER_BIT);
|
glClear(GL_STENCIL_BUFFER_BIT);
|
||||||
fCurContext->resetContext();
|
fCurContext->resetContext();
|
||||||
|
|
||||||
fGpuDevice.reset(nullptr);
|
|
||||||
fCanvas.reset(nullptr);
|
|
||||||
|
|
||||||
GrBackendRenderTargetDesc desc = this->getDesc(this->width(), this->height());
|
GrBackendRenderTargetDesc desc = this->getDesc(this->width(), this->height());
|
||||||
desc.fOrigin = kBottomLeft_GrSurfaceOrigin;
|
desc.fOrigin = kBottomLeft_GrSurfaceOrigin;
|
||||||
sk_sp<GrRenderTarget> curRenderTarget(
|
|
||||||
fCurContext->textureProvider()->wrapBackendRenderTarget(desc));
|
fGpuSurface = SkSurface::MakeFromBackendRenderTarget(fCurContext, desc, nullptr);
|
||||||
SkSurfaceProps props(0, kUnknown_SkPixelGeometry);
|
fCanvas = fGpuSurface->getCanvas();
|
||||||
fGpuDevice.reset(SkGpuDevice::Make(std::move(curRenderTarget), nullptr, &props,
|
|
||||||
SkGpuDevice::kUninit_InitContents).release());
|
|
||||||
fCanvas.reset(new SkCanvas(fGpuDevice));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkGLWidget::resizeGL(int w, int h) {
|
void SkGLWidget::resizeGL(int w, int h) {
|
||||||
@ -76,7 +71,7 @@ void SkGLWidget::resizeGL(int w, int h) {
|
|||||||
void SkGLWidget::paintGL() {
|
void SkGLWidget::paintGL() {
|
||||||
if (!this->isHidden() && fCanvas) {
|
if (!this->isHidden() && fCanvas) {
|
||||||
fCurContext->resetContext();
|
fCurContext->resetContext();
|
||||||
fDebugger->draw(fCanvas.get());
|
fDebugger->draw(fCanvas);
|
||||||
// TODO(chudy): Implement an optional flush button in Gui.
|
// TODO(chudy): Implement an optional flush button in Gui.
|
||||||
fCanvas->flush();
|
fCanvas->flush();
|
||||||
Q_EMIT drawComplete();
|
Q_EMIT drawComplete();
|
||||||
|
@ -47,8 +47,10 @@ private:
|
|||||||
void createRenderTarget();
|
void createRenderTarget();
|
||||||
SkAutoTUnref<const GrGLInterface> fCurIntf;
|
SkAutoTUnref<const GrGLInterface> fCurIntf;
|
||||||
SkAutoTUnref<GrContext> fCurContext;
|
SkAutoTUnref<GrContext> fCurContext;
|
||||||
SkAutoTUnref<SkGpuDevice> fGpuDevice;
|
|
||||||
SkAutoTUnref<SkCanvas> fCanvas;
|
sk_sp<SkSurface> fGpuSurface;
|
||||||
|
SkCanvas* fCanvas;
|
||||||
|
|
||||||
SkDebugger* fDebugger;
|
SkDebugger* fDebugger;
|
||||||
GrBackendRenderTargetDesc getDesc(int w, int h);
|
GrBackendRenderTargetDesc getDesc(int w, int h);
|
||||||
};
|
};
|
||||||
|
@ -206,15 +206,14 @@ int main(int argc, char** argv) {
|
|||||||
GrGLint buffer;
|
GrGLint buffer;
|
||||||
GR_GL_GetIntegerv(interface, GR_GL_FRAMEBUFFER_BINDING, &buffer);
|
GR_GL_GetIntegerv(interface, GR_GL_FRAMEBUFFER_BINDING, &buffer);
|
||||||
desc.fRenderTargetHandle = buffer;
|
desc.fRenderTargetHandle = buffer;
|
||||||
SkAutoTUnref<GrRenderTarget>
|
|
||||||
renderTarget(grContext->textureProvider()->wrapBackendRenderTarget(desc));
|
|
||||||
|
|
||||||
// setup SkSurface
|
// setup SkSurface
|
||||||
// To use distance field text, use commented out SkSurfaceProps instead
|
// To use distance field text, use commented out SkSurfaceProps instead
|
||||||
// SkSurfaceProps props(SkSurfaceProps::kUseDeviceIndependentFonts_Flag,
|
// SkSurfaceProps props(SkSurfaceProps::kUseDeviceIndependentFonts_Flag,
|
||||||
// SkSurfaceProps::kLegacyFontHost_InitType);
|
// SkSurfaceProps::kLegacyFontHost_InitType);
|
||||||
SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
|
SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
|
||||||
SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTargetDirect(renderTarget, &props));
|
|
||||||
|
sk_sp<SkSurface> surface(SkSurface::MakeFromBackendRenderTarget(grContext, desc, &props));
|
||||||
|
|
||||||
SkCanvas* canvas = surface->getCanvas();
|
SkCanvas* canvas = surface->getCanvas();
|
||||||
|
|
||||||
|
@ -48,7 +48,6 @@ SkV8ExampleWindow::SkV8ExampleWindow(void* hwnd, JsContext* context)
|
|||||||
#if SK_SUPPORT_GPU
|
#if SK_SUPPORT_GPU
|
||||||
, fCurContext(NULL)
|
, fCurContext(NULL)
|
||||||
, fCurIntf(NULL)
|
, fCurIntf(NULL)
|
||||||
, fCurRenderTarget(NULL)
|
|
||||||
, fCurSurface(NULL)
|
, fCurSurface(NULL)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
@ -64,7 +63,6 @@ SkV8ExampleWindow::~SkV8ExampleWindow() {
|
|||||||
#if SK_SUPPORT_GPU
|
#if SK_SUPPORT_GPU
|
||||||
SkSafeUnref(fCurContext);
|
SkSafeUnref(fCurContext);
|
||||||
SkSafeUnref(fCurIntf);
|
SkSafeUnref(fCurIntf);
|
||||||
SkSafeUnref(fCurRenderTarget);
|
|
||||||
SkSafeUnref(fCurSurface);
|
SkSafeUnref(fCurSurface);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -99,10 +97,9 @@ void SkV8ExampleWindow::windowSizeChanged() {
|
|||||||
GR_GL_GetIntegerv(fCurIntf, GR_GL_FRAMEBUFFER_BINDING, &buffer);
|
GR_GL_GetIntegerv(fCurIntf, GR_GL_FRAMEBUFFER_BINDING, &buffer);
|
||||||
desc.fRenderTargetHandle = buffer;
|
desc.fRenderTargetHandle = buffer;
|
||||||
|
|
||||||
SkSafeUnref(fCurRenderTarget);
|
|
||||||
fCurRenderTarget = fCurContext->wrapBackendRenderTarget(desc);
|
|
||||||
SkSafeUnref(fCurSurface);
|
SkSafeUnref(fCurSurface);
|
||||||
fCurSurface = SkSurface::NewRenderTargetDirect(fCurRenderTarget);
|
fCurSurface = SkSurface::MakeFromBackendRenderTarget(fCurContext, desc,
|
||||||
|
nullptr, nullptr).release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -178,12 +178,6 @@ public:
|
|||||||
const SkSurfaceProps* props = NULL) {
|
const SkSurfaceProps* props = NULL) {
|
||||||
return NewRaster(SkImageInfo::MakeN32Premul(width, height), props);
|
return NewRaster(SkImageInfo::MakeN32Premul(width, height), props);
|
||||||
}
|
}
|
||||||
static SkSurface* NewRenderTargetDirect(GrRenderTarget* rt, const SkSurfaceProps* props) {
|
|
||||||
return MakeRenderTargetDirect(rt, nullptr, props).release();
|
|
||||||
}
|
|
||||||
static SkSurface* NewRenderTargetDirect(GrRenderTarget* target) {
|
|
||||||
return NewRenderTargetDirect(target, NULL);
|
|
||||||
}
|
|
||||||
static SkSurface* NewFromBackendTexture(GrContext* ctx, const GrBackendTextureDesc& desc,
|
static SkSurface* NewFromBackendTexture(GrContext* ctx, const GrBackendTextureDesc& desc,
|
||||||
const SkSurfaceProps* props) {
|
const SkSurfaceProps* props) {
|
||||||
return MakeFromBackendTexture(ctx, desc, props).release();
|
return MakeFromBackendTexture(ctx, desc, props).release();
|
||||||
|
Loading…
Reference in New Issue
Block a user