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) {
|
||||
fCurContext->abandonContext();
|
||||
}
|
||||
fGpuDevice.reset(nullptr);
|
||||
fCanvas.reset(nullptr);
|
||||
|
||||
fGpuSurface = nullptr;
|
||||
fCanvas = nullptr;
|
||||
|
||||
fCurContext.reset(GrContext::Create(kOpenGL_GrBackend, (GrBackendContext) fCurIntf.get()));
|
||||
}
|
||||
@ -55,17 +56,11 @@ void SkGLWidget::createRenderTarget() {
|
||||
glClear(GL_STENCIL_BUFFER_BIT);
|
||||
fCurContext->resetContext();
|
||||
|
||||
fGpuDevice.reset(nullptr);
|
||||
fCanvas.reset(nullptr);
|
||||
|
||||
GrBackendRenderTargetDesc desc = this->getDesc(this->width(), this->height());
|
||||
desc.fOrigin = kBottomLeft_GrSurfaceOrigin;
|
||||
sk_sp<GrRenderTarget> curRenderTarget(
|
||||
fCurContext->textureProvider()->wrapBackendRenderTarget(desc));
|
||||
SkSurfaceProps props(0, kUnknown_SkPixelGeometry);
|
||||
fGpuDevice.reset(SkGpuDevice::Make(std::move(curRenderTarget), nullptr, &props,
|
||||
SkGpuDevice::kUninit_InitContents).release());
|
||||
fCanvas.reset(new SkCanvas(fGpuDevice));
|
||||
|
||||
fGpuSurface = SkSurface::MakeFromBackendRenderTarget(fCurContext, desc, nullptr);
|
||||
fCanvas = fGpuSurface->getCanvas();
|
||||
}
|
||||
|
||||
void SkGLWidget::resizeGL(int w, int h) {
|
||||
@ -76,7 +71,7 @@ void SkGLWidget::resizeGL(int w, int h) {
|
||||
void SkGLWidget::paintGL() {
|
||||
if (!this->isHidden() && fCanvas) {
|
||||
fCurContext->resetContext();
|
||||
fDebugger->draw(fCanvas.get());
|
||||
fDebugger->draw(fCanvas);
|
||||
// TODO(chudy): Implement an optional flush button in Gui.
|
||||
fCanvas->flush();
|
||||
Q_EMIT drawComplete();
|
||||
|
@ -47,8 +47,10 @@ private:
|
||||
void createRenderTarget();
|
||||
SkAutoTUnref<const GrGLInterface> fCurIntf;
|
||||
SkAutoTUnref<GrContext> fCurContext;
|
||||
SkAutoTUnref<SkGpuDevice> fGpuDevice;
|
||||
SkAutoTUnref<SkCanvas> fCanvas;
|
||||
|
||||
sk_sp<SkSurface> fGpuSurface;
|
||||
SkCanvas* fCanvas;
|
||||
|
||||
SkDebugger* fDebugger;
|
||||
GrBackendRenderTargetDesc getDesc(int w, int h);
|
||||
};
|
||||
|
@ -206,15 +206,14 @@ int main(int argc, char** argv) {
|
||||
GrGLint buffer;
|
||||
GR_GL_GetIntegerv(interface, GR_GL_FRAMEBUFFER_BINDING, &buffer);
|
||||
desc.fRenderTargetHandle = buffer;
|
||||
SkAutoTUnref<GrRenderTarget>
|
||||
renderTarget(grContext->textureProvider()->wrapBackendRenderTarget(desc));
|
||||
|
||||
// setup SkSurface
|
||||
// To use distance field text, use commented out SkSurfaceProps instead
|
||||
// SkSurfaceProps props(SkSurfaceProps::kUseDeviceIndependentFonts_Flag,
|
||||
// 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();
|
||||
|
||||
|
@ -48,7 +48,6 @@ SkV8ExampleWindow::SkV8ExampleWindow(void* hwnd, JsContext* context)
|
||||
#if SK_SUPPORT_GPU
|
||||
, fCurContext(NULL)
|
||||
, fCurIntf(NULL)
|
||||
, fCurRenderTarget(NULL)
|
||||
, fCurSurface(NULL)
|
||||
#endif
|
||||
{
|
||||
@ -64,7 +63,6 @@ SkV8ExampleWindow::~SkV8ExampleWindow() {
|
||||
#if SK_SUPPORT_GPU
|
||||
SkSafeUnref(fCurContext);
|
||||
SkSafeUnref(fCurIntf);
|
||||
SkSafeUnref(fCurRenderTarget);
|
||||
SkSafeUnref(fCurSurface);
|
||||
#endif
|
||||
}
|
||||
@ -99,10 +97,9 @@ void SkV8ExampleWindow::windowSizeChanged() {
|
||||
GR_GL_GetIntegerv(fCurIntf, GR_GL_FRAMEBUFFER_BINDING, &buffer);
|
||||
desc.fRenderTargetHandle = buffer;
|
||||
|
||||
SkSafeUnref(fCurRenderTarget);
|
||||
fCurRenderTarget = fCurContext->wrapBackendRenderTarget(desc);
|
||||
SkSafeUnref(fCurSurface);
|
||||
fCurSurface = SkSurface::NewRenderTargetDirect(fCurRenderTarget);
|
||||
fCurSurface = SkSurface::MakeFromBackendRenderTarget(fCurContext, desc,
|
||||
nullptr, nullptr).release();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -178,12 +178,6 @@ public:
|
||||
const SkSurfaceProps* props = NULL) {
|
||||
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,
|
||||
const SkSurfaceProps* props) {
|
||||
return MakeFromBackendTexture(ctx, desc, props).release();
|
||||
|
Loading…
Reference in New Issue
Block a user