This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[android] extract View and RendererBackend from NativeMapView
- Loading branch information
1 parent
748b815
commit 4067c2a
Showing
5 changed files
with
110 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#include "android_renderer_backend.hpp" | ||
|
||
#include <EGL/egl.h> | ||
|
||
#include <cassert> | ||
|
||
namespace mbgl { | ||
namespace android { | ||
|
||
/** | ||
* From mbgl::View | ||
*/ | ||
void AndroidRendererBackend::bind() { | ||
assert(BackendScope::exists()); | ||
setFramebufferBinding(0); | ||
setViewport(0, 0, getFramebufferSize()); | ||
} | ||
|
||
/** | ||
* From mbgl::RendererBackend. | ||
*/ | ||
gl::ProcAddress AndroidRendererBackend::initializeExtension(const char* name) { | ||
assert(BackendScope::exists()); | ||
return eglGetProcAddress(name); | ||
} | ||
|
||
void AndroidRendererBackend::updateViewPort() { | ||
assert(BackendScope::exists()); | ||
setViewport(0, 0, getFramebufferSize()); | ||
} | ||
|
||
void AndroidRendererBackend::resizeFramebuffer(int width, int height) { | ||
fbWidth = width; | ||
fbHeight = height; | ||
} | ||
|
||
PremultipliedImage AndroidRendererBackend::readFramebuffer() const { | ||
assert(BackendScope::exists()); | ||
return RendererBackend::readFramebuffer(getFramebufferSize()); | ||
} | ||
|
||
const mbgl::Size AndroidRendererBackend::getFramebufferSize() const { | ||
return { static_cast<uint32_t>(fbWidth), static_cast<uint32_t>(fbHeight) }; | ||
} | ||
|
||
/** | ||
* From mbgl::RendererBackend. | ||
*/ | ||
void AndroidRendererBackend::updateAssumedState() { | ||
assumeFramebufferBinding(0); | ||
assumeViewport(0, 0, getFramebufferSize()); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#pragma once | ||
|
||
#include <mbgl/renderer/renderer_backend.hpp> | ||
#include <mbgl/map/view.hpp> | ||
|
||
namespace mbgl { | ||
namespace android { | ||
|
||
class AndroidRendererBackend : public RendererBackend, public View { | ||
public: | ||
|
||
// mbgl::View // | ||
void bind() override; | ||
|
||
// mbgl::RendererBackend // | ||
void updateAssumedState() override; | ||
|
||
void updateViewPort(); | ||
|
||
void resizeFramebuffer(int width, int height); | ||
const mbgl::Size getFramebufferSize() const; | ||
PremultipliedImage readFramebuffer() const; | ||
|
||
protected: | ||
// mbgl::RendererBackend // | ||
gl::ProcAddress initializeExtension(const char*) override; | ||
void activate() override {}; | ||
void deactivate() override {}; | ||
|
||
|
||
private: | ||
|
||
// Minimum texture size according to OpenGL ES 2.0 specification. | ||
int fbWidth = 64; | ||
int fbHeight = 64; | ||
|
||
}; | ||
|
||
} // namespace android | ||
} // namespace mbgl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters