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

Unified Diff: platform_tools/android/visualbench/jni/main.cpp

Issue 1198433004: Fix for assert in VisualBench (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: tweaks Created 5 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: platform_tools/android/visualbench/jni/main.cpp
diff --git a/platform_tools/android/visualbench/jni/main.cpp b/platform_tools/android/visualbench/jni/main.cpp
index 293041ae8e9ed869495b8df6e72298d5877592fc..3d7ceab9eb63a6a7f5ca651c75a213a52ee64895 100644
--- a/platform_tools/android/visualbench/jni/main.cpp
+++ b/platform_tools/android/visualbench/jni/main.cpp
@@ -14,11 +14,19 @@
/**
* Shared state for our app.
*/
+enum State {
+ kInit_State,
+ kAnimate_State,
+ kDestroyRequested_State,
+ kFinished_State,
+};
+
struct VisualBenchState {
- VisualBenchState() : fApp(NULL), fWindow(NULL) {}
+ VisualBenchState() : fApp(NULL), fWindow(NULL), fState(kInit_State) {}
struct android_app* fApp;
SkOSWindow* fWindow;
SkTArray<SkString> fFlags;
+ State fState;
};
static void handle_cmd(struct android_app* app, int32_t cmd) {
@@ -26,12 +34,7 @@ static void handle_cmd(struct android_app* app, int32_t cmd) {
switch (cmd) {
case APP_CMD_INIT_WINDOW:
// The window is being shown, get it ready.
- if (state->fApp->window != NULL) {
- if (state->fWindow) {
- SkDELETE(state->fWindow);
- application_term();
- }
-
+ if (state->fApp->window != NULL && kInit_State == state->fState) {
// drain any events that occurred before |window| was assigned.
while (SkEvent::ProcessEvent());
@@ -48,12 +51,12 @@ static void handle_cmd(struct android_app* app, int32_t cmd) {
state->fWindow = create_sk_window((void*)state->fApp->window,
args.count(),
const_cast<char**>(args.begin()));
+ state->fWindow->forceInvalAll();
+ state->fState = kAnimate_State;
}
break;
case APP_CMD_TERM_WINDOW:
- SkDELETE(state->fWindow);
- state->fWindow = NULL;
- application_term();
+ state->fState = kDestroyRequested_State;
break;
}
}
@@ -84,7 +87,7 @@ void android_main(struct android_app* state) {
"(Ljava/lang/String;)Ljava/lang/String;");
jstring jsParam1 = (jstring)env->CallObjectMethod(intent, gseid,
- env->NewStringUTF("cmdLineArguments"));
+ env->NewStringUTF("cmdLineFlags"));
if (jsParam1) {
const char* flags = env->GetStringUTFChars(jsParam1, 0);
SkTArray<SkString> flagEntries;
@@ -108,21 +111,25 @@ void android_main(struct android_app* state) {
// Check if we are exiting.
if (state->destroyRequested != 0) {
- SkDELETE(visualBenchState.fWindow);
- application_term();
return;
}
+
}
if (visualBenchState.fWindow) {
if (visualBenchState.fWindow->destroyRequested()) {
- SkDELETE(visualBenchState.fWindow);
- visualBenchState.fWindow = NULL;
- application_term();
- break;
+ visualBenchState.fState = kDestroyRequested_State;
+ } else {
+ visualBenchState.fWindow->update(NULL);
}
- visualBenchState.fWindow->update(NULL);
+ }
+
+ if (kDestroyRequested_State == visualBenchState.fState) {
+ SkDELETE(visualBenchState.fWindow);
+ visualBenchState.fWindow = NULL;
+ application_term();
+ ANativeActivity_finish(state->activity);
+ visualBenchState.fState = kFinished_State;
}
}
- ANativeActivity_finish(state->activity);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698