OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 #include "SkWindow.h" | 8 #include "SkWindow.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkOSMenu.h" | 10 #include "SkOSMenu.h" |
11 #include "SkSurface.h" | 11 #include "SkSurface.h" |
12 #include "SkSystemEventTypes.h" | 12 #include "SkSystemEventTypes.h" |
13 #include "SkTime.h" | 13 #include "SkTime.h" |
14 | 14 |
15 #define SK_EventDelayInval "\xd" "n" "\xa" "l" | 15 #define SK_EventDelayInval "\xd" "n" "\xa" "l" |
16 | 16 |
17 SkWindow::SkWindow() | 17 SkWindow::SkWindow() |
18 : fSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType) | 18 : fSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType) |
19 , fFocusView(nullptr) | 19 , fFocusView(nullptr) |
20 { | 20 { |
21 fClicks.reset(); | 21 fClicks.reset(); |
22 fWaitingOnInval = false; | 22 fWaitingOnInval = false; |
23 fColorType = kN32_SkColorType; | |
24 fMatrix.reset(); | 23 fMatrix.reset(); |
25 } | 24 } |
26 | 25 |
27 SkWindow::~SkWindow() { | 26 SkWindow::~SkWindow() { |
28 fClicks.deleteAll(); | 27 fClicks.deleteAll(); |
29 fMenus.deleteAll(); | 28 fMenus.deleteAll(); |
30 } | 29 } |
31 | 30 |
32 SkSurface* SkWindow::createSurface() { | 31 SkSurface* SkWindow::createSurface() { |
33 const SkBitmap& bm = this->getBitmap(); | 32 const SkBitmap& bm = this->getBitmap(); |
(...skipping 12 matching lines...) Expand all Loading... |
46 m.setConcat(fMatrix, matrix); | 45 m.setConcat(fMatrix, matrix); |
47 this->setMatrix(m); | 46 this->setMatrix(m); |
48 } | 47 } |
49 | 48 |
50 void SkWindow::postConcat(const SkMatrix& matrix) { | 49 void SkWindow::postConcat(const SkMatrix& matrix) { |
51 SkMatrix m; | 50 SkMatrix m; |
52 m.setConcat(matrix, fMatrix); | 51 m.setConcat(matrix, fMatrix); |
53 this->setMatrix(m); | 52 this->setMatrix(m); |
54 } | 53 } |
55 | 54 |
56 void SkWindow::setColorType(SkColorType ct) { | 55 void SkWindow::resize(int width, int height) { |
57 this->resize(fBitmap.width(), fBitmap.height(), ct); | 56 if (width != fBitmap.width() || height != fBitmap.height()) { |
58 } | 57 fBitmap.allocPixels(SkImageInfo::Make(width, height, kN32_SkColorType, |
59 | 58 kPremul_SkAlphaType)); |
60 void SkWindow::resize(int width, int height, SkColorType ct) { | |
61 if (ct == kUnknown_SkColorType) | |
62 ct = fColorType; | |
63 | |
64 if (width != fBitmap.width() || height != fBitmap.height() || ct != fColorTy
pe) { | |
65 fColorType = ct; | |
66 fBitmap.allocPixels(SkImageInfo::Make(width, height, | |
67 ct, kPremul_SkAlphaType)); | |
68 | |
69 this->setSize(SkIntToScalar(width), SkIntToScalar(height)); | |
70 this->inval(nullptr); | 59 this->inval(nullptr); |
71 } | 60 } |
| 61 this->setSize(SkIntToScalar(width), SkIntToScalar(height)); |
72 } | 62 } |
73 | 63 |
74 bool SkWindow::handleInval(const SkRect* localR) { | 64 bool SkWindow::handleInval(const SkRect* localR) { |
75 SkIRect ir; | 65 SkIRect ir; |
76 | 66 |
77 if (localR) { | 67 if (localR) { |
78 SkRect devR; | 68 SkRect devR; |
79 SkMatrix inverse; | 69 SkMatrix inverse; |
80 if (!fMatrix.invert(&inverse)) { | 70 if (!fMatrix.invert(&inverse)) { |
81 return false; | 71 return false; |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 desc.fOrigin = kBottomLeft_GrSurfaceOrigin; | 320 desc.fOrigin = kBottomLeft_GrSurfaceOrigin; |
331 desc.fSampleCnt = attachmentInfo.fSampleCount; | 321 desc.fSampleCnt = attachmentInfo.fSampleCount; |
332 desc.fStencilBits = attachmentInfo.fStencilBits; | 322 desc.fStencilBits = attachmentInfo.fStencilBits; |
333 GrGLint buffer; | 323 GrGLint buffer; |
334 GR_GL_GetIntegerv(interface, GR_GL_FRAMEBUFFER_BINDING, &buffer); | 324 GR_GL_GetIntegerv(interface, GR_GL_FRAMEBUFFER_BINDING, &buffer); |
335 desc.fRenderTargetHandle = buffer; | 325 desc.fRenderTargetHandle = buffer; |
336 return grContext->textureProvider()->wrapBackendRenderTarget(desc); | 326 return grContext->textureProvider()->wrapBackendRenderTarget(desc); |
337 } | 327 } |
338 | 328 |
339 #endif | 329 #endif |
OLD | NEW |