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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 ASSERT(!m_paintStateIndex); | 148 ASSERT(!m_paintStateIndex); |
149 ASSERT(!m_paintState->saveCount()); | 149 ASSERT(!m_paintState->saveCount()); |
150 ASSERT(!m_annotationCount); | 150 ASSERT(!m_annotationCount); |
151 ASSERT(!m_layerCount); | 151 ASSERT(!m_layerCount); |
152 ASSERT(m_recordingStateStack.isEmpty()); | 152 ASSERT(m_recordingStateStack.isEmpty()); |
153 ASSERT(m_canvasStateStack.isEmpty()); | 153 ASSERT(m_canvasStateStack.isEmpty()); |
154 } | 154 } |
155 #endif | 155 #endif |
156 } | 156 } |
157 | 157 |
| 158 void GraphicsContext::resetCanvas(SkCanvas* canvas) |
| 159 { |
| 160 ASSERT(canvas); |
| 161 m_canvas = canvas; |
| 162 m_opaqueRegion.reset(); |
| 163 } |
| 164 |
158 void GraphicsContext::save() | 165 void GraphicsContext::save() |
159 { | 166 { |
160 if (contextDisabled()) | 167 if (contextDisabled()) |
161 return; | 168 return; |
162 | 169 |
163 m_paintState->incrementSaveCount(); | 170 m_paintState->incrementSaveCount(); |
164 | 171 |
165 m_canvasStateStack.append(CanvasSaveState(m_pendingCanvasSave, m_canvas->get
SaveCount())); | 172 m_canvasStateStack.append(CanvasSaveState(m_pendingCanvasSave, m_canvas->get
SaveCount())); |
166 m_pendingCanvasSave = true; | 173 m_pendingCanvasSave = true; |
167 } | 174 } |
(...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1037 | 1044 |
1038 void GraphicsContext::drawImageBuffer(ImageBuffer* image, const FloatRect& dest, | 1045 void GraphicsContext::drawImageBuffer(ImageBuffer* image, const FloatRect& dest, |
1039 const FloatRect* src, CompositeOperator op) | 1046 const FloatRect* src, CompositeOperator op) |
1040 { | 1047 { |
1041 if (contextDisabled() || !image) | 1048 if (contextDisabled() || !image) |
1042 return; | 1049 return; |
1043 | 1050 |
1044 image->draw(this, dest, src, op); | 1051 image->draw(this, dest, src, op); |
1045 } | 1052 } |
1046 | 1053 |
| 1054 void GraphicsContext::drawPicture(PassRefPtr<SkPicture> picture, const FloatRect
& dest, const FloatRect& src, CompositeOperator op, WebBlendMode blendMode) |
| 1055 { |
| 1056 if (contextDisabled() || !picture) |
| 1057 return; |
| 1058 |
| 1059 SkPaint picturePaint; |
| 1060 picturePaint.setXfermode(WebCoreCompositeToSkiaComposite(op, blendMode).get(
)); |
| 1061 SkRect skBounds = WebCoreFloatRectToSKRect(dest); |
| 1062 saveLayer(&skBounds, &picturePaint); |
| 1063 SkMatrix pictureTransform; |
| 1064 pictureTransform.setRectToRect(WebCoreFloatRectToSKRect(src), skBounds, SkMa
trix::kFill_ScaleToFit); |
| 1065 m_canvas->concat(pictureTransform); |
| 1066 picture->draw(m_canvas); |
| 1067 restoreLayer(); |
| 1068 } |
| 1069 |
1047 void GraphicsContext::writePixels(const SkImageInfo& info, const void* pixels, s
ize_t rowBytes, int x, int y) | 1070 void GraphicsContext::writePixels(const SkImageInfo& info, const void* pixels, s
ize_t rowBytes, int x, int y) |
1048 { | 1071 { |
1049 if (contextDisabled()) | 1072 if (contextDisabled()) |
1050 return; | 1073 return; |
1051 | 1074 |
1052 m_canvas->writePixels(info, pixels, rowBytes, x, y); | 1075 m_canvas->writePixels(info, pixels, rowBytes, x, y); |
1053 | 1076 |
1054 if (m_trackOpaqueRegion) { | 1077 if (m_trackOpaqueRegion) { |
1055 SkRect rect = SkRect::MakeXYWH(x, y, info.width(), info.height()); | 1078 SkRect rect = SkRect::MakeXYWH(x, y, info.width(), info.height()); |
1056 SkPaint paint; | 1079 SkPaint paint; |
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1826 | 1849 |
1827 void GraphicsContext::didDrawTextInRect(const SkRect& textRect) | 1850 void GraphicsContext::didDrawTextInRect(const SkRect& textRect) |
1828 { | 1851 { |
1829 if (m_trackTextRegion) { | 1852 if (m_trackTextRegion) { |
1830 TRACE_EVENT0("skia", "GraphicsContext::didDrawTextInRect"); | 1853 TRACE_EVENT0("skia", "GraphicsContext::didDrawTextInRect"); |
1831 m_textRegion.join(textRect); | 1854 m_textRegion.join(textRect); |
1832 } | 1855 } |
1833 } | 1856 } |
1834 | 1857 |
1835 } | 1858 } |
OLD | NEW |