| 68 | } |
| 69 | |
| 70 | std::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 |
nothing calls this directly
no test coverage detected