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

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

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

Powered by Google App Engine
This is Rietveld 408576698