Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013, Google Inc. All rights reserved. | 2 * Copyright (c) 2013, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "platform/graphics/UnacceleratedImageBufferSurface.h" | 31 #include "platform/graphics/UnacceleratedImageBufferSurface.h" |
| 32 | 32 |
| 33 #include "platform/RuntimeEnabledFeatures.h" | |
| 33 #include "platform/graphics/skia/SkiaUtils.h" | 34 #include "platform/graphics/skia/SkiaUtils.h" |
| 34 #include "platform/wtf/PassRefPtr.h" | 35 #include "platform/wtf/PassRefPtr.h" |
| 35 #include "third_party/skia/include/core/SkSurface.h" | 36 #include "third_party/skia/include/core/SkSurface.h" |
| 36 | 37 |
| 37 namespace blink { | 38 namespace blink { |
| 38 | 39 |
| 39 UnacceleratedImageBufferSurface::UnacceleratedImageBufferSurface( | 40 UnacceleratedImageBufferSurface::UnacceleratedImageBufferSurface( |
| 40 const IntSize& size, | 41 const IntSize& size, |
| 41 OpacityMode opacity_mode, | 42 OpacityMode opacity_mode, |
| 42 ImageInitializationMode initialization_mode, | 43 ImageInitializationMode initialization_mode, |
| 43 const CanvasColorParams& color_params) | 44 const CanvasColorParams& color_params) |
| 44 : ImageBufferSurface(size, opacity_mode, color_params) { | 45 : ImageBufferSurface(size, opacity_mode, color_params) { |
| 45 SkAlphaType alpha_type = | 46 SkAlphaType alpha_type = |
| 46 (kOpaque == opacity_mode) ? kOpaque_SkAlphaType : kPremul_SkAlphaType; | 47 (kOpaque == opacity_mode) ? kOpaque_SkAlphaType : kPremul_SkAlphaType; |
| 47 SkImageInfo info = SkImageInfo::Make( | 48 SkImageInfo info = SkImageInfo::Make( |
| 48 size.Width(), size.Height(), color_params.GetSkColorType(), alpha_type, | 49 size.Width(), size.Height(), color_params.GetSkColorType(), alpha_type, |
| 49 color_params.GetSkColorSpaceForSkSurfaces()); | 50 color_params.GetSkColorSpaceForSkSurfaces()); |
| 50 SkSurfaceProps disable_lcd_props(0, kUnknown_SkPixelGeometry); | 51 SkSurfaceProps disable_lcd_props(0, kUnknown_SkPixelGeometry); |
| 51 surface_ = SkSurface::MakeRaster( | 52 surface_ = SkSurface::MakeRaster( |
| 52 info, kOpaque == opacity_mode ? 0 : &disable_lcd_props); | 53 info, kOpaque == opacity_mode ? 0 : &disable_lcd_props); |
| 53 | 54 |
| 54 if (!surface_) | 55 if (!surface_) |
| 55 return; | 56 return; |
| 56 | 57 |
| 57 // Always save an initial frame, to support resetting the top level matrix | 58 // Always save an initial frame, to support resetting the top level matrix |
| 58 // and clip. | 59 // and clip. |
| 59 canvas_ = WTF::WrapUnique(new SkiaPaintCanvas(surface_->getCanvas())); | 60 canvas_ = WTF::WrapUnique(new SkiaPaintCanvas( |
| 61 surface_->getCanvas(), | |
| 62 RuntimeEnabledFeatures::colorCorrectRenderingEnabled() && | |
|
Justin Novosad
2017/05/29 14:45:35
Any tests for this? Does it affect layout tests u
ccameron
2017/05/29 15:27:17
This patch is part of the "fix the pile of bugs th
| |
| 63 color_params.UsesOutputSpaceBlending() | |
| 64 ? color_params.GetSkColorSpace() | |
| 65 : nullptr)); | |
| 60 canvas_->save(); | 66 canvas_->save(); |
| 61 | 67 |
| 62 if (initialization_mode == kInitializeImagePixels) | 68 if (initialization_mode == kInitializeImagePixels) |
| 63 Clear(); | 69 Clear(); |
| 64 } | 70 } |
| 65 | 71 |
| 66 UnacceleratedImageBufferSurface::~UnacceleratedImageBufferSurface() {} | 72 UnacceleratedImageBufferSurface::~UnacceleratedImageBufferSurface() {} |
| 67 | 73 |
| 68 PaintCanvas* UnacceleratedImageBufferSurface::Canvas() { | 74 PaintCanvas* UnacceleratedImageBufferSurface::Canvas() { |
| 69 return canvas_.get(); | 75 return canvas_.get(); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 81 return surface_->getCanvas()->writePixels(orig_info, pixels, row_bytes, x, y); | 87 return surface_->getCanvas()->writePixels(orig_info, pixels, row_bytes, x, y); |
| 82 } | 88 } |
| 83 | 89 |
| 84 sk_sp<SkImage> UnacceleratedImageBufferSurface::NewImageSnapshot( | 90 sk_sp<SkImage> UnacceleratedImageBufferSurface::NewImageSnapshot( |
| 85 AccelerationHint, | 91 AccelerationHint, |
| 86 SnapshotReason) { | 92 SnapshotReason) { |
| 87 return surface_->makeImageSnapshot(); | 93 return surface_->makeImageSnapshot(); |
| 88 } | 94 } |
| 89 | 95 |
| 90 } // namespace blink | 96 } // namespace blink |
| OLD | NEW |