| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
| 3 * | 3 * |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 * | 7 * |
| 8 */ | 8 */ |
| 9 #include <v8.h> | 9 #include <v8.h> |
| 10 #include <include/libplatform/libplatform.h> | 10 #include <include/libplatform/libplatform.h> |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 void application_term() { | 41 void application_term() { |
| 42 SkEvent::Term(); | 42 SkEvent::Term(); |
| 43 } | 43 } |
| 44 | 44 |
| 45 SkV8ExampleWindow::SkV8ExampleWindow(void* hwnd, JsContext* context) | 45 SkV8ExampleWindow::SkV8ExampleWindow(void* hwnd, JsContext* context) |
| 46 : INHERITED(hwnd) | 46 : INHERITED(hwnd) |
| 47 , fJsContext(context) | 47 , fJsContext(context) |
| 48 #if SK_SUPPORT_GPU | 48 #if SK_SUPPORT_GPU |
| 49 , fCurContext(NULL) | 49 , fCurContext(NULL) |
| 50 , fCurIntf(NULL) | 50 , fCurIntf(NULL) |
| 51 , fCurRenderTarget(NULL) | |
| 52 , fCurSurface(NULL) | 51 , fCurSurface(NULL) |
| 53 #endif | 52 #endif |
| 54 { | 53 { |
| 55 this->setVisibleP(true); | 54 this->setVisibleP(true); |
| 56 this->setClipToBounds(false); | 55 this->setClipToBounds(false); |
| 57 | 56 |
| 58 #if SK_SUPPORT_GPU | 57 #if SK_SUPPORT_GPU |
| 59 this->windowSizeChanged(); | 58 this->windowSizeChanged(); |
| 60 #endif | 59 #endif |
| 61 } | 60 } |
| 62 | 61 |
| 63 SkV8ExampleWindow::~SkV8ExampleWindow() { | 62 SkV8ExampleWindow::~SkV8ExampleWindow() { |
| 64 #if SK_SUPPORT_GPU | 63 #if SK_SUPPORT_GPU |
| 65 SkSafeUnref(fCurContext); | 64 SkSafeUnref(fCurContext); |
| 66 SkSafeUnref(fCurIntf); | 65 SkSafeUnref(fCurIntf); |
| 67 SkSafeUnref(fCurRenderTarget); | |
| 68 SkSafeUnref(fCurSurface); | 66 SkSafeUnref(fCurSurface); |
| 69 #endif | 67 #endif |
| 70 } | 68 } |
| 71 | 69 |
| 72 #if SK_SUPPORT_GPU | 70 #if SK_SUPPORT_GPU |
| 73 void SkV8ExampleWindow::windowSizeChanged() { | 71 void SkV8ExampleWindow::windowSizeChanged() { |
| 74 if (FLAGS_gpu) { | 72 if (FLAGS_gpu) { |
| 75 SkOSWindow::AttachmentInfo attachmentInfo; | 73 SkOSWindow::AttachmentInfo attachmentInfo; |
| 76 bool result = this->attach( | 74 bool result = this->attach( |
| 77 SkOSWindow::kNativeGL_BackEndType, 0, false, &attachmentInfo); | 75 SkOSWindow::kNativeGL_BackEndType, 0, false, &attachmentInfo); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 92 desc.fWidth = SkScalarRoundToInt(this->width()); | 90 desc.fWidth = SkScalarRoundToInt(this->width()); |
| 93 desc.fHeight = SkScalarRoundToInt(this->height()); | 91 desc.fHeight = SkScalarRoundToInt(this->height()); |
| 94 desc.fConfig = kSkia8888_GrPixelConfig; | 92 desc.fConfig = kSkia8888_GrPixelConfig; |
| 95 desc.fOrigin = kBottomLeft_GrSurfaceOrigin; | 93 desc.fOrigin = kBottomLeft_GrSurfaceOrigin; |
| 96 desc.fSampleCnt = attachmentInfo.fSampleCount; | 94 desc.fSampleCnt = attachmentInfo.fSampleCount; |
| 97 desc.fStencilBits = attachmentInfo.fStencilBits; | 95 desc.fStencilBits = attachmentInfo.fStencilBits; |
| 98 GrGLint buffer; | 96 GrGLint buffer; |
| 99 GR_GL_GetIntegerv(fCurIntf, GR_GL_FRAMEBUFFER_BINDING, &buffer); | 97 GR_GL_GetIntegerv(fCurIntf, GR_GL_FRAMEBUFFER_BINDING, &buffer); |
| 100 desc.fRenderTargetHandle = buffer; | 98 desc.fRenderTargetHandle = buffer; |
| 101 | 99 |
| 102 SkSafeUnref(fCurRenderTarget); | |
| 103 fCurRenderTarget = fCurContext->wrapBackendRenderTarget(desc); | |
| 104 SkSafeUnref(fCurSurface); | 100 SkSafeUnref(fCurSurface); |
| 105 fCurSurface = SkSurface::NewRenderTargetDirect(fCurRenderTarget); | 101 fCurSurface = SkSurface::MakeFromBackendRenderTarget(fCurContext, desc, |
| 102 nullptr, nullptr).r
elease(); |
| 106 } | 103 } |
| 107 } | 104 } |
| 108 #endif | 105 #endif |
| 109 | 106 |
| 110 #if SK_SUPPORT_GPU | 107 #if SK_SUPPORT_GPU |
| 111 SkSurface* SkV8ExampleWindow::createSurface() { | 108 SkSurface* SkV8ExampleWindow::createSurface() { |
| 112 if (FLAGS_gpu) { | 109 if (FLAGS_gpu) { |
| 113 // Increase the ref count since callers of createSurface put the | 110 // Increase the ref count since callers of createSurface put the |
| 114 // results in a SkAutoTUnref. | 111 // results in a SkAutoTUnref. |
| 115 fCurSurface->ref(); | 112 fCurSurface->ref(); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 | 222 |
| 226 if (!jsContext->initialize()) { | 223 if (!jsContext->initialize()) { |
| 227 printf("Failed to initialize.\n"); | 224 printf("Failed to initialize.\n"); |
| 228 exit(1); | 225 exit(1); |
| 229 } | 226 } |
| 230 SkV8ExampleWindow* win = new SkV8ExampleWindow(hwnd, jsContext); | 227 SkV8ExampleWindow* win = new SkV8ExampleWindow(hwnd, jsContext); |
| 231 global->setWindow(win); | 228 global->setWindow(win); |
| 232 | 229 |
| 233 return win; | 230 return win; |
| 234 } | 231 } |
| OLD | NEW |