| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 #include <wtf/MathExtras.h> | 48 #include <wtf/MathExtras.h> |
| 49 | 49 |
| 50 #if OS(DARWIN) | 50 #if OS(DARWIN) |
| 51 #include <ApplicationServices/ApplicationServices.h> | 51 #include <ApplicationServices/ApplicationServices.h> |
| 52 #endif | 52 #endif |
| 53 | 53 |
| 54 using namespace std; | 54 using namespace std; |
| 55 | 55 |
| 56 namespace WebCore { | 56 namespace WebCore { |
| 57 | 57 |
| 58 GraphicsContext::GraphicsContext(PlatformGraphicsContext* platformGraphicsContex
t) | 58 GraphicsContext::GraphicsContext(SkCanvas* canvas) |
| 59 : m_updatingControlTints(false) | 59 : m_updatingControlTints(false) |
| 60 , m_transparencyCount(0) | 60 , m_transparencyCount(0) |
| 61 { | 61 { |
| 62 if (platformGraphicsContext) | 62 if (canvas) { |
| 63 platformGraphicsContext->setGraphicsContext(this); | 63 m_data = adoptPtr(new PlatformContextSkia(canvas)); |
| 64 | 64 m_data->setGraphicsContext(this); |
| 65 // the caller owns the gc | 65 } else { |
| 66 m_data = platformGraphicsContext; | 66 // the caller owns the gc |
| 67 setPaintingDisabled(!platformGraphicsContext || !platformGraphicsContext->ca
nvas()); | 67 setPaintingDisabled(true); |
| 68 } |
| 68 } | 69 } |
| 69 | 70 |
| 70 GraphicsContext::~GraphicsContext() | 71 GraphicsContext::~GraphicsContext() |
| 71 { | 72 { |
| 72 ASSERT(m_stack.isEmpty()); | 73 ASSERT(m_stack.isEmpty()); |
| 73 ASSERT(!m_transparencyCount); | 74 ASSERT(!m_transparencyCount); |
| 74 } | 75 } |
| 75 | 76 |
| 76 PlatformGraphicsContext* GraphicsContext::platformContext() const | 77 PlatformGraphicsContext* GraphicsContext::platformContext() const |
| 77 { | 78 { |
| 78 ASSERT(!paintingDisabled()); | 79 ASSERT(!paintingDisabled()); |
| 79 return m_data; | 80 return m_data.get(); |
| 80 } | 81 } |
| 81 | 82 |
| 82 bool GraphicsContext::isAcceleratedContext() const | 83 bool GraphicsContext::isAcceleratedContext() const |
| 83 { | 84 { |
| 84 return platformContext()->isAccelerated(); | 85 return platformContext()->isAccelerated(); |
| 85 } | 86 } |
| 86 | 87 |
| 87 void GraphicsContext::save() | 88 void GraphicsContext::save() |
| 88 { | 89 { |
| 89 if (paintingDisabled()) | 90 if (paintingDisabled()) |
| (...skipping 1661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1751 static const SkPMColor colors[] = { | 1752 static const SkPMColor colors[] = { |
| 1752 SkPreMultiplyARGB(0x60, 0xFF, 0x00, 0x00), // More transparent red | 1753 SkPreMultiplyARGB(0x60, 0xFF, 0x00, 0x00), // More transparent red |
| 1753 SkPreMultiplyARGB(0x60, 0xC0, 0xC0, 0xC0) // More transparent gray | 1754 SkPreMultiplyARGB(0x60, 0xC0, 0xC0, 0xC0) // More transparent gray |
| 1754 }; | 1755 }; |
| 1755 | 1756 |
| 1756 return colors[index]; | 1757 return colors[index]; |
| 1757 } | 1758 } |
| 1758 #endif | 1759 #endif |
| 1759 | 1760 |
| 1760 } | 1761 } |
| OLD | NEW |