iOS SampleApp menu related changes
git-svn-id: http://skia.googlecode.com/svn/trunk@2023 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
5987045388
commit
e938b19445
@ -44,15 +44,6 @@ class SkEvent;
|
||||
GLint fHeight;
|
||||
} fGL;
|
||||
|
||||
enum Backend {
|
||||
kGL_Backend,
|
||||
kRaster_Backend,
|
||||
};
|
||||
|
||||
// these are visible to DetailViewController
|
||||
Backend fBackend;
|
||||
bool fComplexClip;
|
||||
|
||||
UINavigationItem* fTitle;
|
||||
SkOSWindow* fWind;
|
||||
}
|
||||
|
@ -120,8 +120,8 @@ void GrGLSetDefaultGLInterface() {
|
||||
gDefaultInterface.fViewport = glViewport;
|
||||
|
||||
gDefaultInterface.fGenFramebuffers = glGenFramebuffers;
|
||||
gDefaultInterface.fGetFramebufferAttachmentParameteriv = glFramebufferAttachmentParameteriv;
|
||||
gDefaultInterface.fGetRenderbufferParameteriv = glRenderbufferParameteriv;
|
||||
gDefaultInterface.fGetFramebufferAttachmentParameteriv = glGetFramebufferAttachmentParameteriv;
|
||||
gDefaultInterface.fGetRenderbufferParameteriv = glGetRenderbufferParameteriv;
|
||||
gDefaultInterface.fBindFramebuffer = glBindFramebuffer;
|
||||
gDefaultInterface.fFramebufferTexture2D = glFramebufferTexture2D;
|
||||
gDefaultInterface.fCheckFramebufferStatus = glCheckFramebufferStatus;
|
||||
|
@ -9,14 +9,13 @@
|
||||
#define SkOSWindow_iOS_DEFINED
|
||||
|
||||
#include "SkWindow.h"
|
||||
#include "SkMatrix.h"
|
||||
|
||||
class SkOSWindow : public SkWindow {
|
||||
public:
|
||||
SkOSWindow(void* hwnd);
|
||||
~SkOSWindow();
|
||||
void* getHWND() const { return fHWND; }
|
||||
|
||||
static bool PostEvent(SkEvent* evt, SkEventSinkID, SkMSec delay);
|
||||
virtual bool onDispatchClick(int x, int y, Click::State state,
|
||||
void* owner);
|
||||
void detachGL();
|
||||
@ -30,6 +29,7 @@ protected:
|
||||
virtual void onHandleInval(const SkIRect&);
|
||||
// overrides from SkView
|
||||
virtual void onAddMenu(const SkOSMenu*);
|
||||
virtual void onUpdateMenu(const SkOSMenu*);
|
||||
virtual void onSetTitle(const char[]);
|
||||
|
||||
private:
|
||||
|
@ -1,9 +1,7 @@
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <OpenGLES/EAGL.h>
|
||||
#import <OpenGLES/ES1/gl.h>
|
||||
#include "SkCanvas.h"
|
||||
#include "SkGraphics.h"
|
||||
#import "SkIOSNotifier.h"
|
||||
#import "SkEventNotifier.h"
|
||||
#include "SkOSMenu.h"
|
||||
#include "SkTime.h"
|
||||
#include "SkTypes.h"
|
||||
@ -14,10 +12,10 @@
|
||||
|
||||
SkOSWindow::SkOSWindow(void* hWnd) : fHWND(hWnd) {
|
||||
fInvalEventIsPending = false;
|
||||
fNotifier = [[SkIOSNotifier alloc] init];
|
||||
fNotifier = [[SkEventNotifier alloc] init];
|
||||
}
|
||||
SkOSWindow::~SkOSWindow() {
|
||||
[(SkIOSNotifier*)fNotifier release];
|
||||
[(SkEventNotifier*)fNotifier release];
|
||||
}
|
||||
|
||||
void SkOSWindow::onHandleInval(const SkIRect& r) {
|
||||
@ -48,162 +46,20 @@ void SkOSWindow::onSetTitle(const char title[]) {
|
||||
[(SkUIView*)fHWND setSkTitle:title];
|
||||
}
|
||||
|
||||
void SkOSWindow::onAddMenu(const SkOSMenu* sk_menu) {
|
||||
|
||||
void SkOSWindow::onAddMenu(const SkOSMenu* menu) {
|
||||
[(SkUIView*)fHWND onAddMenu:menu];
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
/*
|
||||
#if 1
|
||||
static void NonEmptyCallback(CFRunLoopTimerRef timer, void*) {
|
||||
// printf("------- event queue depth = %d\n", SkEvent::CountEventsOnQueue());
|
||||
void SkOSWindow::onUpdateMenu(const SkOSMenu* menu) {
|
||||
[(SkUIView*)fHWND onUpdateMenu:menu];
|
||||
}
|
||||
|
||||
if (!SkEvent::ProcessEvent()) {
|
||||
CFRunLoopTimerInvalidate(timer);
|
||||
}
|
||||
}
|
||||
|
||||
void SkEvent::SignalNonEmptyQueue() {
|
||||
double tinyDelay = 1.0 / 60;
|
||||
CFRunLoopTimerRef timer;
|
||||
|
||||
timer = CFRunLoopTimerCreate(NULL,
|
||||
CACurrentMediaTime() + tinyDelay,
|
||||
tinyDelay,
|
||||
0,
|
||||
0,
|
||||
NonEmptyCallback,
|
||||
NULL);
|
||||
CFRunLoopAddTimer(CFRunLoopGetCurrent(),
|
||||
timer,
|
||||
kCFRunLoopCommonModes);
|
||||
CFRelease(timer);
|
||||
}
|
||||
#elif 1
|
||||
#if 0
|
||||
#define NONE_EMPTY_CODE(code) code
|
||||
#else
|
||||
#define NONE_EMPTY_CODE(code)
|
||||
#endif
|
||||
static CFRunLoopSourceRef gNonEmptySource;
|
||||
static CFRunLoopRef gNoneEmptyRunLoop;
|
||||
static bool gAlreadySignaled;
|
||||
|
||||
static void signal_nonempty() {
|
||||
if (!gAlreadySignaled) {
|
||||
NONE_EMPTY_CODE(printf("--- before resignal\n");)
|
||||
gAlreadySignaled = true;
|
||||
CFRunLoopSourceSignal(gNonEmptySource);
|
||||
CFRunLoopWakeUp(gNoneEmptyRunLoop);
|
||||
NONE_EMPTY_CODE(printf("--- after resignal\n");)
|
||||
}
|
||||
}
|
||||
|
||||
static void NonEmptySourceCallback(void*) {
|
||||
gAlreadySignaled = false;
|
||||
NONE_EMPTY_CODE(printf("---- service NonEmptySourceCallback %d\n", SkEvent::CountEventsOnQueue());)
|
||||
if (SkEvent::ProcessEvent()) {
|
||||
signal_nonempty();
|
||||
}
|
||||
NONE_EMPTY_CODE(printf("----- after service\n");)
|
||||
}
|
||||
|
||||
void SkEvent::SignalNonEmptyQueue() {
|
||||
if (NULL == gNonEmptySource) {
|
||||
gNoneEmptyRunLoop = CFRunLoopGetMain();
|
||||
|
||||
CFIndex order = 0; // should this be lower, to not start UIEvents?
|
||||
CFRunLoopSourceContext context;
|
||||
sk_bzero(&context, sizeof(context));
|
||||
// give it a "unique" info, for the default Hash function
|
||||
context.info = (void*)NonEmptySourceCallback;
|
||||
// our perform callback
|
||||
context.perform = NonEmptySourceCallback;
|
||||
gNonEmptySource = CFRunLoopSourceCreate(NULL, order, &context);
|
||||
|
||||
CFRunLoopAddSource(gNoneEmptyRunLoop,
|
||||
gNonEmptySource,
|
||||
kCFRunLoopCommonModes);
|
||||
}
|
||||
signal_nonempty();
|
||||
}
|
||||
#elif 1
|
||||
@interface NonEmptyHandler : NSObject {}
|
||||
- (void)signalNonEmptyQ;
|
||||
@end
|
||||
|
||||
@implementation NonEmptyHandler
|
||||
|
||||
- (void)callProccessEvent {
|
||||
// printf("----- callProcessEvent\n");
|
||||
if (SkEvent::ProcessEvent()) {
|
||||
[self signalNonEmptyQ];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)signalNonEmptyQ {
|
||||
[self performSelectorOnMainThread:@selector(callProccessEvent) withObject:nil waitUntilDone:NO];
|
||||
}
|
||||
|
||||
void SkEvent::SignalNonEmptyQueue() {
|
||||
static id gNonEmptyQueueObject;
|
||||
if (nil == gNonEmptyQueueObject) {
|
||||
gNonEmptyQueueObject = [[NonEmptyHandler alloc] init];
|
||||
}
|
||||
[gNonEmptyQueueObject signalNonEmptyQ];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static CFRunLoopTimerRef gTimer;
|
||||
|
||||
static void TimerCallback(CFRunLoopTimerRef timer, void* info) {
|
||||
gTimer = NULL;
|
||||
SkEvent::ServiceQueueTimer();
|
||||
}
|
||||
|
||||
void SkEvent::SignalQueueTimer(SkMSec delay)
|
||||
{
|
||||
//We always release the timer right after we've added it to our RunLoop,
|
||||
//thus we don't worry about freeing it later: if it fires our callback,
|
||||
//it gets automatically freed, as it does if we call invalidate()
|
||||
|
||||
if (gTimer) {
|
||||
// our callback wasn't called, so invalidate it
|
||||
CFRunLoopTimerInvalidate(gTimer);
|
||||
gTimer = NULL;
|
||||
}
|
||||
|
||||
if (delay) {
|
||||
gTimer = CFRunLoopTimerCreate(NULL,
|
||||
CACurrentMediaTime() + delay/1000.0,
|
||||
// CFAbsoluteTimeGetCurrent() + delay/1000.0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
TimerCallback,
|
||||
NULL);
|
||||
CFRunLoopAddTimer(CFRunLoopGetCurrent(),
|
||||
gTimer,
|
||||
kCFRunLoopCommonModes);
|
||||
CFRelease(gTimer);
|
||||
}
|
||||
}
|
||||
*/
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool SkOSWindow::attachGL()
|
||||
{
|
||||
bool SkOSWindow::attachGL() {
|
||||
bool success = true;
|
||||
return success;
|
||||
}
|
||||
|
||||
void SkOSWindow::detachGL() {
|
||||
}
|
||||
void SkOSWindow::detachGL() {}
|
||||
|
||||
void SkOSWindow::presentGL() {
|
||||
glFlush();
|
||||
|
Loading…
Reference in New Issue
Block a user