Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(774)

Side by Side Diff: Source/core/platform/graphics/ImageBuffer.h

Issue 14298018: This CL implements the first draft of Canvas 2D Context Attributes, aka getContext('2d', { alpha: f… (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased to ToT; test cleanup Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved. 3 * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved.
4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 enum BackingStoreCopy { 66 enum BackingStoreCopy {
67 CopyBackingStore, // Guarantee subsequent draws don't affect the copy. 67 CopyBackingStore, // Guarantee subsequent draws don't affect the copy.
68 DontCopyBackingStore // Subsequent draws may affect the copy. 68 DontCopyBackingStore // Subsequent draws may affect the copy.
69 }; 69 };
70 70
71 enum ScaleBehavior { 71 enum ScaleBehavior {
72 Scaled, 72 Scaled,
73 Unscaled 73 Unscaled
74 }; 74 };
75 75
76 enum OpacityMode {
77 NonOpaque,
78 Opaque,
79 };
80
76 class ImageBuffer { 81 class ImageBuffer {
77 WTF_MAKE_NONCOPYABLE(ImageBuffer); WTF_MAKE_FAST_ALLOCATED; 82 WTF_MAKE_NONCOPYABLE(ImageBuffer); WTF_MAKE_FAST_ALLOCATED;
78 public: 83 public:
79 // Will return a null pointer on allocation failure. 84 // Will return a null pointer on allocation failure.
80 static PassOwnPtr<ImageBuffer> create(const IntSize& size, float resolut ionScale = 1, ColorSpace colorSpace = ColorSpaceDeviceRGB, RenderingMode renderi ngMode = Unaccelerated) 85 static PassOwnPtr<ImageBuffer> create(const IntSize& size, float resolut ionScale = 1, ColorSpace colorSpace = ColorSpaceDeviceRGB, RenderingMode renderi ngMode = Unaccelerated, OpacityMode opacityMode = NonOpaque)
81 { 86 {
82 bool success = false; 87 bool success = false;
83 OwnPtr<ImageBuffer> buf = adoptPtr(new ImageBuffer(size, resolutionS cale, colorSpace, renderingMode, success)); 88 OwnPtr<ImageBuffer> buf = adoptPtr(new ImageBuffer(size, resolutionS cale, colorSpace, renderingMode, opacityMode, success));
84 if (!success) 89 if (!success)
85 return nullptr; 90 return nullptr;
86 return buf.release(); 91 return buf.release();
87 } 92 }
88 93
89 static PassOwnPtr<ImageBuffer> createCompatibleBuffer(const IntSize&, fl oat resolutionScale, ColorSpace, const GraphicsContext*, bool hasAlpha); 94 static PassOwnPtr<ImageBuffer> createCompatibleBuffer(const IntSize&, fl oat resolutionScale, ColorSpace, const GraphicsContext*, bool hasAlpha);
90 95
91 ~ImageBuffer(); 96 ~ImageBuffer();
92 97
93 // The actual resolution of the backing store 98 // The actual resolution of the backing store
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 142
138 private: 143 private:
139 ImageBufferData m_data; 144 ImageBufferData m_data;
140 IntSize m_size; 145 IntSize m_size;
141 IntSize m_logicalSize; 146 IntSize m_logicalSize;
142 float m_resolutionScale; 147 float m_resolutionScale;
143 OwnPtr<GraphicsContext> m_context; 148 OwnPtr<GraphicsContext> m_context;
144 149
145 // This constructor will place its success into the given out-variable 150 // This constructor will place its success into the given out-variable
146 // so that create() knows when it should return failure. 151 // so that create() knows when it should return failure.
147 ImageBuffer(const IntSize&, float resolutionScale, ColorSpace, Rendering Mode, bool& success); 152 ImageBuffer(const IntSize&, float resolutionScale, ColorSpace, Rendering Mode, OpacityMode, bool& success);
148 ImageBuffer(const IntSize&, float resolutionScale, ColorSpace, const Gra phicsContext*, bool hasAlpha, bool& success); 153 ImageBuffer(const IntSize&, float resolutionScale, ColorSpace, const Gra phicsContext*, bool hasAlpha, bool& success);
149 }; 154 };
150 155
151 String ImageDataToDataURL(const ImageData&, const String& mimeType, const do uble* quality); 156 String ImageDataToDataURL(const ImageData&, const String& mimeType, const do uble* quality);
152 157
153 } // namespace WebCore 158 } // namespace WebCore
154 159
155 #endif // ImageBuffer_h 160 #endif // ImageBuffer_h
OLDNEW
« no previous file with comments | « Source/core/page/RuntimeEnabledFeatures.cpp ('k') | Source/core/platform/graphics/chromium/Canvas2DLayerBridge.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698