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

Unified Diff: gpu/ipc/common/activity_flags.h

Issue 2744363002: Clear shader disk cache after glProgramBinary failure. (Closed)
Patch Set: Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: gpu/ipc/common/activity_flags.h
diff --git a/gpu/ipc/common/activity_flags.h b/gpu/ipc/common/activity_flags.h
new file mode 100644
index 0000000000000000000000000000000000000000..a4c72fdaf2fc806cc5a2f920dce3cab1e3ced701
--- /dev/null
+++ b/gpu/ipc/common/activity_flags.h
@@ -0,0 +1,75 @@
+// Copyright (c) 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef GPU_IPC_COMMON_ACTIVITY_FLAGS_H_
+#define GPU_IPC_COMMON_ACTIVITY_FLAGS_H_
+
+#include "base/atomicops.h"
+#include "gpu/gpu_export.h"
+#include "mojo/public/cpp/system/buffer.h"
+
+namespace base {
+template <typename T>
+struct DefaultSingletonTraits;
+
+} // namespace base
+
+namespace gpu {
+
+// Base class for GpuProcessActivityFlags and GpuProcessHostActivityFlags,
+// can not be used directly.
+class GPU_EXPORT ActivityFlagsBase {
+ public:
+ enum Flag : uint32_t { FLAG_LOADING_PROGRAM_BINARY = 0x1 };
+
+ protected:
+ ActivityFlagsBase();
+ ~ActivityFlagsBase();
+
+ void Initialize(mojo::ScopedSharedBufferHandle handle);
+ const mojo::SharedBufferHandle& handle() const { return handle_.get(); }
+ bool is_initialized() const { return handle().is_valid(); }
+
+ protected:
+ volatile base::subtle::Atomic32* AsAtomic();
+
+ private:
+ mojo::ScopedSharedBufferHandle handle_;
+ mojo::ScopedSharedBufferMapping mapping_;
+};
+
+// Provides write-only access to activity flags for the gpu process. Each gpu
+// process has a singleton GpuProcessActivityFlags retreived via GetInstance().
+//
+// Note that we currently assume that the GPU process never sets/unsets flags
+// from multiple threads at the same time. This is true with our current
+// single-flag approach, but may need adjustment if additional flags are added.
+class GPU_EXPORT GpuProcessActivityFlags : public ActivityFlagsBase {
+ public:
+ static GpuProcessActivityFlags* GetInstance();
+ static void InitializeInstance(mojo::ScopedSharedBufferHandle handle);
+
+ void SetFlag(Flag flag);
+ void UnsetFlag(Flag flag);
+
+ private:
+ friend base::DefaultSingletonTraits<GpuProcessActivityFlags>;
+ GpuProcessActivityFlags() = default;
+};
+
+// Provides read-only access to activity flags. Creating a new
+// GpuProcessHostActivityFlags will initialize a new mojo shared buffer. The
+// handle to this buffer should be passed to the GPU process via CloneHandle.
+// The GPU process will then populate flags, which can be read via this class.
+class GPU_EXPORT GpuProcessHostActivityFlags : public ActivityFlagsBase {
+ public:
+ GpuProcessHostActivityFlags();
+
+ bool IsFlagSet(Flag flag);
+ mojo::ScopedSharedBufferHandle CloneHandle() { return handle().Clone(); }
+};
+
+} // namespace gpu
+
+#endif // GPU_IPC_COMMON_ACTIVITY_FLAGS_H_

Powered by Google App Engine
This is Rietveld 408576698