OLD | NEW |
1 #import "SkSampleUIView.h" | 1 #import "SkSampleUIView.h" |
2 | 2 |
3 #define SKGL_CONFIG kEAGLColorFormatRGB565 | 3 #define SKGL_CONFIG kEAGLColorFormatRGB565 |
4 //#define SKGL_CONFIG kEAGLColorFormatRGBA8 | 4 //#define SKGL_CONFIG kEAGLColorFormatRGBA8 |
5 | 5 |
6 #define FORCE_REDRAW | 6 #define FORCE_REDRAW |
7 | 7 |
8 #include "SkCanvas.h" | 8 #include "SkCanvas.h" |
9 #include "SkCGUtils.h" | 9 #include "SkCGUtils.h" |
10 #include "SkSurface.h" | 10 #include "SkSurface.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 } | 33 } |
34 | 34 |
35 virtual ~SkiOSDeviceManager() { | 35 virtual ~SkiOSDeviceManager() { |
36 #if SK_SUPPORT_GPU | 36 #if SK_SUPPORT_GPU |
37 SkSafeUnref(fCurContext); | 37 SkSafeUnref(fCurContext); |
38 SkSafeUnref(fCurIntf); | 38 SkSafeUnref(fCurIntf); |
39 SkSafeUnref(fCurRenderTarget); | 39 SkSafeUnref(fCurRenderTarget); |
40 #endif | 40 #endif |
41 } | 41 } |
42 | 42 |
43 virtual void setUpBackend(SampleWindow* win, int msaaSampleCount) SK_OVERRID
E { | 43 void setUpBackend(SampleWindow* win, int msaaSampleCount) SK_OVERRIDE { |
44 SkASSERT(SkOSWindow::kNone_BackEndType == fBackend); | 44 SkASSERT(SkOSWindow::kNone_BackEndType == fBackend); |
45 | 45 |
46 fBackend = SkOSWindow::kNone_BackEndType; | 46 fBackend = SkOSWindow::kNone_BackEndType; |
47 | 47 |
48 #if SK_SUPPORT_GPU | 48 #if SK_SUPPORT_GPU |
49 switch (win->getDeviceType()) { | 49 switch (win->getDeviceType()) { |
50 // these two don't use GL | 50 // these two don't use GL |
51 case SampleWindow::kRaster_DeviceType: | 51 case SampleWindow::kRaster_DeviceType: |
52 case SampleWindow::kPicture_DeviceType: | 52 case SampleWindow::kPicture_DeviceType: |
53 break; | 53 break; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 SkSafeUnref(fCurContext); | 98 SkSafeUnref(fCurContext); |
99 SkSafeUnref(fCurIntf); | 99 SkSafeUnref(fCurIntf); |
100 SkDebugf("Failed to setup 3D"); | 100 SkDebugf("Failed to setup 3D"); |
101 win->detach(); | 101 win->detach(); |
102 } | 102 } |
103 #endif // SK_SUPPORT_GPU | 103 #endif // SK_SUPPORT_GPU |
104 // call windowSizeChanged to create the render target | 104 // call windowSizeChanged to create the render target |
105 this->windowSizeChanged(win); | 105 this->windowSizeChanged(win); |
106 } | 106 } |
107 | 107 |
108 virtual void tearDownBackend(SampleWindow *win) SK_OVERRIDE { | 108 void tearDownBackend(SampleWindow *win) SK_OVERRIDE { |
109 #if SK_SUPPORT_GPU | 109 #if SK_SUPPORT_GPU |
110 SkSafeUnref(fCurContext); | 110 SkSafeUnref(fCurContext); |
111 fCurContext = NULL; | 111 fCurContext = NULL; |
112 | 112 |
113 SkSafeUnref(fCurIntf); | 113 SkSafeUnref(fCurIntf); |
114 fCurIntf = NULL; | 114 fCurIntf = NULL; |
115 | 115 |
116 SkSafeUnref(fCurRenderTarget); | 116 SkSafeUnref(fCurRenderTarget); |
117 fCurRenderTarget = NULL; | 117 fCurRenderTarget = NULL; |
118 #endif | 118 #endif |
119 win->detach(); | 119 win->detach(); |
120 fBackend = SampleWindow::kNone_BackEndType; | 120 fBackend = SampleWindow::kNone_BackEndType; |
121 } | 121 } |
122 | 122 |
123 virtual SkSurface* createSurface(SampleWindow::DeviceType dType, SampleWindo
w* win) SK_OVERRIDE{ | 123 SkSurface* createSurface(SampleWindow::DeviceType dType, SampleWindow* win)
SK_OVERRIDE{ |
124 #if SK_SUPPORT_GPU | 124 #if SK_SUPPORT_GPU |
125 if (SampleWindow::IsGpuDeviceType(dType) && fCurContext) { | 125 if (SampleWindow::IsGpuDeviceType(dType) && fCurContext) { |
126 SkSurfaceProps props(win->getSurfaceProps()); | 126 SkSurfaceProps props(win->getSurfaceProps()); |
127 return SkSurface::NewRenderTargetDirect(fCurRenderTarget, &props); | 127 return SkSurface::NewRenderTargetDirect(fCurRenderTarget, &props); |
128 } | 128 } |
129 #endif | 129 #endif |
130 return NULL; | 130 return NULL; |
131 } | 131 } |
132 | 132 |
133 virtual void publishCanvas(SampleWindow::DeviceType dType, | 133 virtual void publishCanvas(SampleWindow::DeviceType dType, |
134 SkCanvas* canvas, | 134 SkCanvas* canvas, |
135 SampleWindow* win) SK_OVERRIDE { | 135 SampleWindow* win) SK_OVERRIDE { |
136 #if SK_SUPPORT_GPU | 136 #if SK_SUPPORT_GPU |
137 if (NULL != fCurContext) { | 137 if (NULL != fCurContext) { |
138 fCurContext->flush(); | 138 fCurContext->flush(); |
139 } | 139 } |
140 #endif | 140 #endif |
141 win->present(); | 141 win->present(); |
142 } | 142 } |
143 | 143 |
144 virtual void windowSizeChanged(SampleWindow* win) SK_OVERRIDE { | 144 void windowSizeChanged(SampleWindow* win) SK_OVERRIDE { |
145 #if SK_SUPPORT_GPU | 145 #if SK_SUPPORT_GPU |
146 if (NULL != fCurContext) { | 146 if (NULL != fCurContext) { |
147 SkOSWindow::AttachmentInfo info; | 147 SkOSWindow::AttachmentInfo info; |
148 | 148 |
149 win->attach(fBackend, fMSAASampleCount, &info); | 149 win->attach(fBackend, fMSAASampleCount, &info); |
150 | 150 |
151 glBindFramebuffer(GL_FRAMEBUFFER, fLayerFBO); | 151 glBindFramebuffer(GL_FRAMEBUFFER, fLayerFBO); |
152 GrBackendRenderTargetDesc desc; | 152 GrBackendRenderTargetDesc desc; |
153 desc.fWidth = SkScalarRoundToInt(win->width()); | 153 desc.fWidth = SkScalarRoundToInt(win->width()); |
154 desc.fHeight = SkScalarRoundToInt(win->height()); | 154 desc.fHeight = SkScalarRoundToInt(win->height()); |
155 desc.fConfig = kSkia8888_GrPixelConfig; | 155 desc.fConfig = kSkia8888_GrPixelConfig; |
156 desc.fRenderTargetHandle = fLayerFBO; | 156 desc.fRenderTargetHandle = fLayerFBO; |
157 desc.fSampleCnt = info.fSampleCount; | 157 desc.fSampleCnt = info.fSampleCount; |
158 desc.fStencilBits = info.fStencilBits; | 158 desc.fStencilBits = info.fStencilBits; |
159 | 159 |
160 SkSafeUnref(fCurRenderTarget); | 160 SkSafeUnref(fCurRenderTarget); |
161 fCurRenderTarget = fCurContext->wrapBackendRenderTarget(desc); | 161 fCurRenderTarget = fCurContext->wrapBackendRenderTarget(desc); |
162 } | 162 } |
163 #endif | 163 #endif |
164 } | 164 } |
165 | 165 |
166 virtual GrContext* getGrContext() SK_OVERRIDE { | 166 GrContext* getGrContext() SK_OVERRIDE { |
167 #if SK_SUPPORT_GPU | 167 #if SK_SUPPORT_GPU |
168 return fCurContext; | 168 return fCurContext; |
169 #else | 169 #else |
170 return NULL; | 170 return NULL; |
171 #endif | 171 #endif |
172 } | 172 } |
173 | 173 |
174 virtual GrRenderTarget* getGrRenderTarget() SK_OVERRIDE { | 174 GrRenderTarget* getGrRenderTarget() SK_OVERRIDE { |
175 #if SK_SUPPORT_GPU | 175 #if SK_SUPPORT_GPU |
176 return fCurRenderTarget; | 176 return fCurRenderTarget; |
177 #else | 177 #else |
178 return NULL; | 178 return NULL; |
179 #endif | 179 #endif |
180 } | 180 } |
181 | 181 |
182 bool isUsingGL() const { return SkOSWindow::kNone_BackEndType != fBackend; } | 182 bool isUsingGL() const { return SkOSWindow::kNone_BackEndType != fBackend; } |
183 | 183 |
184 private: | 184 private: |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 glBindRenderbuffer(GL_RENDERBUFFER, fGL.fRenderbuffer); | 468 glBindRenderbuffer(GL_RENDERBUFFER, fGL.fRenderbuffer); |
469 glGetRenderbufferParameteriv(GL_RENDERBUFFER, | 469 glGetRenderbufferParameteriv(GL_RENDERBUFFER, |
470 GL_RENDERBUFFER_STENCIL_SIZE, | 470 GL_RENDERBUFFER_STENCIL_SIZE, |
471 &info->fStencilBits); | 471 &info->fStencilBits); |
472 glGetRenderbufferParameteriv(GL_RENDERBUFFER, | 472 glGetRenderbufferParameteriv(GL_RENDERBUFFER, |
473 GL_RENDERBUFFER_SAMPLES_APPLE, | 473 GL_RENDERBUFFER_SAMPLES_APPLE, |
474 &info->fSampleCount); | 474 &info->fSampleCount); |
475 } | 475 } |
476 | 476 |
477 @end | 477 @end |
OLD | NEW |