| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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, SkColorProfileType pt) { | 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, pt)); | 72 this->resize(SkImageInfo::Make(info.width(), info.height(), ct, kPremul_SkAl
phaType, pt)); |
| 73 |
| 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: |
| 76 SkSurfaceProps props = this->getSurfaceProps(); |
| 77 uint32_t flags = (props.flags() & ~SkSurfaceProps::kAllowSRGBInputs_Flag) | |
| 78 (SkColorAndProfileAreGammaCorrect(ct, pt) ? SkSurfaceProps::kAllowSRGBIn
puts_Flag : 0); |
| 79 this->setSurfaceProps(SkSurfaceProps(flags, props.pixelGeometry())); |
| 73 } | 80 } |
| 74 | 81 |
| 75 bool SkWindow::handleInval(const SkRect* localR) { | 82 bool SkWindow::handleInval(const SkRect* localR) { |
| 76 SkIRect ir; | 83 SkIRect ir; |
| 77 | 84 |
| 78 if (localR) { | 85 if (localR) { |
| 79 SkRect devR; | 86 SkRect devR; |
| 80 SkMatrix inverse; | 87 SkMatrix inverse; |
| 81 if (!fMatrix.invert(&inverse)) { | 88 if (!fMatrix.invert(&inverse)) { |
| 82 return false; | 89 return false; |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 const GrGLInterface* interface, GrContext* grContext) { | 333 const GrGLInterface* interface, GrContext* grContext) { |
| 327 GrBackendRenderTargetDesc desc; | 334 GrBackendRenderTargetDesc desc; |
| 328 desc.fWidth = SkScalarRoundToInt(this->width()); | 335 desc.fWidth = SkScalarRoundToInt(this->width()); |
| 329 desc.fHeight = SkScalarRoundToInt(this->height()); | 336 desc.fHeight = SkScalarRoundToInt(this->height()); |
| 330 // TODO: Query the actual framebuffer for sRGB capable. However, to | 337 // TODO: Query the actual framebuffer for sRGB capable. However, to |
| 331 // preserve old (fake-linear) behavior, we don't do this. Instead, rely | 338 // preserve old (fake-linear) behavior, we don't do this. Instead, rely |
| 332 // on the flag (currently driven via 'C' mode in SampleApp). | 339 // on the flag (currently driven via 'C' mode in SampleApp). |
| 333 // | 340 // |
| 334 // Also, we may not have real sRGB support (ANGLE, in particular), so check
for | 341 // Also, we may not have real sRGB support (ANGLE, in particular), so check
for |
| 335 // that, and fall back to L32: | 342 // that, and fall back to L32: |
| 336 desc.fConfig = grContext->caps()->srgbSupport() && | 343 desc.fConfig = grContext->caps()->srgbSupport() && SkImageInfoIsGammaCorrect
(info()) |
| 337 (info().profileType() == kSRGB_SkColorProfileType || | |
| 338 info().colorType() == kRGBA_F16_SkColorType) | |
| 339 ? kSkiaGamma8888_GrPixelConfig | 344 ? kSkiaGamma8888_GrPixelConfig |
| 340 : kSkia8888_GrPixelConfig; | 345 : kSkia8888_GrPixelConfig; |
| 341 desc.fOrigin = kBottomLeft_GrSurfaceOrigin; | 346 desc.fOrigin = kBottomLeft_GrSurfaceOrigin; |
| 342 desc.fSampleCnt = attachmentInfo.fSampleCount; | 347 desc.fSampleCnt = attachmentInfo.fSampleCount; |
| 343 desc.fStencilBits = attachmentInfo.fStencilBits; | 348 desc.fStencilBits = attachmentInfo.fStencilBits; |
| 344 GrGLint buffer; | 349 GrGLint buffer; |
| 345 GR_GL_GetIntegerv(interface, GR_GL_FRAMEBUFFER_BINDING, &buffer); | 350 GR_GL_GetIntegerv(interface, GR_GL_FRAMEBUFFER_BINDING, &buffer); |
| 346 desc.fRenderTargetHandle = buffer; | 351 desc.fRenderTargetHandle = buffer; |
| 347 return grContext->textureProvider()->wrapBackendRenderTarget(desc); | 352 return grContext->textureProvider()->wrapBackendRenderTarget(desc); |
| 348 } | 353 } |
| 349 | 354 |
| 350 #endif | 355 #endif |
| OLD | NEW |