MCPcopy Create free account
hub / github.com/Tencent/libpag / onCreateSurface

Method onCreateSurface

src/rendering/drawables/BitmapDrawable.cpp:70–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68}
69
70std::shared_ptr<tgfx::Surface> BitmapDrawable::onCreateSurface(tgfx::Context* context) {
71 if (bitmap == nullptr) {
72 return nullptr;
73 }
74 auto hardwareBuffer = bitmap->getHardwareBuffer();
75 if (hardwareBuffer != nullptr) {
76 return tgfx::Surface::MakeFrom(context, hardwareBuffer);
77 }
78 if (offscreenSurface == nullptr) {
79 hardwareBuffer = tgfx::HardwareBufferAllocate(_width, _height);
80 offscreenSurface = tgfx::Surface::MakeFrom(context, hardwareBuffer);
81 tgfx::HardwareBufferRelease(hardwareBuffer);
82 if (offscreenSurface == nullptr) {
83 auto colorType = bitmap->info().colorType() == tgfx::ColorType::BGRA_8888
84 ? tgfx::ColorType::BGRA_8888
85 : tgfx::ColorType::RGBA_8888;
86 offscreenSurface = tgfx::Surface::Make(context, _width, _height, colorType);
87 }
88 }
89 return offscreenSurface;
90}
91} // namespace pag

Callers

nothing calls this directly

Calls 3

infoMethod · 0.80
MakeFunction · 0.50
getHardwareBufferMethod · 0.45

Tested by

no test coverage detected