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" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 fBitmap.allocPixels(info); | 60 fBitmap.allocPixels(info); |
61 this->inval(nullptr); | 61 this->inval(nullptr); |
62 } | 62 } |
63 this->setSize(SkIntToScalar(fBitmap.width()), SkIntToScalar(fBitmap.height()
)); | 63 this->setSize(SkIntToScalar(fBitmap.width()), SkIntToScalar(fBitmap.height()
)); |
64 } | 64 } |
65 | 65 |
66 void SkWindow::resize(int width, int height) { | 66 void SkWindow::resize(int width, int height) { |
67 this->resize(fBitmap.info().makeWH(width, height)); | 67 this->resize(fBitmap.info().makeWH(width, height)); |
68 } | 68 } |
69 | 69 |
70 void SkWindow::setColorType(SkColorType ct, sk_sp<SkColorSpace> cs) { | 70 void SkWindow::setColorType(SkColorType ct, SkColorProfileType pt) { |
71 const SkImageInfo& info = fBitmap.info(); | 71 const SkImageInfo& info = fBitmap.info(); |
72 this->resize(SkImageInfo::Make(info.width(), info.height(), ct, kPremul_SkAl
phaType, cs)); | 72 this->resize(SkImageInfo::Make(info.width(), info.height(), ct, kPremul_SkAl
phaType, pt)); |
73 | 73 |
74 // Set the global flag that enables or disables "legacy" mode, depending on
our format. | 74 // Set the global flag that enables or disables "legacy" mode, depending on
our format. |
75 // With sRGB 32-bit or linear FP 16, we turn on gamma-correct handling of in
puts: | 75 // With sRGB 32-bit or linear FP 16, we turn on gamma-correct handling of in
puts: |
76 SkSurfaceProps props = this->getSurfaceProps(); | 76 SkSurfaceProps props = this->getSurfaceProps(); |
77 uint32_t flags = (props.flags() & ~SkSurfaceProps::kGammaCorrect_Flag) | | 77 uint32_t flags = (props.flags() & ~SkSurfaceProps::kGammaCorrect_Flag) | |
78 (SkColorAndColorSpaceAreGammaCorrect(ct, cs.get()) | 78 (SkColorAndProfileAreGammaCorrect(ct, pt) ? SkSurfaceProps::kGammaCorrec
t_Flag : 0); |
79 ? SkSurfaceProps::kGammaCorrect_Flag : 0); | |
80 this->setSurfaceProps(SkSurfaceProps(flags, props.pixelGeometry())); | 79 this->setSurfaceProps(SkSurfaceProps(flags, props.pixelGeometry())); |
81 } | 80 } |
82 | 81 |
83 bool SkWindow::handleInval(const SkRect* localR) { | 82 bool SkWindow::handleInval(const SkRect* localR) { |
84 SkIRect ir; | 83 SkIRect ir; |
85 | 84 |
86 if (localR) { | 85 if (localR) { |
87 SkRect devR; | 86 SkRect devR; |
88 SkMatrix inverse; | 87 SkMatrix inverse; |
89 if (!fMatrix.invert(&inverse)) { | 88 if (!fMatrix.invert(&inverse)) { |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 desc.fOrigin = kBottomLeft_GrSurfaceOrigin; | 351 desc.fOrigin = kBottomLeft_GrSurfaceOrigin; |
353 desc.fSampleCnt = attachmentInfo.fSampleCount; | 352 desc.fSampleCnt = attachmentInfo.fSampleCount; |
354 desc.fStencilBits = attachmentInfo.fStencilBits; | 353 desc.fStencilBits = attachmentInfo.fStencilBits; |
355 GrGLint buffer; | 354 GrGLint buffer; |
356 GR_GL_GetIntegerv(interface, GR_GL_FRAMEBUFFER_BINDING, &buffer); | 355 GR_GL_GetIntegerv(interface, GR_GL_FRAMEBUFFER_BINDING, &buffer); |
357 desc.fRenderTargetHandle = buffer; | 356 desc.fRenderTargetHandle = buffer; |
358 return grContext->textureProvider()->wrapBackendRenderTarget(desc); | 357 return grContext->textureProvider()->wrapBackendRenderTarget(desc); |
359 } | 358 } |
360 | 359 |
361 #endif | 360 #endif |
OLD | NEW |