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

Unified Diff: chromecast/ui/gfx/gfx_plane.h

Issue 223143003: Initial checkin of chromecast content embedder (cast_shell) and related build scripts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add an additional function in gl_surface_cast.cc Created 6 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: chromecast/ui/gfx/gfx_plane.h
diff --git a/chromecast/ui/gfx/gfx_plane.h b/chromecast/ui/gfx/gfx_plane.h
new file mode 100644
index 0000000000000000000000000000000000000000..7d52cde3aa493a62796b5bfe26c7873c27fa4eb1
--- /dev/null
+++ b/chromecast/ui/gfx/gfx_plane.h
@@ -0,0 +1,116 @@
+// Copyright (c) 2014 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 CHROMECAST_UI_GFX_GFX_PLANE_H_
+#define CHROMECAST_UI_GFX_GFX_PLANE_H_
+
+#include <list>
+
+#include "base/memory/scoped_ptr.h"
+#include "chromecast/ui/gfx/surface.h"
+#include "ui/gfx/rect.h"
+
+namespace base {
+class CommandLine;
+}
+
+namespace gfx {
+
+class Point;
+class Size;
+
+namespace chromecast {
+
+class Osd {
+ public:
+ explicit Osd(Surface* surface);
+ ~Osd();
+
+ Surface* surface() const { return surface_.get(); }
+ const Size& size() const { return surface_->size(); }
+
+ private:
+ const scoped_ptr<Surface> surface_;
+
+ DISALLOW_COPY_AND_ASSIGN(Osd);
+};
+
+// Abstract GFX plane for graphics and OSD.
+class GfxPlane {
+ public:
+ // For primary GFX plane.
+ static GfxPlane* CreatePrimary(const base::CommandLine& command_line,
+ const Size& requested_screen_size);
+ static void DestroyPrimary();
+ static GfxPlane* GetPrimary() { return primary_; }
+
+ // For OSD GFX plane.
+ static GfxPlane* CreateOsdPlane();
+ static void DestroyOsdPlane();
+ static GfxPlane* GetOsdPlane();
+ // Resizes the osd plane once screen resolution info becomes available.
+ static void ResizeOsdPlane(const Size& size);
+
+ GfxPlane();
+ virtual ~GfxPlane();
+
+ // Creates a surface on top of this plane.
+ virtual Surface* CreateSurface(const Size& size) = 0;
+
+ // Returns true if this plane is only for OSD.
+ virtual bool IsOsdPlane() const;
+ // Creates an OSD on top of this plane.
+ Osd* CreateOsd(const Size& size);
+ // Adds an OSD to display. The OSD newly added has highest priority.
+ void AddOsd(Osd* osd, const Point& frame_buffer_point);
+ // Removes the first (highest order of) OSD from the list.
+ void RemoveOsd(Osd* osd, const Point& frame_buffer_point);
+
+ // Displays a surface to screen. It blits to the frame buffer. If any osd
+ // surfaces exist, it composites all osd overlapped with given area before
+ // blitting to the frame buffer.
+ void Display(Surface* surface, const Rect& rect,
+ const Point& frame_buffer_point);
+
+ // Refreshes the screen in given area. If OSD's are changed, it must be called
+ // to refresh the screen.
+ virtual void Refresh(const Rect& frame_buffer_rect);
+
+ // Returns the screen size of this plane.
+ virtual const Size size() const;
+
+ int& num_surfaces() { return num_surfaces_; }
+
+ Surface* frame_buffer() const { return frame_buffer_.get(); }
+ void set_frame_buffer(Surface* surface) { frame_buffer_.reset(surface); }
+
+ // Returns true if we allow 1080p graphics
+ static bool Is1080pAllowed();
+
+ protected:
+ struct OsdAndRect {
+ Osd* osd;
+ Rect rect; // Overlaid area in frame buffer.
+ };
+
+ // Called when a surface on this gfx plane is removed.
+ virtual void OnRemoved(Surface* surface);
+
+ std::list<OsdAndRect> osd_and_rects_;
+
+ private:
+ friend class Surface; // For OnRemoved().
+
+ static GfxPlane* primary_;
+
+ int num_surfaces_;
+ scoped_ptr<Surface> frame_buffer_;
+
+ Surface* current_surface_; // Non-OSD surface which called Display() last.
+};
+
+} // namespace chromecast
+} // namespace gfx
+
+#endif // CHROMECAST_UI_GFX_GFX_PLANE_H_

Powered by Google App Engine
This is Rietveld 408576698