| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 | 9 |
| 10 #ifndef HelloWorld_DEFINED | 10 #ifndef HelloWorld_DEFINED |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 }; | 26 }; |
| 27 HelloWorldWindow(void* hwnd); | 27 HelloWorldWindow(void* hwnd); |
| 28 virtual ~HelloWorldWindow() override; | 28 virtual ~HelloWorldWindow() override; |
| 29 | 29 |
| 30 // Changes the device type of the object. | 30 // Changes the device type of the object. |
| 31 bool setUpBackend(); | 31 bool setUpBackend(); |
| 32 | 32 |
| 33 DeviceType getDeviceType() const { return fType; } | 33 DeviceType getDeviceType() const { return fType; } |
| 34 | 34 |
| 35 protected: | 35 protected: |
| 36 SkSurface* createSurface() override { | 36 sk_sp<SkSurface> makeSurface() override { |
| 37 SkSurfaceProps props(INHERITED::getSurfaceProps()); | 37 SkSurfaceProps props(INHERITED::getSurfaceProps()); |
| 38 if (kGPU_DeviceType == fType) { | 38 if (kGPU_DeviceType == fType) { |
| 39 return SkSurface::MakeRenderTargetDirect(fRenderTarget, nullptr, &pr
ops).release(); | 39 return fGpuSurface; |
| 40 } | 40 } |
| 41 static const SkImageInfo info = SkImageInfo::MakeN32Premul( | 41 const SkImageInfo info = SkImageInfo::MakeN32Premul(SkScalarRoundToInt(t
his->width()), |
| 42 SkScalarRoundToInt(this->width()), SkScalarRoundToInt(this->heig
ht())); | 42 SkScalarRoundToInt(t
his->height())); |
| 43 return fSurface = SkSurface::MakeRaster(info, &props).release(); | 43 fRasterSurface = SkSurface::MakeRaster(info, &props); |
| 44 return fRasterSurface; |
| 44 } | 45 } |
| 45 | 46 |
| 46 void draw(SkCanvas* canvas) override; | 47 void draw(SkCanvas* canvas) override; |
| 47 void drawContents(SkCanvas* canvas); | 48 void drawContents(SkCanvas* canvas); |
| 48 | 49 |
| 49 void onSizeChange() override; | 50 void onSizeChange() override; |
| 50 | 51 |
| 51 private: | 52 private: |
| 52 bool findNextMatch(); // Set example to the first one that matches FLAGS_ma
tch. | 53 bool findNextMatch(); // Set example to the first one that matches FLAGS_ma
tch. |
| 53 void setTitle(); | 54 void setTitle(); |
| 54 void setUpRenderTarget(); | 55 void setUpGpuBackedSurface(); |
| 55 bool onHandleChar(SkUnichar unichar) override; | 56 bool onHandleChar(SkUnichar unichar) override; |
| 56 void tearDownBackend(); | 57 void tearDownBackend(); |
| 57 | 58 |
| 58 // draw contents | 59 // draw contents |
| 59 SkScalar fRotationAngle; | 60 SkScalar fRotationAngle; |
| 60 | 61 |
| 61 // support framework | 62 // support framework |
| 62 DeviceType fType; | 63 DeviceType fType; |
| 63 SkSurface* fSurface; | 64 sk_sp<SkSurface> fRasterSurface; |
| 64 GrContext* fContext; | 65 GrContext* fContext; |
| 65 GrRenderTarget* fRenderTarget; | 66 sk_sp<SkSurface> fGpuSurface; |
| 66 AttachmentInfo fAttachmentInfo; | 67 AttachmentInfo fAttachmentInfo; |
| 67 const GrGLInterface* fInterface; | 68 const GrGLInterface* fInterface; |
| 68 | 69 |
| 69 typedef SkOSWindow INHERITED; | 70 typedef SkOSWindow INHERITED; |
| 70 }; | 71 }; |
| 71 | 72 |
| 72 #endif | 73 #endif |
| OLD | NEW |