OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2003, 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2003, 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. |
3 * Copyright (C) 2013 Google Inc. All rights reserved. | 3 * Copyright (C) 2013 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 m_canvas->restoreToCount(savedState.m_restoreCount); | 179 m_canvas->restoreToCount(savedState.m_restoreCount); |
180 } | 180 } |
181 | 181 |
182 void GraphicsContext::saveLayer(const SkRect* bounds, const SkPaint* paint, SkCa
nvas::SaveFlags saveFlags) | 182 void GraphicsContext::saveLayer(const SkRect* bounds, const SkPaint* paint, SkCa
nvas::SaveFlags saveFlags) |
183 { | 183 { |
184 if (paintingDisabled()) | 184 if (paintingDisabled()) |
185 return; | 185 return; |
186 | 186 |
187 realizeCanvasSave(SkCanvas::kMatrixClip_SaveFlag); | 187 realizeCanvasSave(SkCanvas::kMatrixClip_SaveFlag); |
188 | 188 |
| 189 // We should always save the matrix and clip to match upcoming Skia behavior
. |
| 190 ASSERT(saveFlags & SkCanvas::kMatrix_SaveFlag); |
| 191 ASSERT(saveFlags & SkCanvas::kClip_SaveFlag); |
| 192 |
189 m_canvas->saveLayer(bounds, paint, saveFlags); | 193 m_canvas->saveLayer(bounds, paint, saveFlags); |
190 if (bounds) | 194 if (bounds) |
191 m_canvas->clipRect(*bounds); | 195 m_canvas->clipRect(*bounds); |
192 if (m_trackOpaqueRegion) | 196 if (m_trackOpaqueRegion) |
193 m_opaqueRegion.pushCanvasLayer(paint); | 197 m_opaqueRegion.pushCanvasLayer(paint); |
194 } | 198 } |
195 | 199 |
196 void GraphicsContext::restoreLayer() | 200 void GraphicsContext::restoreLayer() |
197 { | 201 { |
198 if (paintingDisabled()) | 202 if (paintingDisabled()) |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 | 452 |
449 void GraphicsContext::beginLayer(float opacity, CompositeOperator op, const Floa
tRect* bounds, ColorFilter colorFilter, ImageFilter* imageFilter) | 453 void GraphicsContext::beginLayer(float opacity, CompositeOperator op, const Floa
tRect* bounds, ColorFilter colorFilter, ImageFilter* imageFilter) |
450 { | 454 { |
451 if (paintingDisabled()) | 455 if (paintingDisabled()) |
452 return; | 456 return; |
453 | 457 |
454 // We need the "alpha" layer flag here because the base layer is opaque | 458 // We need the "alpha" layer flag here because the base layer is opaque |
455 // (the surface of the page) but layers on top may have transparent parts. | 459 // (the surface of the page) but layers on top may have transparent parts. |
456 // Without explicitly setting the alpha flag, the layer will inherit the | 460 // Without explicitly setting the alpha flag, the layer will inherit the |
457 // opaque setting of the base and some things won't work properly. | 461 // opaque setting of the base and some things won't work properly. |
458 SkCanvas::SaveFlags saveFlags = static_cast<SkCanvas::SaveFlags>(SkCanvas::k
HasAlphaLayer_SaveFlag | SkCanvas::kFullColorLayer_SaveFlag); | 462 SkCanvas::SaveFlags saveFlags = static_cast<SkCanvas::SaveFlags>( |
| 463 SkCanvas::kMatrixClip_SaveFlag | SkCanvas::kHasAlphaLayer_SaveFlag | SkC
anvas::kFullColorLayer_SaveFlag); |
459 | 464 |
460 SkPaint layerPaint; | 465 SkPaint layerPaint; |
461 layerPaint.setAlpha(static_cast<unsigned char>(opacity * 255)); | 466 layerPaint.setAlpha(static_cast<unsigned char>(opacity * 255)); |
462 layerPaint.setXfermode(WebCoreCompositeToSkiaComposite(op, m_paintState->ble
ndMode()).get()); | 467 layerPaint.setXfermode(WebCoreCompositeToSkiaComposite(op, m_paintState->ble
ndMode()).get()); |
463 layerPaint.setColorFilter(WebCoreColorFilterToSkiaColorFilter(colorFilter).g
et()); | 468 layerPaint.setColorFilter(WebCoreColorFilterToSkiaColorFilter(colorFilter).g
et()); |
464 layerPaint.setImageFilter(imageFilter); | 469 layerPaint.setImageFilter(imageFilter); |
465 | 470 |
466 // Filters will adjust the clip to accomodate for filter bounds, but | 471 // Filters will adjust the clip to accomodate for filter bounds, but |
467 // need the kClipToLayer_SaveFlag to do so. We also save the clip here, so | 472 // need the kClipToLayer_SaveFlag to do so. We also save the clip here, so |
468 // it is restored back before the filtered layer is drawn in restore(). | 473 // it is restored back before the filtered layer is drawn in restore(). |
(...skipping 1416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1885 | 1890 |
1886 void GraphicsContext::didDrawTextInRect(const SkRect& textRect) | 1891 void GraphicsContext::didDrawTextInRect(const SkRect& textRect) |
1887 { | 1892 { |
1888 if (m_trackTextRegion) { | 1893 if (m_trackTextRegion) { |
1889 TRACE_EVENT0("skia", "PlatformContextSkia::trackTextRegion"); | 1894 TRACE_EVENT0("skia", "PlatformContextSkia::trackTextRegion"); |
1890 m_textRegion.join(textRect); | 1895 m_textRegion.join(textRect); |
1891 } | 1896 } |
1892 } | 1897 } |
1893 | 1898 |
1894 } | 1899 } |
OLD | NEW |