| 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 870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1038 | 1045 |
| 1039 void GraphicsContext::drawImageBuffer(ImageBuffer* image, const FloatRect& dest, | 1046 void GraphicsContext::drawImageBuffer(ImageBuffer* image, const FloatRect& dest, |
| 1040 const FloatRect* src, CompositeOperator op) | 1047 const FloatRect* src, CompositeOperator op) |
| 1041 { | 1048 { |
| 1042 if (contextDisabled() || !image) | 1049 if (contextDisabled() || !image) |
| 1043 return; | 1050 return; |
| 1044 | 1051 |
| 1045 image->draw(this, dest, src, op); | 1052 image->draw(this, dest, src, op); |
| 1046 } | 1053 } |
| 1047 | 1054 |
| 1055 void GraphicsContext::drawPicture(PassRefPtr<SkPicture> picture, const FloatRect
& dest, const FloatRect& src, CompositeOperator op, WebBlendMode blendMode) |
| 1056 { |
| 1057 if (contextDisabled() || !picture) |
| 1058 return; |
| 1059 |
| 1060 SkPaint picturePaint; |
| 1061 picturePaint.setXfermode(WebCoreCompositeToSkiaComposite(op, blendMode).get(
)); |
| 1062 SkRect skBounds = WebCoreFloatRectToSKRect(dest); |
| 1063 saveLayer(&skBounds, &picturePaint); |
| 1064 SkMatrix pictureTransform; |
| 1065 pictureTransform.setRectToRect(WebCoreFloatRectToSKRect(src), skBounds, SkMa
trix::kFill_ScaleToFit); |
| 1066 m_canvas->concat(pictureTransform); |
| 1067 picture->draw(m_canvas); |
| 1068 restoreLayer(); |
| 1069 } |
| 1070 |
| 1048 void GraphicsContext::writePixels(const SkImageInfo& info, const void* pixels, s
ize_t rowBytes, int x, int y) | 1071 void GraphicsContext::writePixels(const SkImageInfo& info, const void* pixels, s
ize_t rowBytes, int x, int y) |
| 1049 { | 1072 { |
| 1050 if (contextDisabled()) | 1073 if (contextDisabled()) |
| 1051 return; | 1074 return; |
| 1052 | 1075 |
| 1053 m_canvas->writePixels(info, pixels, rowBytes, x, y); | 1076 m_canvas->writePixels(info, pixels, rowBytes, x, y); |
| 1054 | 1077 |
| 1055 if (m_trackOpaqueRegion) { | 1078 if (m_trackOpaqueRegion) { |
| 1056 SkRect rect = SkRect::MakeXYWH(x, y, info.width(), info.height()); | 1079 SkRect rect = SkRect::MakeXYWH(x, y, info.width(), info.height()); |
| 1057 SkPaint paint; | 1080 SkPaint paint; |
| (...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1827 | 1850 |
| 1828 void GraphicsContext::didDrawTextInRect(const SkRect& textRect) | 1851 void GraphicsContext::didDrawTextInRect(const SkRect& textRect) |
| 1829 { | 1852 { |
| 1830 if (m_trackTextRegion) { | 1853 if (m_trackTextRegion) { |
| 1831 TRACE_EVENT0("skia", "GraphicsContext::didDrawTextInRect"); | 1854 TRACE_EVENT0("skia", "GraphicsContext::didDrawTextInRect"); |
| 1832 m_textRegion.join(textRect); | 1855 m_textRegion.join(textRect); |
| 1833 } | 1856 } |
| 1834 } | 1857 } |
| 1835 | 1858 |
| 1836 } | 1859 } |
| OLD | NEW |