• wasm的 surface.makeSurface


    wasm的 surface.makeSurface js中:
      

    CanvasKit.Surface.prototype.makeSurface = function(imageInfo) {
        CanvasKit.setCurrentContext(this._context);
        var s = this._makeSurface(imageInfo);
        s._context = this._context;
        return s;
      };

     
      
    c++中  
     

     .function("_makeSurface", optional_override([](SkSurface& self, SimpleImageInfo sii)->sk_sp<SkSurface> {
                return self.makeSurface(toSkImageInfo(sii));
            }), allow_raw_pointers())
            
            
    
    SkImageInfo toSkImageInfo(const SimpleImageInfo& sii) {
        return SkImageInfo::Make(sii.width, sii.height, sii.colorType, sii.alphaType,
                                 sii.colorSpace ? sii.colorSpace : SkColorSpace::MakeSRGB());
    } 

    实现类中:

    sk_sp<SkSurface> SkSurface::makeSurface(const SkImageInfo& info) {
        return asSB(this)->onNewSurface(info);
    }


    最终到gpu中:

    sk_sp<SkSurface> SkSurface::MakeRenderTarget(GrRecordingContext* rContext,
                                                 const SkSurfaceCharacterization& c,
                                                 SkBudgeted budgeted) {
        if (!rContext || !c.isValid()) {
            return nullptr;
        }
    
        if (c.usesGLFBO0()) {
            // If we are making the surface we will never use FBO0.
            return nullptr;
        }
    
        if (c.vulkanSecondaryCBCompatible()) {
            return nullptr;
        }
    
        auto device = rContext->priv().createDevice(budgeted, c.imageInfo(), SkBackingFit::kExact,
                                                    c.sampleCount(), GrMipmapped(c.isMipMapped()),
                                                    c.isProtected(), c.origin(), c.surfaceProps(),
                                                    skgpu::BaseDevice::InitContents::kClear);
        if (!device) {
            return nullptr;
        }
    
        sk_sp<SkSurface> result = sk_make_sp<SkSurface_Gpu>(std::move(device));
    #ifdef SK_DEBUG
        if (result) {
            SkASSERT(result->isCompatible(c));
        }
    #endif
    
        return result;
    }
  • 相关阅读:
    Eugene and an array CodeForces
    Kind Anton CodeForces
    浙江大学PAT上机题解析之1011. World Cup Betting (20)
    九度OnlineJudge之1001:A+B for Matrices
    九度OnlineJudge之1468:Sharing
    九度OnlineJudge之1464:Hello World for U
    C++ STL 学习笔记
    浙江大学PAT上机题解析之1009. Product of Polynomials (25)
    浙江大学PAT上机题解析之1050. String Subtraction (20)
    浙江大学PAT上机题解析之1008. Elevator (20)
  • 原文地址:https://www.cnblogs.com/bigben0123/p/16599521.html
Copyright © 2020-2023  润新知