| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 * | 6 * |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include "GrContext.h" | 9 #include "GrContext.h" |
| 10 #include "SDL.h" | 10 #include "SDL.h" |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 GrBackendRenderTargetDesc desc; | 199 GrBackendRenderTargetDesc desc; |
| 200 desc.fWidth = dm.w; | 200 desc.fWidth = dm.w; |
| 201 desc.fHeight = dm.h; | 201 desc.fHeight = dm.h; |
| 202 desc.fConfig = kSkia8888_GrPixelConfig; | 202 desc.fConfig = kSkia8888_GrPixelConfig; |
| 203 desc.fOrigin = kBottomLeft_GrSurfaceOrigin; | 203 desc.fOrigin = kBottomLeft_GrSurfaceOrigin; |
| 204 desc.fSampleCnt = kMsaaSampleCount; | 204 desc.fSampleCnt = kMsaaSampleCount; |
| 205 desc.fStencilBits = kStencilBits; | 205 desc.fStencilBits = kStencilBits; |
| 206 GrGLint buffer; | 206 GrGLint buffer; |
| 207 GR_GL_GetIntegerv(interface, GR_GL_FRAMEBUFFER_BINDING, &buffer); | 207 GR_GL_GetIntegerv(interface, GR_GL_FRAMEBUFFER_BINDING, &buffer); |
| 208 desc.fRenderTargetHandle = buffer; | 208 desc.fRenderTargetHandle = buffer; |
| 209 SkAutoTUnref<GrRenderTarget> | |
| 210 renderTarget(grContext->textureProvider()->wrapBackendRenderTarget(d
esc)); | |
| 211 | 209 |
| 212 // setup SkSurface | 210 // setup SkSurface |
| 213 // To use distance field text, use commented out SkSurfaceProps instead | 211 // To use distance field text, use commented out SkSurfaceProps instead |
| 214 // SkSurfaceProps props(SkSurfaceProps::kUseDeviceIndependentFonts_Flag, | 212 // SkSurfaceProps props(SkSurfaceProps::kUseDeviceIndependentFonts_Flag, |
| 215 // SkSurfaceProps::kLegacyFontHost_InitType); | 213 // SkSurfaceProps::kLegacyFontHost_InitType); |
| 216 SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); | 214 SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); |
| 217 SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTargetDirect(renderTarge
t, &props)); | 215 |
| 216 sk_sp<SkSurface> surface(SkSurface::MakeFromBackendRenderTarget(grContext, d
esc, &props)); |
| 218 | 217 |
| 219 SkCanvas* canvas = surface->getCanvas(); | 218 SkCanvas* canvas = surface->getCanvas(); |
| 220 | 219 |
| 221 ApplicationState state; | 220 ApplicationState state; |
| 222 | 221 |
| 223 const char* helpMessage = "Click and drag to create rects. Press esc to qui
t."; | 222 const char* helpMessage = "Click and drag to create rects. Press esc to qui
t."; |
| 224 | 223 |
| 225 SkPaint paint; | 224 SkPaint paint; |
| 226 | 225 |
| 227 // create a surface for CPU rasterization | 226 // create a surface for CPU rasterization |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 SDL_GL_DeleteContext(glContext); | 263 SDL_GL_DeleteContext(glContext); |
| 265 } | 264 } |
| 266 | 265 |
| 267 //Destroy window | 266 //Destroy window |
| 268 SDL_DestroyWindow(window); | 267 SDL_DestroyWindow(window); |
| 269 | 268 |
| 270 //Quit SDL subsystems | 269 //Quit SDL subsystems |
| 271 SDL_Quit(); | 270 SDL_Quit(); |
| 272 return 0; | 271 return 0; |
| 273 } | 272 } |
| OLD | NEW |