Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(431)

Unified Diff: tools/viewer/sk_app/android/RasterWindowContext_android.cpp

Issue 2169543002: Use Windowing system-specific WindowContext factories. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: more xlib Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/viewer/sk_app/android/RasterWindowContext_android.cpp
diff --git a/tools/viewer/sk_app/android/RasterWindowContext_android.cpp b/tools/viewer/sk_app/android/RasterWindowContext_android.cpp
index e2e2c0b16c228027cb37270059c31c1c6350463d..ae49405f2940e59721bad9e9dafeda47279225ed 100644
--- a/tools/viewer/sk_app/android/RasterWindowContext_android.cpp
+++ b/tools/viewer/sk_app/android/RasterWindowContext_android.cpp
@@ -6,30 +6,38 @@
* found in the LICENSE file.
*/
-#include "RasterWindowContext_android.h"
-
+#include "WindowContextFactory_android.h"
+#include "../RasterWindowContext.h"
#include "SkSurface.h"
#include "SkTypes.h"
-#include "Window_android.h"
+using sk_app::RasterWindowContext;
+using sk_app::DisplayParams;
-namespace sk_app {
+namespace {
+class RasterWindowContext_android : public RasterWindowContext {
+public:
+ RasterWindowContext_android(ANativeWindow*, const DisplayParams& params);
-RasterWindowContext* RasterWindowContext::Create(void* platformData, const DisplayParams& params) {
- RasterWindowContext* ctx = new RasterWindowContext_android(platformData, params);
- if (!ctx->isValid()) {
- delete ctx;
- ctx = nullptr;
- }
- return ctx;
-}
+ sk_sp<SkSurface> getBackbufferSurface() override;
+ void swapBuffers() override;
+
+ bool isValid() override { return SkToBool(fNativeWindow); }
+ void resize(uint32_t w, uint32_t h) override;
+ void setDisplayParams(const DisplayParams& params) override;
+
+private:
+ void setBuffersGeometry();
+ sk_sp<SkSurface> fBackbufferSurface = nullptr;
+ ANativeWindow* fNativeWindow = nullptr;
+ ANativeWindow_Buffer fBuffer;
+ ARect fBounds;
+};
-RasterWindowContext_android::RasterWindowContext_android(
- void* platformData, const DisplayParams& params) {
+RasterWindowContext_android::RasterWindowContext_android(ANativeWindow* window,
+ const DisplayParams& params) {
fDisplayParams = params;
- ContextPlatformData_android* androidPlatformData =
- reinterpret_cast<ContextPlatformData_android*>(platformData);
- fNativeWindow = androidPlatformData->fNativeWindow;
+ fNativeWindow = window;
fWidth = ANativeWindow_getWidth(fNativeWindow);
fHeight = ANativeWindow_getHeight(fNativeWindow);
this->setBuffersGeometry();
@@ -80,5 +88,19 @@ void RasterWindowContext_android::swapBuffers() {
ANativeWindow_unlockAndPost(fNativeWindow);
fBackbufferSurface.reset(nullptr);
}
+} // anonymous namespace
+namespace sk_app {
+namespace window_context_factory {
+
+WindowContext* NewRasterForAndroid(ANativeWindow* window, const DisplayParams& params) {
+ WindowContext* ctx = new RasterWindowContext_android(window, params);
+ if (!ctx->isValid()) {
+ delete ctx;
+ return nullptr;
+ }
+ return ctx;
+}
+
+}
} // namespace sk_app
« no previous file with comments | « tools/viewer/sk_app/android/RasterWindowContext_android.h ('k') | tools/viewer/sk_app/android/VulkanWindowContext_android.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698