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