Skip to content

Commit

Permalink
remove some useless code and fix code format error
Browse files Browse the repository at this point in the history
  • Loading branch information
Hparty committed Sep 11, 2024
1 parent 72aeab5 commit f7907cc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
20 changes: 10 additions & 10 deletions src/platform/ohos/JPAGImageView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ napi_value JPAGImageView::Constructor(napi_env env, napi_callback_info info) {
}

std::shared_ptr<PAGDecoder> JPAGImageView::getDecoderInternal() {
if (window == nullptr || _composition == nullptr) {
if (targetWindow == nullptr || _composition == nullptr) {
_decoder = nullptr;
return nullptr;
}
Expand Down Expand Up @@ -589,7 +589,7 @@ void JPAGImageView::onSurfaceCreated(NativeWindow* window) {
return;
}
_window = window;
this->window = tgfx::EGLWindow::MakeFrom(reinterpret_cast<EGLNativeWindowType>(_window));
targetWindow = tgfx::EGLWindow::MakeFrom(reinterpret_cast<EGLNativeWindowType>(_window));
_animator->update();
invalidSize();
}
Expand All @@ -605,7 +605,7 @@ void JPAGImageView::onSurfaceSizeChanged() {
void JPAGImageView::onSurfaceDestroyed() {
std::lock_guard lock_guard(locker);
_window = nullptr;
window = nullptr;
targetWindow = nullptr;
_width = 0;
_height = 0;
}
Expand All @@ -617,8 +617,8 @@ std::shared_ptr<PAGDecoder> JPAGImageView::getDecoder() {

void JPAGImageView::invalidSize() {
_decoder = nullptr;
if (window) {
window->invalidSize();
if (targetWindow) {
targetWindow->invalidSize();
}
OH_NativeWindow_NativeWindowHandleOpt(_window, GET_BUFFER_GEOMETRY, &_height, &_width);
}
Expand Down Expand Up @@ -772,20 +772,20 @@ bool JPAGImageView::handleFrame(Frame frame) {
}

bool JPAGImageView::drawImage(std::shared_ptr<tgfx::Image> image) {
if (!window && image) {
if (!targetWindow && image) {
return false;
}
auto device = window->getDevice();
auto device = targetWindow->getDevice();
if (!device) {
return false;
}
auto context = device->lockContext();
if (!context) {
return false;
}
auto surface = window->getSurface(context, true);
auto surface = targetWindow->getSurface(context, true);
if (surface == nullptr) {
surface = window->getSurface(context, false);
surface = targetWindow->getSurface(context, false);
}
if (!surface) {
device->unlock();
Expand All @@ -802,7 +802,7 @@ bool JPAGImageView::drawImage(std::shared_ptr<tgfx::Image> image) {
canvas->drawImage(image, imageMatrix);
surface->flush();
context->submit();
window->present(context);
targetWindow->present(context);
context->purgeResourcesNotUsedSince(std::chrono::steady_clock::now());
device->unlock();
return true;
Expand Down
10 changes: 4 additions & 6 deletions src/platform/ohos/JPAGImageView.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,21 +106,19 @@ class JPAGImageView : public PAGAnimator::Listener, public XComponentListener {
bool drawImage(std::shared_ptr<tgfx::Image> image);

std::mutex locker;
std::shared_ptr<PAGDecoder> _decoder = nullptr;
int _width = 0;
int _height = 0;
float _renderScale = 1.0f;
float _frameRate = 30.0f;
int _scaleMode = PAGScaleMode::LetterBox;
tgfx::Matrix _matrix = tgfx::Matrix::I();
bool _cacheAllFramesInMemory = false;
std::shared_ptr<PAGComposition> _composition = nullptr;
std::shared_ptr<PAGAnimator> _animator = nullptr;
std::shared_ptr<PAGDecoder> _decoder = nullptr;

NativeWindow* _window = nullptr;
std::shared_ptr<tgfx::Window> window = nullptr;
std::shared_ptr<PAGComposition> container = nullptr;
std::shared_ptr<PAGImageLayer> imageLayer = nullptr;
std::shared_ptr<PAGAnimator> _animator = nullptr;
std::shared_ptr<PAGComposition> _composition = nullptr;
std::shared_ptr<tgfx::Window> targetWindow = nullptr;
std::shared_ptr<tgfx::Image> currentImage = nullptr;
tgfx::Bitmap currentBitmap;

Expand Down
2 changes: 1 addition & 1 deletion src/platform/ohos/XComponentHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
namespace pag {
class XComponentListener {
public:
virtual ~XComponentListener(){};
virtual ~XComponentListener() {};
virtual void onSurfaceCreated(NativeWindow* window) = 0;
virtual void onSurfaceSizeChanged() = 0;
virtual void onSurfaceDestroyed() = 0;
Expand Down

0 comments on commit f7907cc

Please sign in to comment.