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

Unified Diff: runtime/embedders/openglui/common/graphics_handler.cc

Issue 12340036: Android improvements: (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 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: runtime/embedders/openglui/common/graphics_handler.cc
===================================================================
--- runtime/embedders/openglui/common/graphics_handler.cc (revision 18917)
+++ runtime/embedders/openglui/common/graphics_handler.cc (working copy)
@@ -9,15 +9,40 @@
extern void CheckGLError(const char *function);
GraphicsHandler* graphics;
+extern CanvasContext* display_context;
-GraphicsHandler::GraphicsHandler()
- : ag(),
+GraphicsHandler::GraphicsHandler(const char* resource_path)
+ : resource_path_(resource_path),
+ ag(),
grcontext(NULL),
width_(0),
height_(0) {
graphics = this;
+ DecoderHack(0, NULL);
}
+void GraphicsHandler::DecoderHack(int x, SkStream* s) {
+ if (x) { // hack to keep the linker from throwing these out
+ extern SkImageDecoder* sk_libpng_dfactory(SkStream* s);
+ sk_libpng_dfactory(s);
+
+ // TODO(gram): For some reason I get linker errors on these, even though
+ // they are defined in libskia_images. Figure out why...
+ /*
+ extern SkImageDecoder* sk_libjpeg_dfactory(SkStream* s);
+ extern SkImageDecoder* sk_libbmp_dfactory(SkStream* s);
+ extern SkImageDecoder* sk_libgif_dfactory(SkStream* s);
+ extern SkImageDecoder* sk_libico_dfactory(SkStream* s);
+ extern SkImageDecoder* sk_libwbmp_dfactory(SkStream* s);
+ sk_libjpeg_dfactory(s);
+ sk_libbmp_dfactory(s);
+ sk_libgif_dfactory(s);
+ sk_libico_dfactory(s);
+ sk_libwbmp_dfactory(s);
+ */
+ }
+}
+
// Kludge to get around an issue with Android emulator, which returns
// NULL for the shader language version, causing Skia to blow up.
const GrGLubyte* myGLGetString(GLenum name) {
@@ -31,7 +56,6 @@
}
int32_t GraphicsHandler::Start() {
- SkGraphics::Init();
GrGLInterface* fGL = const_cast<GrGLInterface*>(GrGLCreateNativeInterface());
LOGI("Created native interface %s\n", fGL ? "succeeded" : "failed");
fGL->fGetString = myGLGetString;
@@ -41,7 +65,10 @@
}
void GraphicsHandler::Stop() {
- SkGraphics::Term();
+ LOGI("Releasing display context");
+ FreeContexts();
+ grcontext->unref();
+ grcontext = NULL;
}
SkCanvas* GraphicsHandler::CreateDisplayCanvas() {
@@ -82,15 +109,12 @@
}
int32_t GraphicsHandler::Update() {
- extern CanvasContext* display_context;
- if (display_context != NULL) {
+ if (display_context != NULL && display_context->isDirty()) {
LOGI("Flushing display context\n");
display_context->Flush();
+ SwapBuffers();
+ display_context->clearDirty();
}
- SwapBuffers();
return 0;
}
-
-
-
« no previous file with comments | « runtime/embedders/openglui/common/graphics_handler.h ('k') | runtime/embedders/openglui/common/lifecycle_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698