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

Side by Side Diff: experimental/iOSSampleApp/SkSampleUIView.mm

Issue 12437010: Make SkOSWindow return the sample count and stencil bit count for its GL context. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Make SkOSWindow return the sample count and stencil bit count for its GL context. Created 7 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #import "SkSampleUIView.h" 1 #import "SkSampleUIView.h"
2 2
3 //#define SKWIND_CONFIG SkBitmap::kRGB_565_Config 3 //#define SKWIND_CONFIG SkBitmap::kRGB_565_Config
4 #define SKWIND_CONFIG SkBitmap::kARGB_8888_Config 4 #define SKWIND_CONFIG SkBitmap::kARGB_8888_Config
5 #define SKGL_CONFIG kEAGLColorFormatRGB565 5 #define SKGL_CONFIG kEAGLColorFormatRGB565
6 //#define SKGL_CONFIG kEAGLColorFormatRGBA8 6 //#define SKGL_CONFIG kEAGLColorFormatRGBA8
7 7
8 #define FORCE_REDRAW 8 #define FORCE_REDRAW
9 9
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 break; 54 break;
55 // these guys use the native backend 55 // these guys use the native backend
56 case SampleWindow::kGPU_DeviceType: 56 case SampleWindow::kGPU_DeviceType:
57 case SampleWindow::kNullGPU_DeviceType: 57 case SampleWindow::kNullGPU_DeviceType:
58 fBackend = SkOSWindow::kNativeGL_BackEndType; 58 fBackend = SkOSWindow::kNativeGL_BackEndType;
59 break; 59 break;
60 default: 60 default:
61 SkASSERT(false); 61 SkASSERT(false);
62 break; 62 break;
63 } 63 }
64 64 SkOSWindow::AttachmentInfo info;
65 bool result = win->attach(fBackend, msaaSampleCount); 65 bool result = win->attach(fBackend, msaaSampleCount, &info);
66 if (!result) { 66 if (!result) {
67 SkDebugf("Failed to initialize GL"); 67 SkDebugf("Failed to initialize GL");
68 return; 68 return;
69 } 69 }
70 fMSAASampleCount = msaaSampleCount; 70 fMSAASampleCount = msaaSampleCount;
71 71
72 SkASSERT(NULL == fCurIntf); 72 SkASSERT(NULL == fCurIntf);
73 switch (win->getDeviceType()) { 73 switch (win->getDeviceType()) {
74 // these two don't use GL 74 // these two don't use GL
75 case SampleWindow::kRaster_DeviceType: 75 case SampleWindow::kRaster_DeviceType:
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 if (NULL != fCurContext) { 158 if (NULL != fCurContext) {
159 fCurContext->flush(); 159 fCurContext->flush();
160 } 160 }
161 #endif 161 #endif
162 win->present(); 162 win->present();
163 } 163 }
164 164
165 virtual void windowSizeChanged(SampleWindow* win) SK_OVERRIDE { 165 virtual void windowSizeChanged(SampleWindow* win) SK_OVERRIDE {
166 #if SK_SUPPORT_GPU 166 #if SK_SUPPORT_GPU
167 if (NULL != fCurContext) { 167 if (NULL != fCurContext) {
168 win->attach(fBackend, fMSAASampleCount); 168 SkOSWindow::AttachmentInfo info;
169
170 win->attach(fBackend, fMSAASampleCount, &info);
169 171
170 glBindFramebuffer(GL_FRAMEBUFFER, fLayerFBO); 172 glBindFramebuffer(GL_FRAMEBUFFER, fLayerFBO);
171 GrBackendRenderTargetDesc desc; 173 GrBackendRenderTargetDesc desc;
172 desc.fWidth = SkScalarRound(win->width()); 174 desc.fWidth = SkScalarRound(win->width());
173 desc.fHeight = SkScalarRound(win->height()); 175 desc.fHeight = SkScalarRound(win->height());
174 desc.fConfig = kSkia8888_GrPixelConfig; 176 desc.fConfig = kSkia8888_GrPixelConfig;
175 desc.fRenderTargetHandle = fLayerFBO; 177 desc.fRenderTargetHandle = fLayerFBO;
176 glGetIntegerv(GL_SAMPLES, &desc.fSampleCnt); 178 desc.fSampleCnt = info.fSampleCount;
177 glGetIntegerv(GL_STENCIL_BITS, &desc.fStencilBits); 179 desc.fStencilBits = info.fStencilBits;
178 180
179 SkSafeUnref(fCurRenderTarget); 181 SkSafeUnref(fCurRenderTarget);
180 fCurRenderTarget = fCurContext->wrapBackendRenderTarget(desc); 182 fCurRenderTarget = fCurContext->wrapBackendRenderTarget(desc);
181 } 183 }
182 #endif 184 #endif
183 } 185 }
184 186
185 virtual GrContext* getGrContext() SK_OVERRIDE { 187 virtual GrContext* getGrContext() SK_OVERRIDE {
186 #if SK_SUPPORT_GPU 188 #if SK_SUPPORT_GPU
187 return fCurContext; 189 return fCurContext;
188 #else 190 #else
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 if (gl) { 475 if (gl) {
474 [self performSelector:@selector(drawInGL) withObject:nil afterDelay: 0]; 476 [self performSelector:@selector(drawInGL) withObject:nil afterDelay: 0];
475 } 477 }
476 else { 478 else {
477 [self performSelector:@selector(drawInRaster) withObject:nil afterDe lay:0]; 479 [self performSelector:@selector(drawInRaster) withObject:nil afterDe lay:0];
478 [self setNeedsDisplay]; 480 [self setNeedsDisplay];
479 } 481 }
480 } 482 }
481 } 483 }
482 484
485 - (void)getAttachmentInfo:(SkOSWindow::AttachmentInfo*)info {
486 glBindRenderbuffer(GL_RENDERBUFFER, fGL.fRenderbuffer);
487 glGetRenderbufferParameteriv(GL_RENDERBUFFER,
488 GL_RENDERBUFFER_STENCIL_SIZE,
489 &info->fStencilBits);
490 glGetRenderbufferParameteriv(GL_RENDERBUFFER,
491 GL_RENDERBUFFER_SAMPLES_APPLE,
492 &info->fSampleCount);
493 }
494
483 @end 495 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698