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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/ImageBuffer.h

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments from Kent; merge. Created 4 years, 6 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
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 21 matching lines...) Expand all
32 #include "platform/geometry/FloatRect.h" 32 #include "platform/geometry/FloatRect.h"
33 #include "platform/geometry/IntSize.h" 33 #include "platform/geometry/IntSize.h"
34 #include "platform/graphics/Canvas2DLayerBridge.h" 34 #include "platform/graphics/Canvas2DLayerBridge.h"
35 #include "platform/graphics/GraphicsTypes.h" 35 #include "platform/graphics/GraphicsTypes.h"
36 #include "platform/graphics/GraphicsTypes3D.h" 36 #include "platform/graphics/GraphicsTypes3D.h"
37 #include "platform/graphics/ImageBufferSurface.h" 37 #include "platform/graphics/ImageBufferSurface.h"
38 #include "platform/transforms/AffineTransform.h" 38 #include "platform/transforms/AffineTransform.h"
39 #include "third_party/skia/include/core/SkPaint.h" 39 #include "third_party/skia/include/core/SkPaint.h"
40 #include "third_party/skia/include/core/SkPicture.h" 40 #include "third_party/skia/include/core/SkPicture.h"
41 #include "wtf/Forward.h" 41 #include "wtf/Forward.h"
42 #include "wtf/OwnPtr.h"
43 #include "wtf/PassOwnPtr.h"
44 #include "wtf/PassRefPtr.h" 42 #include "wtf/PassRefPtr.h"
45 #include "wtf/Vector.h" 43 #include "wtf/Vector.h"
46 #include "wtf/text/WTFString.h" 44 #include "wtf/text/WTFString.h"
47 #include "wtf/typed_arrays/Uint8ClampedArray.h" 45 #include "wtf/typed_arrays/Uint8ClampedArray.h"
46 #include <memory>
48 47
49 namespace gpu { 48 namespace gpu {
50 namespace gles2 { 49 namespace gles2 {
51 class GLES2Interface; 50 class GLES2Interface;
52 } 51 }
53 } 52 }
54 53
55 namespace WTF { 54 namespace WTF {
56 55
57 class ArrayBufferContents; 56 class ArrayBufferContents;
(...skipping 10 matching lines...) Expand all
68 class IntRect; 67 class IntRect;
69 68
70 enum Multiply { 69 enum Multiply {
71 Premultiplied, 70 Premultiplied,
72 Unmultiplied 71 Unmultiplied
73 }; 72 };
74 73
75 class PLATFORM_EXPORT ImageBuffer { 74 class PLATFORM_EXPORT ImageBuffer {
76 WTF_MAKE_NONCOPYABLE(ImageBuffer); USING_FAST_MALLOC(ImageBuffer); 75 WTF_MAKE_NONCOPYABLE(ImageBuffer); USING_FAST_MALLOC(ImageBuffer);
77 public: 76 public:
78 static PassOwnPtr<ImageBuffer> create(const IntSize&, OpacityMode = NonOpaqu e, ImageInitializationMode = InitializeImagePixels); 77 static std::unique_ptr<ImageBuffer> create(const IntSize&, OpacityMode = Non Opaque, ImageInitializationMode = InitializeImagePixels);
79 static PassOwnPtr<ImageBuffer> create(PassOwnPtr<ImageBufferSurface>); 78 static std::unique_ptr<ImageBuffer> create(std::unique_ptr<ImageBufferSurfac e>);
80 79
81 virtual ~ImageBuffer(); 80 virtual ~ImageBuffer();
82 81
83 void setClient(ImageBufferClient* client) { m_client = client; } 82 void setClient(ImageBufferClient* client) { m_client = client; }
84 83
85 const IntSize& size() const { return m_surface->size(); } 84 const IntSize& size() const { return m_surface->size(); }
86 bool isAccelerated() const { return m_surface->isAccelerated(); } 85 bool isAccelerated() const { return m_surface->isAccelerated(); }
87 bool isRecording() const { return m_surface->isRecording(); } 86 bool isRecording() const { return m_surface->isRecording(); }
88 void setHasExpensiveOp() { m_surface->setHasExpensiveOp(); } 87 void setHasExpensiveOp() { m_surface->setHasExpensiveOp(); }
89 bool isExpensiveToPaint() const { return m_surface->isExpensiveToPaint(); } 88 bool isExpensiveToPaint() const { return m_surface->isExpensiveToPaint(); }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 137
139 PassRefPtr<SkPicture> getPicture() { return m_surface->getPicture(); } 138 PassRefPtr<SkPicture> getPicture() { return m_surface->getPicture(); }
140 139
141 void draw(GraphicsContext&, const FloatRect&, const FloatRect*, SkXfermode:: Mode); 140 void draw(GraphicsContext&, const FloatRect&, const FloatRect*, SkXfermode:: Mode);
142 141
143 void updateGPUMemoryUsage() const; 142 void updateGPUMemoryUsage() const;
144 static intptr_t getGlobalGPUMemoryUsage() { return s_globalGPUMemoryUsage; } 143 static intptr_t getGlobalGPUMemoryUsage() { return s_globalGPUMemoryUsage; }
145 intptr_t getGPUMemoryUsage() { return m_gpuMemoryUsage; } 144 intptr_t getGPUMemoryUsage() { return m_gpuMemoryUsage; }
146 145
147 protected: 146 protected:
148 ImageBuffer(PassOwnPtr<ImageBufferSurface>); 147 ImageBuffer(std::unique_ptr<ImageBufferSurface>);
149 148
150 private: 149 private:
151 enum SnapshotState { 150 enum SnapshotState {
152 InitialSnapshotState, 151 InitialSnapshotState,
153 DidAcquireSnapshot, 152 DidAcquireSnapshot,
154 DrawnToAfterSnapshot, 153 DrawnToAfterSnapshot,
155 }; 154 };
156 mutable SnapshotState m_snapshotState; 155 mutable SnapshotState m_snapshotState;
157 OwnPtr<ImageBufferSurface> m_surface; 156 std::unique_ptr<ImageBufferSurface> m_surface;
158 ImageBufferClient* m_client; 157 ImageBufferClient* m_client;
159 158
160 mutable intptr_t m_gpuMemoryUsage; 159 mutable intptr_t m_gpuMemoryUsage;
161 static intptr_t s_globalGPUMemoryUsage; 160 static intptr_t s_globalGPUMemoryUsage;
162 }; 161 };
163 162
164 struct ImageDataBuffer { 163 struct ImageDataBuffer {
165 STACK_ALLOCATED(); 164 STACK_ALLOCATED();
166 ImageDataBuffer(const IntSize& size, const unsigned char* data) : m_data(dat a), m_size(size) { } 165 ImageDataBuffer(const IntSize& size, const unsigned char* data) : m_data(dat a), m_size(size) { }
167 String PLATFORM_EXPORT toDataURL(const String& mimeType, const double& quali ty) const; 166 String PLATFORM_EXPORT toDataURL(const String& mimeType, const double& quali ty) const;
168 bool PLATFORM_EXPORT encodeImage(const String& mimeType, const double& quali ty, Vector<unsigned char>* encodedImage) const; 167 bool PLATFORM_EXPORT encodeImage(const String& mimeType, const double& quali ty, Vector<unsigned char>* encodedImage) const;
169 const unsigned char* pixels() const { return m_data; } 168 const unsigned char* pixels() const { return m_data; }
170 const IntSize& size() const { return m_size; } 169 const IntSize& size() const { return m_size; }
171 int height() const { return m_size.height(); } 170 int height() const { return m_size.height(); }
172 int width() const { return m_size.width(); } 171 int width() const { return m_size.width(); }
173 172
174 const unsigned char* m_data; 173 const unsigned char* m_data;
175 const IntSize m_size; 174 const IntSize m_size;
176 }; 175 };
177 176
178 } // namespace blink 177 } // namespace blink
179 178
180 #endif // ImageBuffer_h 179 #endif // ImageBuffer_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698